summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
Diffstat (limited to 'system')
-rw-r--r--system/application/config/config.php602
-rw-r--r--system/application/views/welcome_message.php122
-rw-r--r--system/codeigniter/Base4.php132
-rw-r--r--system/codeigniter/Base5.php106
-rw-r--r--system/codeigniter/CodeIgniter.php4
-rw-r--r--system/codeigniter/Common.php518
-rw-r--r--system/database/DB.php170
-rw-r--r--system/database/DB_active_rec.php4
-rw-r--r--system/database/DB_cache.php386
-rw-r--r--system/database/DB_driver.php2132
-rw-r--r--system/database/DB_result.php578
-rw-r--r--system/database/DB_utility.php908
-rw-r--r--system/database/drivers/mssql/mssql_driver.php914
-rw-r--r--system/database/drivers/mssql/mssql_result.php344
-rw-r--r--system/database/drivers/mssql/mssql_utility.php258
-rw-r--r--system/database/drivers/mysql/mysql_driver.php982
-rw-r--r--system/database/drivers/mysql/mysql_result.php344
-rw-r--r--system/database/drivers/mysql/mysql_utility.php486
-rw-r--r--system/database/drivers/mysqli/mysqli_driver.php964
-rw-r--r--system/database/drivers/mysqli/mysqli_result.php344
-rw-r--r--system/database/drivers/mysqli/mysqli_utility.php488
-rw-r--r--system/database/drivers/oci8/oci8_driver.php1208
-rw-r--r--system/database/drivers/oci8/oci8_result.php500
-rw-r--r--system/database/drivers/oci8/oci8_utility.php256
-rw-r--r--system/database/drivers/odbc/odbc_driver.php4
-rw-r--r--system/database/drivers/odbc/odbc_result.php466
-rw-r--r--system/database/drivers/odbc/odbc_utility.php320
-rw-r--r--system/database/drivers/postgre/postgre_driver.php4
-rw-r--r--system/database/drivers/postgre/postgre_result.php344
-rw-r--r--system/database/drivers/postgre/postgre_utility.php256
-rw-r--r--system/database/drivers/sqlite/sqlite_driver.php966
-rw-r--r--system/database/drivers/sqlite/sqlite_result.php350
-rw-r--r--system/database/drivers/sqlite/sqlite_utility.php306
-rw-r--r--system/helpers/array_helper.php140
-rw-r--r--system/helpers/cookie_helper.php250
-rw-r--r--system/helpers/date_helper.php6
-rw-r--r--system/helpers/directory_helper.php132
-rw-r--r--system/helpers/download_helper.php6
-rw-r--r--system/helpers/file_helper.php356
-rw-r--r--system/helpers/form_helper.php6
-rw-r--r--system/helpers/html_helper.php406
-rw-r--r--system/helpers/inflector_helper.php278
-rw-r--r--system/helpers/security_helper.php222
-rw-r--r--system/helpers/smiley_helper.php328
-rw-r--r--system/helpers/string_helper.php6
-rw-r--r--system/helpers/text_helper.php840
-rw-r--r--system/helpers/typography_helper.php1078
-rw-r--r--system/helpers/url_helper.php6
-rw-r--r--system/helpers/xml_helper.php114
-rw-r--r--system/libraries/Benchmark.php220
-rw-r--r--system/libraries/Calendar.php948
-rw-r--r--system/libraries/Config.php488
-rw-r--r--system/libraries/Controller.php228
-rw-r--r--system/libraries/Email.php3436
-rw-r--r--system/libraries/Encrypt.php792
-rw-r--r--system/libraries/Exceptions.php4
-rw-r--r--system/libraries/Ftp.php1230
-rw-r--r--system/libraries/Hooks.php446
-rw-r--r--system/libraries/Image_lib.php4
-rw-r--r--system/libraries/Input.php4
-rw-r--r--system/libraries/Language.php240
-rw-r--r--system/libraries/Loader.php4
-rw-r--r--system/libraries/Log.php234
-rw-r--r--system/libraries/Model.php162
-rw-r--r--system/libraries/Output.php726
-rw-r--r--system/libraries/Pagination.php420
-rw-r--r--system/libraries/Parser.php340
-rw-r--r--system/libraries/Profiler.php6
-rw-r--r--system/libraries/Router.php4
-rw-r--r--system/libraries/Session.php974
-rw-r--r--system/libraries/Sha1.php496
-rw-r--r--system/libraries/Table.php4
-rw-r--r--system/libraries/Trackback.php1094
-rw-r--r--system/libraries/URI.php732
-rw-r--r--system/libraries/Unit_test.php660
-rw-r--r--system/libraries/Upload.php1616
-rw-r--r--system/libraries/User_agent.php4
-rw-r--r--system/libraries/Validation.php1468
-rw-r--r--system/libraries/Xmlrpc.php2822
-rw-r--r--system/libraries/Xmlrpcs.php1004
-rw-r--r--system/libraries/Zip.php758
-rw-r--r--system/plugins/captcha_pi.php690
-rw-r--r--system/plugins/js_calendar_pi.php1206
-rw-r--r--system/scaffolding/Scaffolding.php576
-rw-r--r--system/scaffolding/views/footer.php18
85 files changed, 21999 insertions, 21999 deletions
diff --git a/system/application/config/config.php b/system/application/config/config.php
index b1598b341..3bb9d1d23 100644
--- a/system/application/config/config.php
+++ b/system/application/config/config.php
@@ -1,302 +1,302 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-
-/*
-|--------------------------------------------------------------------------
-| Base Site URL
-|--------------------------------------------------------------------------
-|
-| URL to your Code Igniter root. Typically this will be your base URL,
-| WITH a trailing slash:
-|
-| http://www.your-site.com/
-|
-*/
-$config['base_url'] = "http://127.0.0.1/CodeIgniter/";
-
-/*
-|--------------------------------------------------------------------------
-| 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 Code Igniter.
-| For more information please see the user guide:
-|
-| http://www.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";
-
-
-/*
-|--------------------------------------------------------------------------
-| 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://www.codeigniter.com/user_guide/general/core_classes.html
-| http://www.codeigniter.com/user_guide/general/creating_libraries.html
-|
-*/
-$config['subclass_prefix'] = 'MY_';
-
-
-/*
-|--------------------------------------------------------------------------
-| Allowed URL Characters
-|--------------------------------------------------------------------------
-|
-| This lets you specify 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 Code Igniter uses search-engine friendly segment based URLs:
-| www.your-site.com/who/what/where/
-|
-| You can optionally enable standard query string based URLs:
-| www.your-site.com?who=me&what=something&where=here
-|
-| Options are: TRUE or FALSE (boolean)
-|
-| The two other items let you set the query string "words" that will
-| invoke your controllers and its functions:
-| www.your-site.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 Code Igniter is designed primarily to
-| use segment based URLs.
-|
-*/
-$config['enable_query_strings'] = FALSE;
-$config['controller_trigger'] = 'c';
-$config['function_trigger'] = 'm';
-
-/*
-|--------------------------------------------------------------------------
-| 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
-| 0 = Error logging TURNED OFF
-| 1 = Error Messages (including PHP errors)
-| 2 = Debug Messages
-| 3 = Informational Messages
-| 4 = All Messages
-|
-| For a live site you'll usually only enable Errors (1) to be logged otherwise
-| your log files will fill up very fast.
-|
-*/
-$config['log_threshold'] = 0;
-
-/*
-|--------------------------------------------------------------------------
-| Error Logging Directory Path
-|--------------------------------------------------------------------------
-|
-| Leave this BLANK unless you would like to set something other than the default
-| system/logs/ folder. Use a full server path with trailing slash.
-|
-*/
-$config['log_path'] = '';
-
-/*
-|--------------------------------------------------------------------------
-| Date Format for Logs
-|--------------------------------------------------------------------------
-|
-| Each item that is logged has an associated date. You can use PHP date
-| codes to set your own date formatting
-|
-*/
-$config['log_date_format'] = 'Y-m-d H:i:s';
-
-/*
-|--------------------------------------------------------------------------
-| Cache Directory Path
-|--------------------------------------------------------------------------
-|
-| Leave this BLANK unless you would like to set something other than the default
-| system/cache/ folder. Use a full server path with trailing slash.
-|
-*/
-$config['cache_path'] = '';
-
-/*
-|--------------------------------------------------------------------------
-| Encryption Key
-|--------------------------------------------------------------------------
-|
-| If you use the Encryption class or the Sessions class with encryption
-| enabled you MUST set an encryption key. See the user guide for info.
-|
-*/
-$config['encryption_key'] = "";
-
-/*
-|--------------------------------------------------------------------------
-| Session Variables
-|--------------------------------------------------------------------------
-|
-| 'session_cookie_name' = the name you want for the cookie
-| 'encrypt_sess_cookie' = TRUE/FALSE (boolean). Whether to encrypt the cookie
-| 'session_expiration' = the number of SECONDS you want the session to last.
-| by default sessions last 7200 seconds (two hours). Set to zero for no expiration.
-|
-*/
-$config['sess_cookie_name'] = 'ci_session';
-$config['sess_expiration'] = 7200;
-$config['sess_encrypt_cookie'] = FALSE;
-$config['sess_use_database'] = FALSE;
-$config['sess_table_name'] = 'ci_sessions';
-$config['sess_match_ip'] = FALSE;
-$config['sess_match_useragent'] = TRUE;
-
-/*
-|--------------------------------------------------------------------------
-| Cookie Related Variables
-|--------------------------------------------------------------------------
-|
-| 'cookie_prefix' = Set a prefix if you need to avoid collisions
-| 'cookie_domain' = Set to .your-domain.com for site-wide cookies
-| 'cookie_path' = Typically will be a forward slash
-|
-*/
-$config['cookie_prefix'] = "";
-$config['cookie_domain'] = "";
-$config['cookie_path'] = "/";
-
-/*
-|--------------------------------------------------------------------------
-| Global XSS Filtering
-|--------------------------------------------------------------------------
-|
-| Determines whether the XSS filter is always active when GET, POST or
-| COOKIE data is encountered
-|
-*/
-$config['global_xss_filtering'] = FALSE;
-
-/*
-|--------------------------------------------------------------------------
-| Output Compression
-|--------------------------------------------------------------------------
-|
-| Enables Gzip output compression for faster page loads. When enabled,
-| the output class will test whether your server supports Gzip.
-| Even if it does, however, not all browsers support compression
-| so enable only if you are reasonably sure your visitors can handle it.
-|
-| VERY IMPORTANT: If you are getting a blank page when compression is enabled it
-| means you are prematurely outputting something to your browser. It could
-| even be a line of whitespace at the end of one of your scripts. For
-| compression to work, nothing can be sent before the output buffer is called
-| by the output class. Do not "echo" any values with compression enabled.
-|
-*/
-$config['compress_output'] = FALSE;
-
-/*
-|--------------------------------------------------------------------------
-| Master Time Reference
-|--------------------------------------------------------------------------
-|
-| Options are "local" or "gmt". This pref tells the system whether to use
-| your server's local time as the master "now" reference, or convert it to
-| GMT. See the "date helper" page of the user guide for information
-| regarding date handling.
-|
-*/
-$config['time_reference'] = 'local';
-
-
-/*
-|--------------------------------------------------------------------------
-| Rewrite PHP Short Tags
-|--------------------------------------------------------------------------
-|
-| If your PHP installation does not have short tag support enabled CI
-| can rewrite the tags on-the-fly, enabling you to utilize that syntax
-| in your view files. Options are TRUE or FALSE (boolean)
-|
-*/
-$config['rewrite_short_tags'] = FALSE;
-
-
+<?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://www.your-site.com/
+|
+*/
+$config['base_url'] = "http://127.0.0.1/CodeIgniter/";
+
+/*
+|--------------------------------------------------------------------------
+| 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://www.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";
+
+
+/*
+|--------------------------------------------------------------------------
+| 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://www.codeigniter.com/user_guide/general/core_classes.html
+| http://www.codeigniter.com/user_guide/general/creating_libraries.html
+|
+*/
+$config['subclass_prefix'] = 'MY_';
+
+
+/*
+|--------------------------------------------------------------------------
+| Allowed URL Characters
+|--------------------------------------------------------------------------
+|
+| This lets you specify 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:
+| www.your-site.com/who/what/where/
+|
+| You can optionally enable standard query string based URLs:
+| www.your-site.com?who=me&what=something&where=here
+|
+| Options are: TRUE or FALSE (boolean)
+|
+| The two other items let you set the query string "words" that will
+| invoke your controllers and its functions:
+| www.your-site.com/index.php?c=controller&m=function
+|
+| Please note that some of the helpers won't work as expected when
+| this feature is enabled, since CodeIgniter is designed primarily to
+| use segment based URLs.
+|
+*/
+$config['enable_query_strings'] = FALSE;
+$config['controller_trigger'] = 'c';
+$config['function_trigger'] = 'm';
+
+/*
+|--------------------------------------------------------------------------
+| 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
+| 0 = Error logging TURNED OFF
+| 1 = Error Messages (including PHP errors)
+| 2 = Debug Messages
+| 3 = Informational Messages
+| 4 = All Messages
+|
+| For a live site you'll usually only enable Errors (1) to be logged otherwise
+| your log files will fill up very fast.
+|
+*/
+$config['log_threshold'] = 0;
+
+/*
+|--------------------------------------------------------------------------
+| Error Logging Directory Path
+|--------------------------------------------------------------------------
+|
+| Leave this BLANK unless you would like to set something other than the default
+| system/logs/ folder. Use a full server path with trailing slash.
+|
+*/
+$config['log_path'] = '';
+
+/*
+|--------------------------------------------------------------------------
+| Date Format for Logs
+|--------------------------------------------------------------------------
+|
+| Each item that is logged has an associated date. You can use PHP date
+| codes to set your own date formatting
+|
+*/
+$config['log_date_format'] = 'Y-m-d H:i:s';
+
+/*
+|--------------------------------------------------------------------------
+| Cache Directory Path
+|--------------------------------------------------------------------------
+|
+| Leave this BLANK unless you would like to set something other than the default
+| system/cache/ folder. Use a full server path with trailing slash.
+|
+*/
+$config['cache_path'] = '';
+
+/*
+|--------------------------------------------------------------------------
+| Encryption Key
+|--------------------------------------------------------------------------
+|
+| If you use the Encryption class or the Sessions class with encryption
+| enabled you MUST set an encryption key. See the user guide for info.
+|
+*/
+$config['encryption_key'] = "";
+
+/*
+|--------------------------------------------------------------------------
+| Session Variables
+|--------------------------------------------------------------------------
+|
+| 'session_cookie_name' = the name you want for the cookie
+| 'encrypt_sess_cookie' = TRUE/FALSE (boolean). Whether to encrypt the cookie
+| 'session_expiration' = the number of SECONDS you want the session to last.
+| by default sessions last 7200 seconds (two hours). Set to zero for no expiration.
+|
+*/
+$config['sess_cookie_name'] = 'ci_session';
+$config['sess_expiration'] = 7200;
+$config['sess_encrypt_cookie'] = FALSE;
+$config['sess_use_database'] = FALSE;
+$config['sess_table_name'] = 'ci_sessions';
+$config['sess_match_ip'] = FALSE;
+$config['sess_match_useragent'] = TRUE;
+
+/*
+|--------------------------------------------------------------------------
+| Cookie Related Variables
+|--------------------------------------------------------------------------
+|
+| 'cookie_prefix' = Set a prefix if you need to avoid collisions
+| 'cookie_domain' = Set to .your-domain.com for site-wide cookies
+| 'cookie_path' = Typically will be a forward slash
+|
+*/
+$config['cookie_prefix'] = "";
+$config['cookie_domain'] = "";
+$config['cookie_path'] = "/";
+
+/*
+|--------------------------------------------------------------------------
+| Global XSS Filtering
+|--------------------------------------------------------------------------
+|
+| Determines whether the XSS filter is always active when GET, POST or
+| COOKIE data is encountered
+|
+*/
+$config['global_xss_filtering'] = FALSE;
+
+/*
+|--------------------------------------------------------------------------
+| Output Compression
+|--------------------------------------------------------------------------
+|
+| Enables Gzip output compression for faster page loads. When enabled,
+| the output class will test whether your server supports Gzip.
+| Even if it does, however, not all browsers support compression
+| so enable only if you are reasonably sure your visitors can handle it.
+|
+| VERY IMPORTANT: If you are getting a blank page when compression is enabled it
+| means you are prematurely outputting something to your browser. It could
+| even be a line of whitespace at the end of one of your scripts. For
+| compression to work, nothing can be sent before the output buffer is called
+| by the output class. Do not "echo" any values with compression enabled.
+|
+*/
+$config['compress_output'] = FALSE;
+
+/*
+|--------------------------------------------------------------------------
+| Master Time Reference
+|--------------------------------------------------------------------------
+|
+| Options are "local" or "gmt". This pref tells the system whether to use
+| your server's local time as the master "now" reference, or convert it to
+| GMT. See the "date helper" page of the user guide for information
+| regarding date handling.
+|
+*/
+$config['time_reference'] = 'local';
+
+
+/*
+|--------------------------------------------------------------------------
+| Rewrite PHP Short Tags
+|--------------------------------------------------------------------------
+|
+| If your PHP installation does not have short tag support enabled CI
+| can rewrite the tags on-the-fly, enabling you to utilize that syntax
+| in your view files. Options are TRUE or FALSE (boolean)
+|
+*/
+$config['rewrite_short_tags'] = FALSE;
+
+
?> \ No newline at end of file
diff --git a/system/application/views/welcome_message.php b/system/application/views/welcome_message.php
index 393fb56e1..8313059e4 100644
--- a/system/application/views/welcome_message.php
+++ b/system/application/views/welcome_message.php
@@ -1,62 +1,62 @@
-<html>
-<head>
-<title>Welcome to Code Igniter</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 Code Igniter!</h1>
-
-<p>The page you are looking at is being generated dynamically by Code Igniter.</p>
-
-<p>If you would like to edit this page you'll find it located at:</p>
-<code>system/application/views/welcome_message.php</code>
-
-<p>The corresponding controller for this page is found at:</p>
-<code>system/application/controllers/welcome.php</code>
-
-<p>If you are exploring Code Igniter 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>
+<head>
+<title>Welcome to CodeIgniter</title>
+
+<style type="text/css">
+
+body {
+ background-color: #fff;
+ margin: 40px;
+ font-family: Lucida Grande, Verdana, Sans-serif;
+ font-size: 14px;
+ color: #4F5155;
+}
+
+a {
+ color: #003399;
+ background-color: transparent;
+ font-weight: normal;
+}
+
+h1 {
+ color: #444;
+ background-color: transparent;
+ border-bottom: 1px solid #D0D0D0;
+ font-size: 16px;
+ font-weight: bold;
+ margin: 24px 0 2px 0;
+ padding: 5px 0 6px 0;
+}
+
+code {
+ font-family: Monaco, Verdana, Sans-serif;
+ font-size: 12px;
+ background-color: #f9f9f9;
+ border: 1px solid #D0D0D0;
+ color: #002166;
+ display: block;
+ margin: 14px 0 14px 0;
+ padding: 12px 10px 12px 10px;
+}
+
+</style>
+</head>
+<body>
+
+<h1>Welcome to CodeIgniter!</h1>
+
+<p>The page you are looking at is being generated dynamically by CodeIgniter.</p>
+
+<p>If you would like to edit this page you'll find it located at:</p>
+<code>system/application/views/welcome_message.php</code>
+
+<p>The corresponding controller for this page is found at:</p>
+<code>system/application/controllers/welcome.php</code>
+
+<p>If you are exploring CodeIgniter for the very first time, you should start by reading the <a href="user_guide/">User Guide</a>.</p>
+
+
+<p><br />Page rendered in {elapsed_time} seconds</p>
+
+</body>
</html> \ No newline at end of file
diff --git a/system/codeigniter/Base4.php b/system/codeigniter/Base4.php
index b2713b660..b00da8ba2 100644
--- a/system/codeigniter/Base4.php
+++ b/system/codeigniter/Base4.php
@@ -1,67 +1,67 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.3
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * CI_BASE - For PHP 4
- *
- * This file is used only when Code Igniter is being run under PHP 4.
- *
- * In order to allow CI to work under PHP 4 we had to make the Loader class
- * the parent of the Controller Base class. It's the only way we can
- * enable functions like $this->load->library('email') to instantiate
- * classes that can then be used within controllers as $this->email->send()
- *
- * PHP 4 also has trouble referencing the CI super object within application
- * constructors since objects do not exist until the class is fully
- * instantiated. Basically PHP 4 sucks...
- *
- * Since PHP 5 doesn't suffer from this problem so we load one of
- * two files based on the version of PHP being run.
- *
- * @package CodeIgniter
- * @subpackage codeigniter
- * @category front-controller
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/
- */
- class CI_Base extends CI_Loader {
-
- function CI_Base()
- {
- // This allows syntax like $this->load->foo() to work
- parent::CI_Loader();
- $this->load =& $this;
-
- // This allows resources used within controller constructors to work
- global $OBJ;
- $OBJ = $this->load; // Do NOT use a reference.
- }
-}
-
-function &get_instance()
-{
- global $CI, $OBJ;
-
- if (is_object($CI))
- {
- return $CI;
- }
-
- return $OBJ->load;
-}
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.3
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CI_BASE - For PHP 4
+ *
+ * This file is used only when CodeIgniter is being run under PHP 4.
+ *
+ * In order to allow CI to work under PHP 4 we had to make the Loader class
+ * the parent of the Controller Base class. It's the only way we can
+ * enable functions like $this->load->library('email') to instantiate
+ * classes that can then be used within controllers as $this->email->send()
+ *
+ * PHP 4 also has trouble referencing the CI super object within application
+ * constructors since objects do not exist until the class is fully
+ * instantiated. Basically PHP 4 sucks...
+ *
+ * Since PHP 5 doesn't suffer from this problem so we load one of
+ * two files based on the version of PHP being run.
+ *
+ * @package CodeIgniter
+ * @subpackage codeigniter
+ * @category front-controller
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/
+ */
+ class CI_Base extends CI_Loader {
+
+ function CI_Base()
+ {
+ // This allows syntax like $this->load->foo() to work
+ parent::CI_Loader();
+ $this->load =& $this;
+
+ // This allows resources used within controller constructors to work
+ global $OBJ;
+ $OBJ = $this->load; // Do NOT use a reference.
+ }
+}
+
+function &get_instance()
+{
+ global $CI, $OBJ;
+
+ if (is_object($CI))
+ {
+ return $CI;
+ }
+
+ return $OBJ->load;
+}
+
?> \ No newline at end of file
diff --git a/system/codeigniter/Base5.php b/system/codeigniter/Base5.php
index 0d036fae2..d1531a571 100644
--- a/system/codeigniter/Base5.php
+++ b/system/codeigniter/Base5.php
@@ -1,54 +1,54 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.3
- * @filesource
- */
-
-
-// ------------------------------------------------------------------------
-
-/**
- * CI_BASE - For PHP 5
- *
- * This file contains some code used only when Code Igniter is being
- * run under PHP 5. It allows us to manage the CI super object more
- * gracefully than what is possible with PHP 4.
- *
- * @package CodeIgniter
- * @subpackage codeigniter
- * @category front-controller
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/
- */
-
-class CI_Base {
-
- private static $instance;
-
- public function CI_Base()
- {
- self::$instance =& $this;
- }
-
- public static function &get_instance()
- {
- return self::$instance;
- }
-}
-
-function &get_instance()
-{
- return CI_Base::get_instance();
-}
-
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.3
+ * @filesource
+ */
+
+
+// ------------------------------------------------------------------------
+
+/**
+ * CI_BASE - For PHP 5
+ *
+ * This file contains some code used only when CodeIgniter is being
+ * run under PHP 5. It allows us to manage the CI super object more
+ * gracefully than what is possible with PHP 4.
+ *
+ * @package CodeIgniter
+ * @subpackage codeigniter
+ * @category front-controller
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/
+ */
+
+class CI_Base {
+
+ private static $instance;
+
+ public function CI_Base()
+ {
+ self::$instance =& $this;
+ }
+
+ public static function &get_instance()
+ {
+ return self::$instance;
+ }
+}
+
+function &get_instance()
+{
+ return CI_Base::get_instance();
+}
+
+
?> \ No newline at end of file
diff --git a/system/codeigniter/CodeIgniter.php b/system/codeigniter/CodeIgniter.php
index 12f1a0d5e..aed05ddc2 100644
--- a/system/codeigniter/CodeIgniter.php
+++ b/system/codeigniter/CodeIgniter.php
@@ -1,12 +1,12 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
- * Code Igniter
+ * CodeIgniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
* @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
* @license http://www.codeignitor.com/user_guide/license.html
* @link http://www.codeigniter.com
* @since Version 1.0
diff --git a/system/codeigniter/Common.php b/system/codeigniter/Common.php
index 4576cd964..36c9356a9 100644
--- a/system/codeigniter/Common.php
+++ b/system/codeigniter/Common.php
@@ -1,260 +1,260 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.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 Rick Ellis
- * @link http://www.codeigniter.com/user_guide/
- */
-
-// ------------------------------------------------------------------------
-
-/**
-* Class registry
-*
-* This function acts as a singleton. If the requested class does not
-* exist it is instantiated and set to a static variable. If it has
-* previously been instantiated the variable is returned.
-*
-* @access public
-* @param string the class name being requested
-* @param bool optional flag that lets classes get loaded but not instantiated
-* @return object
-*/
-function &load_class($class, $instantiate = TRUE)
-{
- static $objects = array();
-
- // Does the class exist? If so, we're done...
- if (isset($objects[$class]))
- {
- return $objects[$class];
- }
-
- // If the requested class does not exist in the application/libraries
- // folder we'll load the native class from the system/libraries folder.
- if (file_exists(APPPATH.'libraries/'.config_item('subclass_prefix').$class.EXT))
- {
- require(BASEPATH.'libraries/'.$class.EXT);
- require(APPPATH.'libraries/'.config_item('subclass_prefix').$class.EXT);
- $is_subclass = TRUE;
- }
- else
- {
- if (file_exists(APPPATH.'libraries/'.$class.EXT))
- {
- require(APPPATH.'libraries/'.$class.EXT);
- $is_subclass = FALSE;
- }
- else
- {
- require(BASEPATH.'libraries/'.$class.EXT);
- $is_subclass = FALSE;
- }
- }
-
- if ($instantiate == FALSE)
- {
- $objects[$class] = TRUE;
- return $objects[$class];
- }
-
- if ($is_subclass == TRUE)
- {
- $name = config_item('subclass_prefix').$class;
- $objects[$class] =& new $name();
- return $objects[$class];
- }
-
- $name = ($class != 'Controller') ? 'CI_'.$class : $class;
-
- $objects[$class] =& new $name();
- return $objects[$class];
-}
-
-/**
-* Loads the main config.php file
-*
-* @access private
-* @return array
-*/
-function &get_config()
-{
- static $main_conf;
-
- if ( ! isset($main_conf))
- {
- if ( ! file_exists(APPPATH.'config/config'.EXT))
- {
- exit('The configuration file config'.EXT.' does not exist.');
- }
-
- require(APPPATH.'config/config'.EXT);
-
- if ( ! isset($config) OR ! is_array($config))
- {
- exit('Your config file does not appear to be formatted correctly.');
- }
-
- $main_conf[0] =& $config;
- }
- return $main_conf[0];
-}
-
-/**
-* Gets a config item
-*
-* @access public
-* @return mixed
-*/
-function config_item($item)
-{
- static $config_item = array();
-
- if ( ! isset($config_item[$item]))
- {
- $config =& get_config();
-
- if ( ! isset($config[$item]))
- {
- return FALSE;
- }
- $config_item[$item] = $config[$item];
- }
-
- return $config_item[$item];
-}
-
-
-/**
-* Error Handler
-*
-* This function lets us invoke the exception class and
-* display errors using the standard error template located
-* in application/errors/errors.php
-* This function will send the error page directly to the
-* browser and exit.
-*
-* @access public
-* @return void
-*/
-function show_error($message)
-{
- $error =& load_class('Exceptions');
- echo $error->show_error('An Error Was Encountered', $message);
- exit;
-}
-
-
-/**
-* 404 Page Handler
-*
-* This function is similar to the show_error() function above
-* However, instead of the standard error template it displays
-* 404 errors.
-*
-* @access public
-* @return void
-*/
-function show_404($page = '')
-{
- $error =& load_class('Exceptions');
- $error->show_404($page);
- exit;
-}
-
-
-/**
-* Error Logging Interface
-*
-* We use this as a simple mechanism to access the logging
-* class and send messages to be logged.
-*
-* @access public
-* @return void
-*/
-function log_message($level = 'error', $message, $php_error = FALSE)
-{
- static $LOG;
-
- $config =& get_config();
- if ($config['log_threshold'] == 0)
- {
- return;
- }
-
- $LOG =& load_class('Log');
- $LOG->write_log($level, $message, $php_error);
-}
-
-/**
-* Exception Handler
-*
-* This is the custom exception handler that is declaired at the top
-* of Codeigniter.php. The main reason we use this is permit
-* PHP errors to be logged in our own log files since we may
-* not have access to server logs. Since this function
-* effectively intercepts PHP errors, however, we also need
-* to display errors based on the current error_reporting level.
-* We do that with the use of a PHP error template.
-*
-* @access private
-* @return void
-*/
-function _exception_handler($severity, $message, $filepath, $line)
-{
- // We don't bother with "strict" notices since they will fill up
- // the log file with information that isn't normally very
- // helpful. For example, if you are running PHP 5 and you
- // use version 4 style class functions (without prefixes
- // like "public", "private", etc.) you'll get notices telling
- // you that these have been deprecated.
-
- if ($severity == E_STRICT)
- {
- return;
- }
-
- $error =& load_class('Exceptions');
-
- // Should we display the error?
- // We'll get the current error_reporting level and add its bits
- // with the severity bits to find out.
-
- if (($severity & error_reporting()) == $severity)
- {
- $error->show_php_error($severity, $message, $filepath, $line);
- }
-
- // Should we log the error? No? We're done...
- $config =& get_config();
- if ($config['log_threshold'] == 0)
- {
- return;
- }
-
- $error->log_exception($severity, $message, $filepath, $line);
-}
-
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.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 Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+* Class registry
+*
+* This function acts as a singleton. If the requested class does not
+* exist it is instantiated and set to a static variable. If it has
+* previously been instantiated the variable is returned.
+*
+* @access public
+* @param string the class name being requested
+* @param bool optional flag that lets classes get loaded but not instantiated
+* @return object
+*/
+function &load_class($class, $instantiate = TRUE)
+{
+ static $objects = array();
+
+ // Does the class exist? If so, we're done...
+ if (isset($objects[$class]))
+ {
+ return $objects[$class];
+ }
+
+ // If the requested class does not exist in the application/libraries
+ // folder we'll load the native class from the system/libraries folder.
+ if (file_exists(APPPATH.'libraries/'.config_item('subclass_prefix').$class.EXT))
+ {
+ require(BASEPATH.'libraries/'.$class.EXT);
+ require(APPPATH.'libraries/'.config_item('subclass_prefix').$class.EXT);
+ $is_subclass = TRUE;
+ }
+ else
+ {
+ if (file_exists(APPPATH.'libraries/'.$class.EXT))
+ {
+ require(APPPATH.'libraries/'.$class.EXT);
+ $is_subclass = FALSE;
+ }
+ else
+ {
+ require(BASEPATH.'libraries/'.$class.EXT);
+ $is_subclass = FALSE;
+ }
+ }
+
+ if ($instantiate == FALSE)
+ {
+ $objects[$class] = TRUE;
+ return $objects[$class];
+ }
+
+ if ($is_subclass == TRUE)
+ {
+ $name = config_item('subclass_prefix').$class;
+ $objects[$class] =& new $name();
+ return $objects[$class];
+ }
+
+ $name = ($class != 'Controller') ? 'CI_'.$class : $class;
+
+ $objects[$class] =& new $name();
+ return $objects[$class];
+}
+
+/**
+* Loads the main config.php file
+*
+* @access private
+* @return array
+*/
+function &get_config()
+{
+ static $main_conf;
+
+ if ( ! isset($main_conf))
+ {
+ if ( ! file_exists(APPPATH.'config/config'.EXT))
+ {
+ exit('The configuration file config'.EXT.' does not exist.');
+ }
+
+ require(APPPATH.'config/config'.EXT);
+
+ if ( ! isset($config) OR ! is_array($config))
+ {
+ exit('Your config file does not appear to be formatted correctly.');
+ }
+
+ $main_conf[0] =& $config;
+ }
+ return $main_conf[0];
+}
+
+/**
+* Gets a config item
+*
+* @access public
+* @return mixed
+*/
+function config_item($item)
+{
+ static $config_item = array();
+
+ if ( ! isset($config_item[$item]))
+ {
+ $config =& get_config();
+
+ if ( ! isset($config[$item]))
+ {
+ return FALSE;
+ }
+ $config_item[$item] = $config[$item];
+ }
+
+ return $config_item[$item];
+}
+
+
+/**
+* Error Handler
+*
+* This function lets us invoke the exception class and
+* display errors using the standard error template located
+* in application/errors/errors.php
+* This function will send the error page directly to the
+* browser and exit.
+*
+* @access public
+* @return void
+*/
+function show_error($message)
+{
+ $error =& load_class('Exceptions');
+ echo $error->show_error('An Error Was Encountered', $message);
+ exit;
+}
+
+
+/**
+* 404 Page Handler
+*
+* This function is similar to the show_error() function above
+* However, instead of the standard error template it displays
+* 404 errors.
+*
+* @access public
+* @return void
+*/
+function show_404($page = '')
+{
+ $error =& load_class('Exceptions');
+ $error->show_404($page);
+ exit;
+}
+
+
+/**
+* Error Logging Interface
+*
+* We use this as a simple mechanism to access the logging
+* class and send messages to be logged.
+*
+* @access public
+* @return void
+*/
+function log_message($level = 'error', $message, $php_error = FALSE)
+{
+ static $LOG;
+
+ $config =& get_config();
+ if ($config['log_threshold'] == 0)
+ {
+ return;
+ }
+
+ $LOG =& load_class('Log');
+ $LOG->write_log($level, $message, $php_error);
+}
+
+/**
+* Exception Handler
+*
+* This is the custom exception handler that is declaired at the top
+* of Codeigniter.php. The main reason we use this is permit
+* PHP errors to be logged in our own log files since we may
+* not have access to server logs. Since this function
+* effectively intercepts PHP errors, however, we also need
+* to display errors based on the current error_reporting level.
+* We do that with the use of a PHP error template.
+*
+* @access private
+* @return void
+*/
+function _exception_handler($severity, $message, $filepath, $line)
+{
+ // We don't bother with "strict" notices since they will fill up
+ // the log file with information that isn't normally very
+ // helpful. For example, if you are running PHP 5 and you
+ // use version 4 style class functions (without prefixes
+ // like "public", "private", etc.) you'll get notices telling
+ // you that these have been deprecated.
+
+ if ($severity == E_STRICT)
+ {
+ return;
+ }
+
+ $error =& load_class('Exceptions');
+
+ // Should we display the error?
+ // We'll get the current error_reporting level and add its bits
+ // with the severity bits to find out.
+
+ if (($severity & error_reporting()) == $severity)
+ {
+ $error->show_php_error($severity, $message, $filepath, $line);
+ }
+
+ // Should we log the error? No? We're done...
+ $config =& get_config();
+ if ($config['log_threshold'] == 0)
+ {
+ return;
+ }
+
+ $error->log_exception($severity, $message, $filepath, $line);
+}
+
+
?> \ No newline at end of file
diff --git a/system/database/DB.php b/system/database/DB.php
index c6bd365d9..4a119d042 100644
--- a/system/database/DB.php
+++ b/system/database/DB.php
@@ -1,86 +1,86 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Initialize the database
- *
- * @category Database
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/database/
- */
-function &DB($params = '', $active_record = FALSE)
-{
- // Load the DB config file if a DSN string wasn't passed
- if (is_string($params) AND strpos($params, '://') === FALSE)
- {
- include(APPPATH.'config/database'.EXT);
-
- $group = ($params == '') ? $active_group : $params;
-
- if ( ! isset($db[$group]))
- {
- show_error('You have specified an invalid database connection group: '.$group);
- }
-
- $params = $db[$group];
- }
-
- // 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 == TRUE)
- {
- $params['active_r'] = TRUE;
- }
-
- require_once(BASEPATH.'database/DB_driver'.EXT);
-
- if ( ! isset($params['active_r']) OR $params['active_r'] == 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);
- return $DB;
-}
-
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Initialize the database
+ *
+ * @category Database
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/database/
+ */
+function &DB($params = '', $active_record = FALSE)
+{
+ // Load the DB config file if a DSN string wasn't passed
+ if (is_string($params) AND strpos($params, '://') === FALSE)
+ {
+ include(APPPATH.'config/database'.EXT);
+
+ $group = ($params == '') ? $active_group : $params;
+
+ if ( ! isset($db[$group]))
+ {
+ show_error('You have specified an invalid database connection group: '.$group);
+ }
+
+ $params = $db[$group];
+ }
+
+ // 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 == TRUE)
+ {
+ $params['active_r'] = TRUE;
+ }
+
+ require_once(BASEPATH.'database/DB_driver'.EXT);
+
+ if ( ! isset($params['active_r']) OR $params['active_r'] == 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);
+ return $DB;
+}
+
+
?> \ No newline at end of file
diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php
index 1c72528e5..d79a068e3 100644
--- a/system/database/DB_active_rec.php
+++ b/system/database/DB_active_rec.php
@@ -1,12 +1,12 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
- * Code Igniter
+ * CodeIgniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
* @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
* @license http://www.codeignitor.com/user_guide/license.html
* @link http://www.codeigniter.com
* @since Version 1.0
diff --git a/system/database/DB_cache.php b/system/database/DB_cache.php
index 53425d1d9..33f408fb4 100644
--- a/system/database/DB_cache.php
+++ b/system/database/DB_cache.php
@@ -1,194 +1,194 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Database Cache Class
- *
- * @category Database
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/database/
- */
-class CI_DB_Cache {
-
- var $CI;
-
- /**
- * Constructor
- *
- * Grabs the CI super object instance so we can access it.
- *
- */
- function CI_DB_Cache()
- {
- // Assign the main CI object to $this->CI
- // and load the file helper since we use it a lot
- $this->CI =& get_instance();
- $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->CI->db->cachedir == '')
- {
- return $this->CI->db->cache_off();
- }
-
- $path = $this->CI->db->cachedir;
- }
-
- // Add a trailing slash to the path if needed
- $path = preg_replace("/(.+?)\/*$/", "\\1/", $path);
-
- if ( ! is_dir($path) OR ! is_writable($path))
- {
- if ($this->CI->db->db_debug)
- {
- return $this->CI->db->display_error('db_invalid_cache_path');
- }
-
- // If the path is wrong we'll turn off caching
- return $this->CI->db->cache_off();
- }
-
- $this->CI->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->CI->db->cache_off();
- }
-
- $uri = ($this->CI->uri->segment(1) == FALSE) ? 'default.' : $this->CI->uri->segment(1).'+';
- $uri .= ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2);
-
- $filepath = $uri.'/'.md5($sql);
-
- if (FALSE === ($cachedata = read_file($this->CI->db->cachedir.$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->CI->db->cache_off();
- }
-
- $uri = ($this->CI->uri->segment(1) == FALSE) ? 'default.' : $this->CI->uri->segment(1).'+';
- $uri .= ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2);
-
- $dir_path = $this->CI->db->cachedir.$uri.'/';
-
- $filename = md5($sql);
-
- if ( ! @is_dir($dir_path))
- {
- if ( ! @mkdir($dir_path, 0777))
- {
- return FALSE;
- }
-
- @chmod($dir_path, 0777);
- }
-
- if (write_file($dir_path.$filename, serialize($object)) === FALSE)
- {
- return FALSE;
- }
-
- @chmod($dir_path.$filename, 0777);
- 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(2);
- }
-
- if ($segment_two == '')
- {
- $segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2);
- }
-
- $dir_path = $this->CI->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->CI->db->cachedir, TRUE);
- }
-
-}
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Database Cache Class
+ *
+ * @category Database
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/database/
+ */
+class CI_DB_Cache {
+
+ var $CI;
+
+ /**
+ * Constructor
+ *
+ * Grabs the CI super object instance so we can access it.
+ *
+ */
+ function CI_DB_Cache()
+ {
+ // Assign the main CI object to $this->CI
+ // and load the file helper since we use it a lot
+ $this->CI =& get_instance();
+ $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->CI->db->cachedir == '')
+ {
+ return $this->CI->db->cache_off();
+ }
+
+ $path = $this->CI->db->cachedir;
+ }
+
+ // Add a trailing slash to the path if needed
+ $path = preg_replace("/(.+?)\/*$/", "\\1/", $path);
+
+ if ( ! is_dir($path) OR ! is_writable($path))
+ {
+ if ($this->CI->db->db_debug)
+ {
+ return $this->CI->db->display_error('db_invalid_cache_path');
+ }
+
+ // If the path is wrong we'll turn off caching
+ return $this->CI->db->cache_off();
+ }
+
+ $this->CI->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->CI->db->cache_off();
+ }
+
+ $uri = ($this->CI->uri->segment(1) == FALSE) ? 'default.' : $this->CI->uri->segment(1).'+';
+ $uri .= ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2);
+
+ $filepath = $uri.'/'.md5($sql);
+
+ if (FALSE === ($cachedata = read_file($this->CI->db->cachedir.$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->CI->db->cache_off();
+ }
+
+ $uri = ($this->CI->uri->segment(1) == FALSE) ? 'default.' : $this->CI->uri->segment(1).'+';
+ $uri .= ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2);
+
+ $dir_path = $this->CI->db->cachedir.$uri.'/';
+
+ $filename = md5($sql);
+
+ if ( ! @is_dir($dir_path))
+ {
+ if ( ! @mkdir($dir_path, 0777))
+ {
+ return FALSE;
+ }
+
+ @chmod($dir_path, 0777);
+ }
+
+ if (write_file($dir_path.$filename, serialize($object)) === FALSE)
+ {
+ return FALSE;
+ }
+
+ @chmod($dir_path.$filename, 0777);
+ 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(2);
+ }
+
+ if ($segment_two == '')
+ {
+ $segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2);
+ }
+
+ $dir_path = $this->CI->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->CI->db->cachedir, TRUE);
+ }
+
+}
+
?> \ No newline at end of file
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index 2a8510e13..7ff33246a 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -1,1067 +1,1067 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Database Driver Class
- *
- * This is the platform-independent base DB implementation class.
- * This class will not be called directly. Rather, the adapter
- * class for the specific database will extend and instantiate it.
- *
- * @package CodeIgniter
- * @subpackage Drivers
- * @category Database
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/database/
- */
-class CI_DB_driver {
-
- var $username;
- var $password;
- var $hostname;
- var $database;
- var $dbdriver = 'mysql';
- var $dbprefix = '';
- var $port = '';
- var $pconnect = FALSE;
- var $conn_id = FALSE;
- var $result_id = FALSE;
- var $db_debug = FALSE;
- var $benchmark = 0;
- var $query_count = 0;
- var $bind_marker = '?';
- var $queries = array();
- var $data_cache = array();
- var $trans_enabled = TRUE;
- var $_trans_depth = 0;
- var $_trans_failure = FALSE; // Used with transactions to determine if a rollback should occur
- var $cache_on = FALSE;
- var $cachedir = '';
- var $cache_autodel = FALSE;
- var $CACHE; // The cache class object
-
-
- // These are use with Oracle
- var $stmt_id;
- var $curs_id;
- var $limit_used;
-
-
-
- /**
- * Constructor. Accepts one parameter containing the database
- * connection settings.
- *
- * 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';
- *
- * @param mixed. Can be an array or a DSN string
- */
- function CI_DB_driver($params)
- {
- $this->initialize($params);
- log_message('debug', 'Database Driver Class Initialized');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Initialize Database Settings
- *
- * @access private Called by the constructor
- * @param mixed
- * @return void
- */
- function initialize($params = '')
- {
- if (is_array($params))
- {
- $defaults = array(
- 'hostname' => '',
- 'username' => '',
- 'password' => '',
- 'database' => '',
- 'conn_id' => FALSE,
- 'dbdriver' => 'mysql',
- 'dbprefix' => '',
- 'port' => '',
- 'pconnect' => FALSE,
- 'db_debug' => FALSE,
- 'cachedir' => '',
- 'cache_on' => FALSE
- );
-
- foreach ($defaults as $key => $val)
- {
- $this->$key = ( ! isset($params[$key])) ? $val : $params[$key];
- }
- }
- elseif (strpos($params, '://'))
- {
- if (FALSE === ($dsn = @parse_url($params)))
- {
- log_message('error', 'Invalid DB Connection String');
-
- if ($this->db_debug)
- {
- return $this->display_error('db_invalid_connection_str');
- }
- return FALSE;
- }
-
- $this->hostname = ( ! isset($dsn['host'])) ? '' : rawurldecode($dsn['host']);
- $this->username = ( ! isset($dsn['user'])) ? '' : rawurldecode($dsn['user']);
- $this->password = ( ! isset($dsn['pass'])) ? '' : rawurldecode($dsn['pass']);
- $this->database = ( ! isset($dsn['path'])) ? '' : rawurldecode(substr($dsn['path'], 1));
- }
-
- // If an existing DB connection resource is supplied
- // there is no need to connect and select the database
- if (is_resource($this->conn_id))
- {
- return TRUE;
- }
-
- // Connect to the database
- $this->conn_id = ($this->pconnect == FALSE) ? $this->db_connect() : $this->db_pconnect();
-
- // No connection? Throw an error
- if ( ! $this->conn_id)
- {
- log_message('error', 'Unable to connect to the database');
-
- if ($this->db_debug)
- {
- $this->display_error('db_unable_to_connect');
- }
- return FALSE;
- }
-
- // Select the database
- if ($this->database != '')
- {
- if ( ! $this->db_select())
- {
- log_message('error', 'Unable to select database: '.$this->database);
-
- if ($this->db_debug)
- {
- $this->display_error('db_unable_to_select', $this->database);
- }
- return FALSE;
- }
- }
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * The name of the platform in use (mysql, mssql, etc...)
- *
- * @access public
- * @return string
- */
- function platform()
- {
- return $this->dbdriver;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Database Version Number. Returns a string containing the
- * version of the database being used
- *
- * @access public
- * @return string
- */
- function version()
- {
- if (FALSE === ($sql = $this->_version()))
- {
- if ($this->db_debug)
- {
- return $this->display_error('db_unsupported_function');
- }
- return FALSE;
- }
-
- if ($this->dbdriver == 'oci8')
- {
- return $sql;
- }
-
- $query = $this->query($sql);
- $row = $query->row();
- return $row->ver;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Execute the query
- *
- * Accepts an SQL string as input and returns a result object upon
- * successful execution of a "read" type query. Returns boolean TRUE
- * upon successful execution of a "write" type query. Returns boolean
- * FALSE upon failure, and if the $db_debug variable is set to TRUE
- * will raise an error.
- *
- * @access public
- * @param string An SQL query string
- * @param array An array of binding data
- * @return mixed
- */
- function query($sql, $binds = FALSE, $return_object = TRUE)
- {
- if ($sql == '')
- {
- if ($this->db_debug)
- {
- log_message('error', 'Invalid query: '.$sql);
- return $this->display_error('db_invalid_query');
- }
- return FALSE;
- }
-
- // Is query caching enabled? If the query is a "read type"
- // we will load the caching class and return the previously
- // cached query if it exists
- if ($this->cache_on == TRUE AND stristr($sql, 'SELECT'))
- {
- if ($this->_cache_init())
- {
- $this->load_rdriver();
- if (FALSE !== ($cache = $this->CACHE->read($sql)))
- {
- return $cache;
- }
- }
- }
-
- // Compile binds if needed
- if ($binds !== FALSE)
- {
- $sql = $this->compile_binds($sql, $binds);
- }
-
- // Save the query for debugging
- $this->queries[] = $sql;
-
- // Start the Query Timer
- $time_start = list($sm, $ss) = explode(' ', microtime());
-
- // Run the Query
- if (FALSE === ($this->result_id = $this->simple_query($sql)))
- {
- // This will trigger a rollback if transactions are being used
- $this->_trans_failure = TRUE;
-
- if ($this->db_debug)
- {
- log_message('error', 'Query error: '.$this->_error_message());
- return $this->display_error(
- array(
- 'Error Number: '.$this->_error_number(),
- $this->_error_message(),
- $sql
- )
- );
- }
-
- return FALSE;
- }
-
- // Stop and aggregate the query time results
- $time_end = list($em, $es) = explode(' ', microtime());
- $this->benchmark += ($em + $es) - ($sm + $ss);
-
- // Increment the query counter
- $this->query_count++;
-
- // Was the query a "write" type?
- // If so we'll simply return true
- if ($this->is_write_type($sql) === TRUE)
- {
- // If caching is enabled we'll auto-cleanup any
- // existing files related to this particular URI
- if ($this->cache_on == TRUE AND $this->cache_autodel == TRUE AND $this->_cache_init())
- {
- $this->CACHE->delete();
- }
-
- return TRUE;
- }
-
- // Return TRUE if we don't need to create a result object
- // Currently only the Oracle driver uses this when stored
- // procedures are used
- if ($return_object !== TRUE)
- {
- return TRUE;
- }
-
- // Load and instantiate the result driver
-
- $driver = $this->load_rdriver();
- $RES = new $driver();
- $RES->conn_id = $this->conn_id;
- $RES->result_id = $this->result_id;
-
- if ($this->dbdriver == 'oci8')
- {
- $RES->stmt_id = $this->stmt_id;
- $RES->curs_id = NULL;
- $RES->limit_used = $this->limit_used;
- }
-
- // Is query caching enabled? If so, we'll serialize the
- // result object and save it to a cache file.
- if ($this->cache_on == TRUE AND $this->_cache_init())
- {
- // We'll create a new instance of the result object
- // only without the platform specific driver since
- // we can't use it with cached data (the query result
- // resource ID won't be any good once we've cached the
- // result object, so we'll have to compile the data
- // and save it)
- $CR = new CI_DB_result();
- $CR->num_rows = $RES->num_rows();
- $CR->result_object = $RES->result_object();
- $CR->result_array = $RES->result_array();
-
- // Reset these since cached objects can not utilize resource IDs.
- $CR->conn_id = NULL;
- $CR->result_id = NULL;
-
- $this->CACHE->write($sql, $CR);
- }
-
- return $RES;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Load the result drivers
- *
- * @access public
- * @return string the name of the result class
- */
- function load_rdriver()
- {
- $driver = 'CI_DB_'.$this->dbdriver.'_result';
-
- if ( ! class_exists($driver))
- {
- include_once(BASEPATH.'database/DB_result'.EXT);
- include_once(BASEPATH.'database/drivers/'.$this->dbdriver.'/'.$this->dbdriver.'_result'.EXT);
- }
-
- return $driver;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Simple Query
- * This is a simplified version of the query() function. Internally
- * we only use it when running transaction commands since they do
- * not require all the features of the main query() function.
- *
- * @access public
- * @param string the sql query
- * @return mixed
- */
- function simple_query($sql)
- {
- if ( ! $this->conn_id)
- {
- $this->initialize();
- }
-
- return $this->_execute($sql);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Disable Transactions
- * This permits transactions to be disabled at run-time.
- *
- * @access public
- * @return void
- */
- function trans_off()
- {
- $this->trans_enabled = FALSE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Start Transaction
- *
- * @access public
- * @return void
- */
- function trans_start($test_mode = FALSE)
- {
- if ( ! $this->trans_enabled)
- {
- return FALSE;
- }
-
- // When transactions are nested we only begin/commit/rollback the outermost ones
- if ($this->_trans_depth > 0)
- {
- $this->_trans_depth += 1;
- return;
- }
-
- $this->trans_begin($test_mode);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Complete Transaction
- *
- * @access public
- * @return bool
- */
- function trans_complete()
- {
- if ( ! $this->trans_enabled)
- {
- return FALSE;
- }
-
- // When transactions are nested we only begin/commit/rollback the outermost ones
- if ($this->_trans_depth > 1)
- {
- $this->_trans_depth -= 1;
- return TRUE;
- }
-
- // The query() function will set this flag to TRUE in the event that a query failed
- if ($this->_trans_failure === TRUE)
- {
- $this->trans_rollback();
-
- if ($this->db_debug)
- {
- return $this->display_error('db_transaction_failure');
- }
- return FALSE;
- }
-
- $this->trans_commit();
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Lets you retrieve the transaction flag to determine if it has failed
- *
- * @access public
- * @return bool
- */
- function trans_status()
- {
- return $this->_trans_failure;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Compile Bindings
- *
- * @access public
- * @param string the sql statement
- * @param array an array of bind data
- * @return string
- */
- function compile_binds($sql, $binds)
- {
- if (FALSE === strpos($sql, $this->bind_marker))
- {
- return $sql;
- }
-
- if ( ! is_array($binds))
- {
- $binds = array($binds);
- }
-
- foreach ($binds as $val)
- {
- $val = $this->escape($val);
-
- // Just in case the replacement string contains the bind
- // character we'll temporarily replace it with a marker
- $val = str_replace($this->bind_marker, '{%bind_marker%}', $val);
- $sql = preg_replace("#".preg_quote($this->bind_marker, '#')."#", str_replace('$', '\$', $val), $sql, 1);
- }
-
- return str_replace('{%bind_marker%}', $this->bind_marker, $sql);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Determines if a query is a "write" type.
- *
- * @access public
- * @param string An SQL query string
- * @return boolean
- */
- function is_write_type($sql)
- {
- if ( ! preg_match('/^\s*"?(INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|LOAD DATA|COPY|ALTER|GRANT|REVOKE|LOCK|UNLOCK)\s+/i', $sql))
- {
- return FALSE;
- }
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Calculate the aggregate query elapsed time
- *
- * @access public
- * @param integer The number of decimal places
- * @return integer
- */
- function elapsed_time($decimals = 6)
- {
- return number_format($this->benchmark, $decimals);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Returns the total number of queries
- *
- * @access public
- * @return integer
- */
- function total_queries()
- {
- return $this->query_count;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Returns the last query that was executed
- *
- * @access public
- * @return void
- */
- function last_query()
- {
- return end($this->queries);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * "Smart" Escape String
- *
- * Escapes data based on type
- * Sets boolean and null types
- *
- * @access public
- * @param string
- * @return integer
- */
- function escape($str)
- {
- switch (gettype($str))
- {
- case 'string' : $str = "'".$this->escape_str($str)."'";
- break;
- case 'boolean' : $str = ($str === FALSE) ? 0 : 1;
- break;
- default : $str = ($str === NULL) ? 'NULL' : $str;
- break;
- }
-
- return $str;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Primary
- *
- * Retrieves the primary key. It assumes that the row in the first
- * position is the primary key
- *
- * @access public
- * @param string the table name
- * @return string
- */
- function primary($table = '')
- {
- $fields = $this->list_fields($table);
-
- if ( ! is_array($fields))
- {
- return FALSE;
- }
-
- return current($fields);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Returns an array of table names
- *
- * @access public
- * @return array
- */
- function list_tables()
- {
- // Is there a cached result?
- if (isset($this->data_cache['table_names']))
- {
- return $this->data_cache['table_names'];
- }
-
- if (FALSE === ($sql = $this->_list_tables()))
- {
- if ($this->db_debug)
- {
- return $this->display_error('db_unsupported_function');
- }
- return FALSE;
- }
-
- $retval = array();
- $query = $this->query($sql);
-
- if ($query->num_rows() > 0)
- {
- foreach($query->result_array() as $row)
- {
- if (isset($row['TABLE_NAME']))
- {
- $retval[] = $row['TABLE_NAME'];
- }
- else
- {
- $retval[] = array_shift($row);
- }
- }
- }
-
- $this->data_cache['table_names'] = $retval;
- return $this->data_cache['table_names'];
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Determine if a particular table exists
- * @access public
- * @return boolean
- */
- function table_exists($table_name)
- {
- return ( ! in_array($this->dbprefix.$table_name, $this->list_tables())) ? FALSE : TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Fetch MySQL Field Names
- *
- * @access public
- * @param string the table name
- * @return array
- */
- function list_fields($table = '')
- {
- // Is there a cached result?
- if (isset($this->data_cache['field_names'][$table]))
- {
- return $this->data_cache['field_names'][$table];
- }
-
- if ($table == '')
- {
- if ($this->db_debug)
- {
- return $this->display_error('db_field_param_missing');
- }
- return FALSE;
- }
-
- if (FALSE === ($sql = $this->_list_columns($this->dbprefix.$table)))
- {
- if ($this->db_debug)
- {
- return $this->display_error('db_unsupported_function');
- }
- return FALSE;
- }
-
- $query = $this->query($sql);
-
- $retval = array();
- foreach($query->result_array() as $row)
- {
- if (isset($row['COLUMN_NAME']))
- {
- $retval[] = $row['COLUMN_NAME'];
- }
- else
- {
- $retval[] = current($row);
- }
- }
-
- $this->data_cache['field_names'][$table] = $retval;
- return $this->data_cache['field_names'][$table];
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Determine if a particular field exists
- * @access public
- * @param string
- * @param string
- * @return boolean
- */
- function field_exists($field_name, $table_name)
- {
- return ( ! in_array($field_name, $this->list_fields($table_name))) ? FALSE : TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * DEPRECATED - use list_fields()
- */
- function field_names($table = '')
- {
- return $this->list_fields($table);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Returns an object with field data
- *
- * @access public
- * @param string the table name
- * @return object
- */
- function field_data($table = '')
- {
- if ($table == '')
- {
- if ($this->db_debug)
- {
- return $this->display_error('db_field_param_missing');
- }
- return FALSE;
- }
-
- $query = $this->query($this->_field_data($this->dbprefix.$table));
- return $query->field_data();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Generate an insert string
- *
- * @access public
- * @param string the table upon which the query will be performed
- * @param array an associative array data of key/values
- * @return string
- */
- function insert_string($table, $data)
- {
- $fields = array();
- $values = array();
-
- foreach($data as $key => $val)
- {
- $fields[] = $key;
- $values[] = $this->escape($val);
- }
-
- return $this->_insert($this->dbprefix.$table, $fields, $values);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Generate an update string
- *
- * @access public
- * @param string the table upon which the query will be performed
- * @param array an associative array data of key/values
- * @param mixed the "where" statement
- * @return string
- */
- function update_string($table, $data, $where)
- {
- if ($where == '')
- return false;
-
- $fields = array();
- foreach($data as $key => $val)
- {
- $fields[$key] = $this->escape($val);
- }
-
- if ( ! is_array($where))
- {
- $dest = array($where);
- }
- else
- {
- $dest = array();
- foreach ($where as $key => $val)
- {
- $prefix = (count($dest) == 0) ? '' : ' AND ';
-
- if ($val != '')
- {
- if ( ! $this->_has_operator($key))
- {
- $key .= ' =';
- }
-
- $val = ' '.$this->escape($val);
- }
-
- $dest[] = $prefix.$key.$val;
- }
- }
-
- return $this->_update($this->dbprefix.$table, $fields, $dest);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Enables a native PHP function to be run, using a platform agnostic wrapper.
- *
- * @access public
- * @param string the function name
- * @param mixed any parameters needed by the function
- * @return mixed
- */
- function call_function($function)
- {
- $driver = ($this->dbdriver == 'postgre') ? 'pg_' : $this->dbdriver.'_';
-
- if (FALSE === strpos($driver, $function))
- {
- $function = $driver.$function;
- }
-
- if ( ! function_exists($function))
- {
- if ($this->db_debug)
- {
- return $this->display_error('db_unsupported_function');
- }
- return FALSE;
- }
- else
- {
- $args = (func_num_args() > 1) ? array_splice(func_get_args(), 1) : null;
-
- return call_user_func_array($function, $args);
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Cache Directory Path
- *
- * @access public
- * @param string the path to the cache directory
- * @return void
- */
- function cache_set_path($path = '')
- {
- $this->cachedir = $path;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Enable Query Caching
- *
- * @access public
- * @return void
- */
- function cache_on()
- {
- $this->cache_on = TRUE;
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Disable Query Caching
- *
- * @access public
- * @return void
- */
- function cache_off()
- {
- $this->cache_on = FALSE;
- return FALSE;
- }
-
-
- // --------------------------------------------------------------------
-
- /**
- * Delete the cache files associated with a particular URI
- *
- * @access public
- * @return void
- */
- function cache_delete($segment_one = '', $segment_two = '')
- {
- if ( ! $this->_cache_init())
- {
- return FALSE;
- }
- return $this->CACHE->delete($segment_one, $segment_two);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Delete All cache files
- *
- * @access public
- * @return void
- */
- function cache_delete_all()
- {
- if ( ! $this->_cache_init())
- {
- return FALSE;
- }
-
- return $this->CACHE->delete_all();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Initialize the Cache Class
- *
- * @access private
- * @return void
- */
- function _cache_init()
- {
- if (is_object($this->CACHE) AND class_exists('CI_DB_Cache'))
- {
- return TRUE;
- }
-
- if ( ! @include(BASEPATH.'database/DB_cache'.EXT))
- {
- return $this->cache_off();
- }
-
- $this->CACHE = new CI_DB_Cache;
- return TRUE;
- }
-
-
- // --------------------------------------------------------------------
-
- /**
- * Close DB Connection
- *
- * @access public
- * @return void
- */
- function close()
- {
- if (is_resource($this->conn_id))
- {
- $this->_close($this->conn_id);
- }
- $this->conn_id = FALSE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Display an error message
- *
- * @access public
- * @param string the error message
- * @param string any "swap" values
- * @param boolean whether to localize the message
- * @return string sends the application/error_db.php template
- */
- function display_error($error = '', $swap = '', $native = FALSE)
- {
- $LANG = new CI_Language();
- $LANG->load('db');
-
- $heading = 'MySQL Error';
-
- if ($native == TRUE)
- {
- $message = $error;
- }
- else
- {
- $message = ( ! is_array($error)) ? array(str_replace('%s', $swap, $LANG->line($error))) : $error;
- }
-
- if ( ! class_exists('CI_Exceptions'))
- {
- include(BASEPATH.'libraries/Exceptions'.EXT);
- }
-
- $error = new CI_Exceptions();
- echo $error->show_error('An Error Was Encountered', $message, 'error_db');
- exit;
- }
-
-}
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Database Driver Class
+ *
+ * This is the platform-independent base DB implementation class.
+ * This class will not be called directly. Rather, the adapter
+ * class for the specific database will extend and instantiate it.
+ *
+ * @package CodeIgniter
+ * @subpackage Drivers
+ * @category Database
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/database/
+ */
+class CI_DB_driver {
+
+ var $username;
+ var $password;
+ var $hostname;
+ var $database;
+ var $dbdriver = 'mysql';
+ var $dbprefix = '';
+ var $port = '';
+ var $pconnect = FALSE;
+ var $conn_id = FALSE;
+ var $result_id = FALSE;
+ var $db_debug = FALSE;
+ var $benchmark = 0;
+ var $query_count = 0;
+ var $bind_marker = '?';
+ var $queries = array();
+ var $data_cache = array();
+ var $trans_enabled = TRUE;
+ var $_trans_depth = 0;
+ var $_trans_failure = FALSE; // Used with transactions to determine if a rollback should occur
+ var $cache_on = FALSE;
+ var $cachedir = '';
+ var $cache_autodel = FALSE;
+ var $CACHE; // The cache class object
+
+
+ // These are use with Oracle
+ var $stmt_id;
+ var $curs_id;
+ var $limit_used;
+
+
+
+ /**
+ * Constructor. Accepts one parameter containing the database
+ * connection settings.
+ *
+ * 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';
+ *
+ * @param mixed. Can be an array or a DSN string
+ */
+ function CI_DB_driver($params)
+ {
+ $this->initialize($params);
+ log_message('debug', 'Database Driver Class Initialized');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Initialize Database Settings
+ *
+ * @access private Called by the constructor
+ * @param mixed
+ * @return void
+ */
+ function initialize($params = '')
+ {
+ if (is_array($params))
+ {
+ $defaults = array(
+ 'hostname' => '',
+ 'username' => '',
+ 'password' => '',
+ 'database' => '',
+ 'conn_id' => FALSE,
+ 'dbdriver' => 'mysql',
+ 'dbprefix' => '',
+ 'port' => '',
+ 'pconnect' => FALSE,
+ 'db_debug' => FALSE,
+ 'cachedir' => '',
+ 'cache_on' => FALSE
+ );
+
+ foreach ($defaults as $key => $val)
+ {
+ $this->$key = ( ! isset($params[$key])) ? $val : $params[$key];
+ }
+ }
+ elseif (strpos($params, '://'))
+ {
+ if (FALSE === ($dsn = @parse_url($params)))
+ {
+ log_message('error', 'Invalid DB Connection String');
+
+ if ($this->db_debug)
+ {
+ return $this->display_error('db_invalid_connection_str');
+ }
+ return FALSE;
+ }
+
+ $this->hostname = ( ! isset($dsn['host'])) ? '' : rawurldecode($dsn['host']);
+ $this->username = ( ! isset($dsn['user'])) ? '' : rawurldecode($dsn['user']);
+ $this->password = ( ! isset($dsn['pass'])) ? '' : rawurldecode($dsn['pass']);
+ $this->database = ( ! isset($dsn['path'])) ? '' : rawurldecode(substr($dsn['path'], 1));
+ }
+
+ // If an existing DB connection resource is supplied
+ // there is no need to connect and select the database
+ if (is_resource($this->conn_id))
+ {
+ return TRUE;
+ }
+
+ // Connect to the database
+ $this->conn_id = ($this->pconnect == FALSE) ? $this->db_connect() : $this->db_pconnect();
+
+ // No connection? Throw an error
+ if ( ! $this->conn_id)
+ {
+ log_message('error', 'Unable to connect to the database');
+
+ if ($this->db_debug)
+ {
+ $this->display_error('db_unable_to_connect');
+ }
+ return FALSE;
+ }
+
+ // Select the database
+ if ($this->database != '')
+ {
+ if ( ! $this->db_select())
+ {
+ log_message('error', 'Unable to select database: '.$this->database);
+
+ if ($this->db_debug)
+ {
+ $this->display_error('db_unable_to_select', $this->database);
+ }
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * The name of the platform in use (mysql, mssql, etc...)
+ *
+ * @access public
+ * @return string
+ */
+ function platform()
+ {
+ return $this->dbdriver;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Database Version Number. Returns a string containing the
+ * version of the database being used
+ *
+ * @access public
+ * @return string
+ */
+ function version()
+ {
+ if (FALSE === ($sql = $this->_version()))
+ {
+ if ($this->db_debug)
+ {
+ return $this->display_error('db_unsupported_function');
+ }
+ return FALSE;
+ }
+
+ if ($this->dbdriver == 'oci8')
+ {
+ return $sql;
+ }
+
+ $query = $this->query($sql);
+ $row = $query->row();
+ return $row->ver;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Execute the query
+ *
+ * Accepts an SQL string as input and returns a result object upon
+ * successful execution of a "read" type query. Returns boolean TRUE
+ * upon successful execution of a "write" type query. Returns boolean
+ * FALSE upon failure, and if the $db_debug variable is set to TRUE
+ * will raise an error.
+ *
+ * @access public
+ * @param string An SQL query string
+ * @param array An array of binding data
+ * @return mixed
+ */
+ function query($sql, $binds = FALSE, $return_object = TRUE)
+ {
+ if ($sql == '')
+ {
+ if ($this->db_debug)
+ {
+ log_message('error', 'Invalid query: '.$sql);
+ return $this->display_error('db_invalid_query');
+ }
+ return FALSE;
+ }
+
+ // Is query caching enabled? If the query is a "read type"
+ // we will load the caching class and return the previously
+ // cached query if it exists
+ if ($this->cache_on == TRUE AND stristr($sql, 'SELECT'))
+ {
+ if ($this->_cache_init())
+ {
+ $this->load_rdriver();
+ if (FALSE !== ($cache = $this->CACHE->read($sql)))
+ {
+ return $cache;
+ }
+ }
+ }
+
+ // Compile binds if needed
+ if ($binds !== FALSE)
+ {
+ $sql = $this->compile_binds($sql, $binds);
+ }
+
+ // Save the query for debugging
+ $this->queries[] = $sql;
+
+ // Start the Query Timer
+ $time_start = list($sm, $ss) = explode(' ', microtime());
+
+ // Run the Query
+ if (FALSE === ($this->result_id = $this->simple_query($sql)))
+ {
+ // This will trigger a rollback if transactions are being used
+ $this->_trans_failure = TRUE;
+
+ if ($this->db_debug)
+ {
+ log_message('error', 'Query error: '.$this->_error_message());
+ return $this->display_error(
+ array(
+ 'Error Number: '.$this->_error_number(),
+ $this->_error_message(),
+ $sql
+ )
+ );
+ }
+
+ return FALSE;
+ }
+
+ // Stop and aggregate the query time results
+ $time_end = list($em, $es) = explode(' ', microtime());
+ $this->benchmark += ($em + $es) - ($sm + $ss);
+
+ // Increment the query counter
+ $this->query_count++;
+
+ // Was the query a "write" type?
+ // If so we'll simply return true
+ if ($this->is_write_type($sql) === TRUE)
+ {
+ // If caching is enabled we'll auto-cleanup any
+ // existing files related to this particular URI
+ if ($this->cache_on == TRUE AND $this->cache_autodel == TRUE AND $this->_cache_init())
+ {
+ $this->CACHE->delete();
+ }
+
+ return TRUE;
+ }
+
+ // Return TRUE if we don't need to create a result object
+ // Currently only the Oracle driver uses this when stored
+ // procedures are used
+ if ($return_object !== TRUE)
+ {
+ return TRUE;
+ }
+
+ // Load and instantiate the result driver
+
+ $driver = $this->load_rdriver();
+ $RES = new $driver();
+ $RES->conn_id = $this->conn_id;
+ $RES->result_id = $this->result_id;
+
+ if ($this->dbdriver == 'oci8')
+ {
+ $RES->stmt_id = $this->stmt_id;
+ $RES->curs_id = NULL;
+ $RES->limit_used = $this->limit_used;
+ }
+
+ // Is query caching enabled? If so, we'll serialize the
+ // result object and save it to a cache file.
+ if ($this->cache_on == TRUE AND $this->_cache_init())
+ {
+ // We'll create a new instance of the result object
+ // only without the platform specific driver since
+ // we can't use it with cached data (the query result
+ // resource ID won't be any good once we've cached the
+ // result object, so we'll have to compile the data
+ // and save it)
+ $CR = new CI_DB_result();
+ $CR->num_rows = $RES->num_rows();
+ $CR->result_object = $RES->result_object();
+ $CR->result_array = $RES->result_array();
+
+ // Reset these since cached objects can not utilize resource IDs.
+ $CR->conn_id = NULL;
+ $CR->result_id = NULL;
+
+ $this->CACHE->write($sql, $CR);
+ }
+
+ return $RES;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Load the result drivers
+ *
+ * @access public
+ * @return string the name of the result class
+ */
+ function load_rdriver()
+ {
+ $driver = 'CI_DB_'.$this->dbdriver.'_result';
+
+ if ( ! class_exists($driver))
+ {
+ include_once(BASEPATH.'database/DB_result'.EXT);
+ include_once(BASEPATH.'database/drivers/'.$this->dbdriver.'/'.$this->dbdriver.'_result'.EXT);
+ }
+
+ return $driver;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Simple Query
+ * This is a simplified version of the query() function. Internally
+ * we only use it when running transaction commands since they do
+ * not require all the features of the main query() function.
+ *
+ * @access public
+ * @param string the sql query
+ * @return mixed
+ */
+ function simple_query($sql)
+ {
+ if ( ! $this->conn_id)
+ {
+ $this->initialize();
+ }
+
+ return $this->_execute($sql);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Disable Transactions
+ * This permits transactions to be disabled at run-time.
+ *
+ * @access public
+ * @return void
+ */
+ function trans_off()
+ {
+ $this->trans_enabled = FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Start Transaction
+ *
+ * @access public
+ * @return void
+ */
+ function trans_start($test_mode = FALSE)
+ {
+ if ( ! $this->trans_enabled)
+ {
+ return FALSE;
+ }
+
+ // When transactions are nested we only begin/commit/rollback the outermost ones
+ if ($this->_trans_depth > 0)
+ {
+ $this->_trans_depth += 1;
+ return;
+ }
+
+ $this->trans_begin($test_mode);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Complete Transaction
+ *
+ * @access public
+ * @return bool
+ */
+ function trans_complete()
+ {
+ if ( ! $this->trans_enabled)
+ {
+ return FALSE;
+ }
+
+ // When transactions are nested we only begin/commit/rollback the outermost ones
+ if ($this->_trans_depth > 1)
+ {
+ $this->_trans_depth -= 1;
+ return TRUE;
+ }
+
+ // The query() function will set this flag to TRUE in the event that a query failed
+ if ($this->_trans_failure === TRUE)
+ {
+ $this->trans_rollback();
+
+ if ($this->db_debug)
+ {
+ return $this->display_error('db_transaction_failure');
+ }
+ return FALSE;
+ }
+
+ $this->trans_commit();
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Lets you retrieve the transaction flag to determine if it has failed
+ *
+ * @access public
+ * @return bool
+ */
+ function trans_status()
+ {
+ return $this->_trans_failure;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Compile Bindings
+ *
+ * @access public
+ * @param string the sql statement
+ * @param array an array of bind data
+ * @return string
+ */
+ function compile_binds($sql, $binds)
+ {
+ if (FALSE === strpos($sql, $this->bind_marker))
+ {
+ return $sql;
+ }
+
+ if ( ! is_array($binds))
+ {
+ $binds = array($binds);
+ }
+
+ foreach ($binds as $val)
+ {
+ $val = $this->escape($val);
+
+ // Just in case the replacement string contains the bind
+ // character we'll temporarily replace it with a marker
+ $val = str_replace($this->bind_marker, '{%bind_marker%}', $val);
+ $sql = preg_replace("#".preg_quote($this->bind_marker, '#')."#", str_replace('$', '\$', $val), $sql, 1);
+ }
+
+ return str_replace('{%bind_marker%}', $this->bind_marker, $sql);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Determines if a query is a "write" type.
+ *
+ * @access public
+ * @param string An SQL query string
+ * @return boolean
+ */
+ function is_write_type($sql)
+ {
+ if ( ! preg_match('/^\s*"?(INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|LOAD DATA|COPY|ALTER|GRANT|REVOKE|LOCK|UNLOCK)\s+/i', $sql))
+ {
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Calculate the aggregate query elapsed time
+ *
+ * @access public
+ * @param integer The number of decimal places
+ * @return integer
+ */
+ function elapsed_time($decimals = 6)
+ {
+ return number_format($this->benchmark, $decimals);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Returns the total number of queries
+ *
+ * @access public
+ * @return integer
+ */
+ function total_queries()
+ {
+ return $this->query_count;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Returns the last query that was executed
+ *
+ * @access public
+ * @return void
+ */
+ function last_query()
+ {
+ return end($this->queries);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * "Smart" Escape String
+ *
+ * Escapes data based on type
+ * Sets boolean and null types
+ *
+ * @access public
+ * @param string
+ * @return integer
+ */
+ function escape($str)
+ {
+ switch (gettype($str))
+ {
+ case 'string' : $str = "'".$this->escape_str($str)."'";
+ break;
+ case 'boolean' : $str = ($str === FALSE) ? 0 : 1;
+ break;
+ default : $str = ($str === NULL) ? 'NULL' : $str;
+ break;
+ }
+
+ return $str;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Primary
+ *
+ * Retrieves the primary key. It assumes that the row in the first
+ * position is the primary key
+ *
+ * @access public
+ * @param string the table name
+ * @return string
+ */
+ function primary($table = '')
+ {
+ $fields = $this->list_fields($table);
+
+ if ( ! is_array($fields))
+ {
+ return FALSE;
+ }
+
+ return current($fields);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Returns an array of table names
+ *
+ * @access public
+ * @return array
+ */
+ function list_tables()
+ {
+ // Is there a cached result?
+ if (isset($this->data_cache['table_names']))
+ {
+ return $this->data_cache['table_names'];
+ }
+
+ if (FALSE === ($sql = $this->_list_tables()))
+ {
+ if ($this->db_debug)
+ {
+ return $this->display_error('db_unsupported_function');
+ }
+ return FALSE;
+ }
+
+ $retval = array();
+ $query = $this->query($sql);
+
+ if ($query->num_rows() > 0)
+ {
+ foreach($query->result_array() as $row)
+ {
+ if (isset($row['TABLE_NAME']))
+ {
+ $retval[] = $row['TABLE_NAME'];
+ }
+ else
+ {
+ $retval[] = array_shift($row);
+ }
+ }
+ }
+
+ $this->data_cache['table_names'] = $retval;
+ return $this->data_cache['table_names'];
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Determine if a particular table exists
+ * @access public
+ * @return boolean
+ */
+ function table_exists($table_name)
+ {
+ return ( ! in_array($this->dbprefix.$table_name, $this->list_tables())) ? FALSE : TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch MySQL Field Names
+ *
+ * @access public
+ * @param string the table name
+ * @return array
+ */
+ function list_fields($table = '')
+ {
+ // Is there a cached result?
+ if (isset($this->data_cache['field_names'][$table]))
+ {
+ return $this->data_cache['field_names'][$table];
+ }
+
+ if ($table == '')
+ {
+ if ($this->db_debug)
+ {
+ return $this->display_error('db_field_param_missing');
+ }
+ return FALSE;
+ }
+
+ if (FALSE === ($sql = $this->_list_columns($this->dbprefix.$table)))
+ {
+ if ($this->db_debug)
+ {
+ return $this->display_error('db_unsupported_function');
+ }
+ return FALSE;
+ }
+
+ $query = $this->query($sql);
+
+ $retval = array();
+ foreach($query->result_array() as $row)
+ {
+ if (isset($row['COLUMN_NAME']))
+ {
+ $retval[] = $row['COLUMN_NAME'];
+ }
+ else
+ {
+ $retval[] = current($row);
+ }
+ }
+
+ $this->data_cache['field_names'][$table] = $retval;
+ return $this->data_cache['field_names'][$table];
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Determine if a particular field exists
+ * @access public
+ * @param string
+ * @param string
+ * @return boolean
+ */
+ function field_exists($field_name, $table_name)
+ {
+ return ( ! in_array($field_name, $this->list_fields($table_name))) ? FALSE : TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * DEPRECATED - use list_fields()
+ */
+ function field_names($table = '')
+ {
+ return $this->list_fields($table);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Returns an object with field data
+ *
+ * @access public
+ * @param string the table name
+ * @return object
+ */
+ function field_data($table = '')
+ {
+ if ($table == '')
+ {
+ if ($this->db_debug)
+ {
+ return $this->display_error('db_field_param_missing');
+ }
+ return FALSE;
+ }
+
+ $query = $this->query($this->_field_data($this->dbprefix.$table));
+ return $query->field_data();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Generate an insert string
+ *
+ * @access public
+ * @param string the table upon which the query will be performed
+ * @param array an associative array data of key/values
+ * @return string
+ */
+ function insert_string($table, $data)
+ {
+ $fields = array();
+ $values = array();
+
+ foreach($data as $key => $val)
+ {
+ $fields[] = $key;
+ $values[] = $this->escape($val);
+ }
+
+ return $this->_insert($this->dbprefix.$table, $fields, $values);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Generate an update string
+ *
+ * @access public
+ * @param string the table upon which the query will be performed
+ * @param array an associative array data of key/values
+ * @param mixed the "where" statement
+ * @return string
+ */
+ function update_string($table, $data, $where)
+ {
+ if ($where == '')
+ return false;
+
+ $fields = array();
+ foreach($data as $key => $val)
+ {
+ $fields[$key] = $this->escape($val);
+ }
+
+ if ( ! is_array($where))
+ {
+ $dest = array($where);
+ }
+ else
+ {
+ $dest = array();
+ foreach ($where as $key => $val)
+ {
+ $prefix = (count($dest) == 0) ? '' : ' AND ';
+
+ if ($val != '')
+ {
+ if ( ! $this->_has_operator($key))
+ {
+ $key .= ' =';
+ }
+
+ $val = ' '.$this->escape($val);
+ }
+
+ $dest[] = $prefix.$key.$val;
+ }
+ }
+
+ return $this->_update($this->dbprefix.$table, $fields, $dest);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Enables a native PHP function to be run, using a platform agnostic wrapper.
+ *
+ * @access public
+ * @param string the function name
+ * @param mixed any parameters needed by the function
+ * @return mixed
+ */
+ function call_function($function)
+ {
+ $driver = ($this->dbdriver == 'postgre') ? 'pg_' : $this->dbdriver.'_';
+
+ if (FALSE === strpos($driver, $function))
+ {
+ $function = $driver.$function;
+ }
+
+ if ( ! function_exists($function))
+ {
+ if ($this->db_debug)
+ {
+ return $this->display_error('db_unsupported_function');
+ }
+ return FALSE;
+ }
+ else
+ {
+ $args = (func_num_args() > 1) ? array_splice(func_get_args(), 1) : null;
+
+ return call_user_func_array($function, $args);
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Cache Directory Path
+ *
+ * @access public
+ * @param string the path to the cache directory
+ * @return void
+ */
+ function cache_set_path($path = '')
+ {
+ $this->cachedir = $path;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Enable Query Caching
+ *
+ * @access public
+ * @return void
+ */
+ function cache_on()
+ {
+ $this->cache_on = TRUE;
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Disable Query Caching
+ *
+ * @access public
+ * @return void
+ */
+ function cache_off()
+ {
+ $this->cache_on = FALSE;
+ return FALSE;
+ }
+
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Delete the cache files associated with a particular URI
+ *
+ * @access public
+ * @return void
+ */
+ function cache_delete($segment_one = '', $segment_two = '')
+ {
+ if ( ! $this->_cache_init())
+ {
+ return FALSE;
+ }
+ return $this->CACHE->delete($segment_one, $segment_two);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Delete All cache files
+ *
+ * @access public
+ * @return void
+ */
+ function cache_delete_all()
+ {
+ if ( ! $this->_cache_init())
+ {
+ return FALSE;
+ }
+
+ return $this->CACHE->delete_all();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Initialize the Cache Class
+ *
+ * @access private
+ * @return void
+ */
+ function _cache_init()
+ {
+ if (is_object($this->CACHE) AND class_exists('CI_DB_Cache'))
+ {
+ return TRUE;
+ }
+
+ if ( ! @include(BASEPATH.'database/DB_cache'.EXT))
+ {
+ return $this->cache_off();
+ }
+
+ $this->CACHE = new CI_DB_Cache;
+ return TRUE;
+ }
+
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Close DB Connection
+ *
+ * @access public
+ * @return void
+ */
+ function close()
+ {
+ if (is_resource($this->conn_id))
+ {
+ $this->_close($this->conn_id);
+ }
+ $this->conn_id = FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Display an error message
+ *
+ * @access public
+ * @param string the error message
+ * @param string any "swap" values
+ * @param boolean whether to localize the message
+ * @return string sends the application/error_db.php template
+ */
+ function display_error($error = '', $swap = '', $native = FALSE)
+ {
+ $LANG = new CI_Language();
+ $LANG->load('db');
+
+ $heading = 'MySQL Error';
+
+ if ($native == TRUE)
+ {
+ $message = $error;
+ }
+ else
+ {
+ $message = ( ! is_array($error)) ? array(str_replace('%s', $swap, $LANG->line($error))) : $error;
+ }
+
+ if ( ! class_exists('CI_Exceptions'))
+ {
+ include(BASEPATH.'libraries/Exceptions'.EXT);
+ }
+
+ $error = new CI_Exceptions();
+ echo $error->show_error('An Error Was Encountered', $message, 'error_db');
+ exit;
+ }
+
+}
+
?> \ No newline at end of file
diff --git a/system/database/DB_result.php b/system/database/DB_result.php
index 9784561d4..7d85ebb92 100644
--- a/system/database/DB_result.php
+++ b/system/database/DB_result.php
@@ -1,290 +1,290 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.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 Rick Ellis
- * @link http://www.codeigniter.com/user_guide/database/
- */
-class CI_DB_result {
-
- var $conn_id = NULL;
- var $result_id = NULL;
- var $result_array = array();
- var $result_object = array();
- var $current_row = 0;
- var $num_rows = 0;
-
-
- /**
- * Query result. Acts as a wrapper function for the following functions.
- *
- * @access public
- * @param string can be "object" or "array"
- * @return mixed either a result object or array
- */
- function result($type = 'object')
- {
- return ($type == 'object') ? $this->result_object() : $this->result_array();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Query result. "object" version.
- *
- * @access public
- * @return object
- */
- function result_object()
- {
- if (count($this->result_object) > 0)
- {
- return $this->result_object;
- }
-
- // In the event that query caching is on the result_id variable
- // will return FALSE since there isn't a valid SQL resource so
- // we'll simply return an empty array.
- if ($this->result_id === FALSE OR $this->num_rows() == 0)
- {
- return array();
- }
-
- $this->_data_seek(0);
- while ($row = $this->_fetch_object())
- {
- $this->result_object[] = $row;
- }
-
- return $this->result_object;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Query result. "array" version.
- *
- * @access public
- * @return array
- */
- function result_array()
- {
- if (count($this->result_array) > 0)
- {
- return $this->result_array;
- }
-
- // In the event that query caching is on the result_id variable
- // will return FALSE since there isn't a valid SQL resource so
- // we'll simply return an empty array.
- if ($this->result_id === FALSE OR $this->num_rows() == 0)
- {
- return array();
- }
-
- $this->_data_seek(0);
- while ($row = $this->_fetch_assoc())
- {
- $this->result_array[] = $row;
- }
-
- return $this->result_array;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Query result. Acts as a wrapper function for the following functions.
- *
- * @access public
- * @param string can be "object" or "array"
- * @return mixed either a result object or array
- */
- function row($n = 0, $type = 'object')
- {
- return ($type == 'object') ? $this->row_object($n) : $this->row_array($n);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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_names() { return array(); } // Deprecated
- 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
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.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 Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/database/
+ */
+class CI_DB_result {
+
+ var $conn_id = NULL;
+ var $result_id = NULL;
+ var $result_array = array();
+ var $result_object = array();
+ var $current_row = 0;
+ var $num_rows = 0;
+
+
+ /**
+ * Query result. Acts as a wrapper function for the following functions.
+ *
+ * @access public
+ * @param string can be "object" or "array"
+ * @return mixed either a result object or array
+ */
+ function result($type = 'object')
+ {
+ return ($type == 'object') ? $this->result_object() : $this->result_array();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Query result. "object" version.
+ *
+ * @access public
+ * @return object
+ */
+ function result_object()
+ {
+ if (count($this->result_object) > 0)
+ {
+ return $this->result_object;
+ }
+
+ // In the event that query caching is on the result_id variable
+ // will return FALSE since there isn't a valid SQL resource so
+ // we'll simply return an empty array.
+ if ($this->result_id === FALSE OR $this->num_rows() == 0)
+ {
+ return array();
+ }
+
+ $this->_data_seek(0);
+ while ($row = $this->_fetch_object())
+ {
+ $this->result_object[] = $row;
+ }
+
+ return $this->result_object;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Query result. "array" version.
+ *
+ * @access public
+ * @return array
+ */
+ function result_array()
+ {
+ if (count($this->result_array) > 0)
+ {
+ return $this->result_array;
+ }
+
+ // In the event that query caching is on the result_id variable
+ // will return FALSE since there isn't a valid SQL resource so
+ // we'll simply return an empty array.
+ if ($this->result_id === FALSE OR $this->num_rows() == 0)
+ {
+ return array();
+ }
+
+ $this->_data_seek(0);
+ while ($row = $this->_fetch_assoc())
+ {
+ $this->result_array[] = $row;
+ }
+
+ return $this->result_array;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Query result. Acts as a wrapper function for the following functions.
+ *
+ * @access public
+ * @param string can be "object" or "array"
+ * @return mixed either a result object or array
+ */
+ function row($n = 0, $type = 'object')
+ {
+ return ($type == 'object') ? $this->row_object($n) : $this->row_array($n);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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_names() { return array(); } // Deprecated
+ 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
?> \ No newline at end of file
diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php
index 9533ec607..d48425d7e 100644
--- a/system/database/DB_utility.php
+++ b/system/database/DB_utility.php
@@ -1,455 +1,455 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Database Utility Class
- *
- * @category Database
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/database/
- */
-class CI_DB_utility {
-
- 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");
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * List databases
- *
- * @access public
- * @return bool
- */
- function list_databases()
- {
- // Is there a cached result?
- if (isset($this->data_cache['db_names']))
- {
- return $this->data_cache['db_names'];
- }
-
- $query = $this->db->query($this->_list_databases());
- $dbs = array();
- if ($query->num_rows() > 0)
- {
- foreach ($query->result_array() as $row)
- {
- $dbs[] = current($row);
- }
- }
-
- $this->data_cache['db_names'] = $dbs;
- return $this->data_cache['db_names'];
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Optimize Table
- *
- * @access public
- * @param string the table name
- * @return bool
- */
- function optimize_table($table_name)
- {
- $sql = $this->_optimize_table($table_name);
-
- if (is_bool($sql))
- {
- return $sql;
- }
-
- $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;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Optimize 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);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Drop Table
- *
- * @access public
- * @param string the table name
- * @return bool
- */
- function drop_table($table_name)
- {
- $sql = $this->_drop_table($table_name);
-
- if (is_bool($sql))
- {
- return $sql;
- }
-
- return $this->db->query($sql);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Generate CSV from a query result object
- *
- * @access public
- * @param object The query result object
- * @param string The delimiter - tab by default
- * @param string The newline character - \n by default
- * @return string
- */
- function csv_from_result($query, $delim = "\t", $newline = "\n")
- {
- if ( ! is_object($query) OR ! method_exists($query, 'field_names'))
- {
- 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 .= $name.$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 .= $item.$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, 'field_names'))
- {
- 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();
- }
-
- }
-
-
-
-
-
-
-}
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Database Utility Class
+ *
+ * @category Database
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/database/
+ */
+class CI_DB_utility {
+
+ 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");
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * List databases
+ *
+ * @access public
+ * @return bool
+ */
+ function list_databases()
+ {
+ // Is there a cached result?
+ if (isset($this->data_cache['db_names']))
+ {
+ return $this->data_cache['db_names'];
+ }
+
+ $query = $this->db->query($this->_list_databases());
+ $dbs = array();
+ if ($query->num_rows() > 0)
+ {
+ foreach ($query->result_array() as $row)
+ {
+ $dbs[] = current($row);
+ }
+ }
+
+ $this->data_cache['db_names'] = $dbs;
+ return $this->data_cache['db_names'];
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Optimize Table
+ *
+ * @access public
+ * @param string the table name
+ * @return bool
+ */
+ function optimize_table($table_name)
+ {
+ $sql = $this->_optimize_table($table_name);
+
+ if (is_bool($sql))
+ {
+ return $sql;
+ }
+
+ $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;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Optimize 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);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop Table
+ *
+ * @access public
+ * @param string the table name
+ * @return bool
+ */
+ function drop_table($table_name)
+ {
+ $sql = $this->_drop_table($table_name);
+
+ if (is_bool($sql))
+ {
+ return $sql;
+ }
+
+ return $this->db->query($sql);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Generate CSV from a query result object
+ *
+ * @access public
+ * @param object The query result object
+ * @param string The delimiter - tab by default
+ * @param string The newline character - \n by default
+ * @return string
+ */
+ function csv_from_result($query, $delim = "\t", $newline = "\n")
+ {
+ if ( ! is_object($query) OR ! method_exists($query, 'field_names'))
+ {
+ 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 .= $name.$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 .= $item.$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, 'field_names'))
+ {
+ 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();
+ }
+
+ }
+
+
+
+
+
+
+}
+
?> \ No newline at end of file
diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php
index 47cfa6bbe..ef66e3f3a 100644
--- a/system/database/drivers/mssql/mssql_driver.php
+++ b/system/database/drivers/mssql/mssql_driver.php
@@ -1,458 +1,458 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.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 Rick Ellis
- * @link http://www.codeigniter.com/user_guide/database/
- */
-class CI_DB_mssql_driver extends CI_DB {
-
- /**
- * Non-persistent database connection
- *
- * @access private called by the base class
- * @return resource
- */
- function db_connect()
- {
- return @mssql_connect($this->hostname, $this->username, $this->password);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Persistent database connection
- *
- * @access private called by the base class
- * @return resource
- */
- function db_pconnect()
- {
- return @mssql_pconnect($this->hostname, $this->username, $this->password);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Select the database
- *
- * @access private called by the base class
- * @return resource
- */
- function db_select()
- {
- return @mssql_select_db($this->database, $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 @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
- * @return string
- */
- function escape_str($str)
- {
- // Escape single quotes
- return str_replace("'", "''", $str);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Affected Rows
- *
- * @access public
- * @return integer
- */
- function affected_rows()
- {
- return @mssql_rows_affected($this->conn_id);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Insert ID
- *
- * @access public
- * @return integer
- */
- function insert_id()
- {
- // Not supported in MS SQL?
- return 0;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * "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("SELECT COUNT(*) AS numrows FROM ".$this->dbprefix.$table);
-
- if ($query->num_rows() == 0)
- return '0';
-
- $row = $query->row();
- return $row->numrows;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * List table query
- *
- * Generates a platform-specific query string so that the table names can be fetched
- *
- * @access private
- * @return string
- */
- function _list_tables()
- {
- return "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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 = '".$this->_escape_table($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 ".$this->_escape_table($table);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * The error message string
- *
- * @access private
- * @return string
- */
- function _error_message()
- {
- // Are errros even supported in MS SQL?
- return '';
- }
-
- // --------------------------------------------------------------------
-
- /**
- * The error message number
- *
- * @access private
- * @return integer
- */
- function _error_number()
- {
- // Are error numbers supported?
- return '';
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Escape Table Name
- *
- * This function adds backticks if the table name has a period
- * in it. Some DBs will get cranky unless periods are escaped
- *
- * @access private
- * @param string the table name
- * @return string
- */
- function _escape_table($table)
- {
- // I don't believe this is necessary with MS SQL. Not sure, though. - Rick
-
- /*
- if (stristr($table, '.'))
- {
- $table = preg_replace("/\./", "`.`", $table);
- }
- */
-
- return $table;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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 ".$this->_escape_table($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
- * @return string
- */
- function _update($table, $values, $where)
- {
- foreach($values as $key => $val)
- {
- $valstr[] = $key." = ".$val;
- }
-
- return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Delete statement
- *
- * Generates a platform-specific delete string from the supplied data
- *
- * @access public
- * @param string the table name
- * @param array the where clause
- * @return string
- */
- function _delete($table, $where)
- {
- return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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);
- }
-
-}
-
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.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 Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/database/
+ */
+class CI_DB_mssql_driver extends CI_DB {
+
+ /**
+ * Non-persistent database connection
+ *
+ * @access private called by the base class
+ * @return resource
+ */
+ function db_connect()
+ {
+ return @mssql_connect($this->hostname, $this->username, $this->password);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Persistent database connection
+ *
+ * @access private called by the base class
+ * @return resource
+ */
+ function db_pconnect()
+ {
+ return @mssql_pconnect($this->hostname, $this->username, $this->password);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Select the database
+ *
+ * @access private called by the base class
+ * @return resource
+ */
+ function db_select()
+ {
+ return @mssql_select_db($this->database, $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 @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
+ * @return string
+ */
+ function escape_str($str)
+ {
+ // Escape single quotes
+ return str_replace("'", "''", $str);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Affected Rows
+ *
+ * @access public
+ * @return integer
+ */
+ function affected_rows()
+ {
+ return @mssql_rows_affected($this->conn_id);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Insert ID
+ *
+ * @access public
+ * @return integer
+ */
+ function insert_id()
+ {
+ // Not supported in MS SQL?
+ return 0;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * "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("SELECT COUNT(*) AS numrows FROM ".$this->dbprefix.$table);
+
+ if ($query->num_rows() == 0)
+ return '0';
+
+ $row = $query->row();
+ return $row->numrows;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * List table query
+ *
+ * Generates a platform-specific query string so that the table names can be fetched
+ *
+ * @access private
+ * @return string
+ */
+ function _list_tables()
+ {
+ return "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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 = '".$this->_escape_table($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 ".$this->_escape_table($table);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * The error message string
+ *
+ * @access private
+ * @return string
+ */
+ function _error_message()
+ {
+ // Are errros even supported in MS SQL?
+ return '';
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * The error message number
+ *
+ * @access private
+ * @return integer
+ */
+ function _error_number()
+ {
+ // Are error numbers supported?
+ return '';
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Escape Table Name
+ *
+ * This function adds backticks if the table name has a period
+ * in it. Some DBs will get cranky unless periods are escaped
+ *
+ * @access private
+ * @param string the table name
+ * @return string
+ */
+ function _escape_table($table)
+ {
+ // I don't believe this is necessary with MS SQL. Not sure, though. - Rick
+
+ /*
+ if (stristr($table, '.'))
+ {
+ $table = preg_replace("/\./", "`.`", $table);
+ }
+ */
+
+ return $table;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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 ".$this->_escape_table($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
+ * @return string
+ */
+ function _update($table, $values, $where)
+ {
+ foreach($values as $key => $val)
+ {
+ $valstr[] = $key." = ".$val;
+ }
+
+ return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Delete statement
+ *
+ * Generates a platform-specific delete string from the supplied data
+ *
+ * @access public
+ * @param string the table name
+ * @param array the where clause
+ * @return string
+ */
+ function _delete($table, $where)
+ {
+ return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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);
+ }
+
+}
+
+
?> \ No newline at end of file
diff --git a/system/database/drivers/mssql/mssql_result.php b/system/database/drivers/mssql/mssql_result.php
index eb7afef70..eb471e4be 100644
--- a/system/database/drivers/mssql/mssql_result.php
+++ b/system/database/drivers/mssql/mssql_result.php
@@ -1,173 +1,173 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * MS SQL Result Class
- *
- * This class extends the parent result class: CI_DB_result
- *
- * @category Database
- * @author Rick Ellis
- * @link http://www.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;
- }
-
- // Deprecated
- function field_names()
- {
- return $this->list_fields();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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);
- }
-
-}
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * MS SQL Result Class
+ *
+ * This class extends the parent result class: CI_DB_result
+ *
+ * @category Database
+ * @author Rick Ellis
+ * @link http://www.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;
+ }
+
+ // Deprecated
+ function field_names()
+ {
+ return $this->list_fields();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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);
+ }
+
+}
+
?> \ No newline at end of file
diff --git a/system/database/drivers/mssql/mssql_utility.php b/system/database/drivers/mssql/mssql_utility.php
index b24646123..7f4e73084 100644
--- a/system/database/drivers/mssql/mssql_utility.php
+++ b/system/database/drivers/mssql/mssql_utility.php
@@ -1,130 +1,130 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * MS SQL Utility Class
- *
- * @category Database
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/database/
- */
-class CI_DB_mssql_utility extends CI_DB_utility {
-
-
- /**
- * 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_table($table);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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');
- }
-
-
-}
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * MS SQL Utility Class
+ *
+ * @category Database
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/database/
+ */
+class CI_DB_mssql_utility extends CI_DB_utility {
+
+
+ /**
+ * 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_table($table);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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');
+ }
+
+
+}
+
?> \ No newline at end of file
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php
index 2104b9abd..367c2d11f 100644
--- a/system/database/drivers/mysql/mysql_driver.php
+++ b/system/database/drivers/mysql/mysql_driver.php
@@ -1,492 +1,492 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.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 Rick Ellis
- * @link http://www.codeigniter.com/user_guide/database/
- */
-class CI_DB_mysql_driver extends CI_DB {
-
- /**
- * 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()
- {
- 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()
- {
- return @mysql_pconnect($this->hostname, $this->username, $this->password);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Select the database
- *
- * @access private called by the base class
- * @return resource
- */
- function db_select()
- {
- return @mysql_select_db($this->database, $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
- * @return string
- */
- function escape_str($str)
- {
- if (get_magic_quotes_gpc())
- {
- return $str;
- }
-
- if (function_exists('mysql_real_escape_string'))
- {
- return mysql_real_escape_string($str, $this->conn_id);
- }
- elseif (function_exists('mysql_escape_string'))
- {
- return mysql_escape_string($str);
- }
- else
- {
- return addslashes($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("SELECT COUNT(*) AS numrows FROM `".$this->dbprefix.$table."`");
-
- if ($query->num_rows() == 0)
- return '0';
-
- $row = $query->row();
- return $row->numrows;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * List table query
- *
- * Generates a platform-specific query string so that the table names can be fetched
- *
- * @access private
- * @return string
- */
- function _list_tables()
- {
- return "SHOW TABLES FROM `".$this->database."`";
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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->_escape_table($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 ".$this->_escape_table($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 Table Name
- *
- * This function adds backticks if the table name has a period
- * in it. Some DBs will get cranky unless periods are escaped
- *
- * @access private
- * @param string the table name
- * @return string
- */
- function _escape_table($table)
- {
- if (stristr($table, '.'))
- {
- $table = preg_replace("/\./", "`.`", $table);
- }
-
- return $table;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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 ".$this->_escape_table($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
- * @return string
- */
- function _update($table, $values, $where)
- {
- foreach($values as $key => $val)
- {
- $valstr[] = $key." = ".$val;
- }
-
- return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Delete statement
- *
- * Generates a platform-specific delete string from the supplied data
- *
- * @access public
- * @param string the table name
- * @param array the where clause
- * @return string
- */
- function _delete($table, $where)
- {
- return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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);
- }
-
-}
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.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 Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/database/
+ */
+class CI_DB_mysql_driver extends CI_DB {
+
+ /**
+ * 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()
+ {
+ 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()
+ {
+ return @mysql_pconnect($this->hostname, $this->username, $this->password);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Select the database
+ *
+ * @access private called by the base class
+ * @return resource
+ */
+ function db_select()
+ {
+ return @mysql_select_db($this->database, $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
+ * @return string
+ */
+ function escape_str($str)
+ {
+ if (get_magic_quotes_gpc())
+ {
+ return $str;
+ }
+
+ if (function_exists('mysql_real_escape_string'))
+ {
+ return mysql_real_escape_string($str, $this->conn_id);
+ }
+ elseif (function_exists('mysql_escape_string'))
+ {
+ return mysql_escape_string($str);
+ }
+ else
+ {
+ return addslashes($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("SELECT COUNT(*) AS numrows FROM `".$this->dbprefix.$table."`");
+
+ if ($query->num_rows() == 0)
+ return '0';
+
+ $row = $query->row();
+ return $row->numrows;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * List table query
+ *
+ * Generates a platform-specific query string so that the table names can be fetched
+ *
+ * @access private
+ * @return string
+ */
+ function _list_tables()
+ {
+ return "SHOW TABLES FROM `".$this->database."`";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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->_escape_table($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 ".$this->_escape_table($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 Table Name
+ *
+ * This function adds backticks if the table name has a period
+ * in it. Some DBs will get cranky unless periods are escaped
+ *
+ * @access private
+ * @param string the table name
+ * @return string
+ */
+ function _escape_table($table)
+ {
+ if (stristr($table, '.'))
+ {
+ $table = preg_replace("/\./", "`.`", $table);
+ }
+
+ return $table;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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 ".$this->_escape_table($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
+ * @return string
+ */
+ function _update($table, $values, $where)
+ {
+ foreach($values as $key => $val)
+ {
+ $valstr[] = $key." = ".$val;
+ }
+
+ return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Delete statement
+ *
+ * Generates a platform-specific delete string from the supplied data
+ *
+ * @access public
+ * @param string the table name
+ * @param array the where clause
+ * @return string
+ */
+ function _delete($table, $where)
+ {
+ return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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);
+ }
+
+}
+
?> \ No newline at end of file
diff --git a/system/database/drivers/mysql/mysql_result.php b/system/database/drivers/mysql/mysql_result.php
index 9b28dead7..7dcd5cb0e 100644
--- a/system/database/drivers/mysql/mysql_result.php
+++ b/system/database/drivers/mysql/mysql_result.php
@@ -1,173 +1,173 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// --------------------------------------------------------------------
-
-/**
- * MySQL Result Class
- *
- * This class extends the parent result class: CI_DB_result
- *
- * @category Database
- * @author Rick Ellis
- * @link http://www.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;
- }
-
- // Deprecated
- function field_names()
- {
- return $this->list_fields();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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);
- }
-
-}
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// --------------------------------------------------------------------
+
+/**
+ * MySQL Result Class
+ *
+ * This class extends the parent result class: CI_DB_result
+ *
+ * @category Database
+ * @author Rick Ellis
+ * @link http://www.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;
+ }
+
+ // Deprecated
+ function field_names()
+ {
+ return $this->list_fields();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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);
+ }
+
+}
+
?> \ No newline at end of file
diff --git a/system/database/drivers/mysql/mysql_utility.php b/system/database/drivers/mysql/mysql_utility.php
index 32007d224..b357f47df 100644
--- a/system/database/drivers/mysql/mysql_utility.php
+++ b/system/database/drivers/mysql/mysql_utility.php
@@ -1,244 +1,244 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * MySQL Utility Class
- *
- * @category Database
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/database/
- */
-class CI_DB_mysql_utility extends CI_DB_utility {
-
- /**
- * 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;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * List databases
- *
- * @access private
- * @return bool
- */
- function _list_databases()
- {
- return "SHOW DATABASES";
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Drop Table
- *
- * @access private
- * @return bool
- */
- function _drop_table($table)
- {
- return "DROP TABLE IF EXISTS ".$this->db->_escape_table($table);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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_table($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_table($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))
- {
- $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)
- {
- // Do a little formatting...
- $v = str_replace(array("\x00", "\x0a", "\x0d", "\x1a"), array('\0', '\n', '\r', '\Z'), $v);
- $v = str_replace(array("\n", "\r", "\t"), array('\n', '\r', '\t'), $v);
- $v = str_replace('\\', '\\\\', $v);
- $v = str_replace('\'', '\\\'', $v);
- $v = str_replace('\\\n', '\n', $v);
- $v = str_replace('\\\r', '\r', $v);
- $v = str_replace('\\\t', '\t', $v);
-
- // Escape the data if it's not an integer type
- $val_str .= ($is_int[$i] == FALSE) ? $this->db->escape($v) : $v;
- $val_str .= ', ';
-
- $i++;
- }
-
- $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;
- }
-
-
-}
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * MySQL Utility Class
+ *
+ * @category Database
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/database/
+ */
+class CI_DB_mysql_utility extends CI_DB_utility {
+
+ /**
+ * 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;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * List databases
+ *
+ * @access private
+ * @return bool
+ */
+ function _list_databases()
+ {
+ return "SHOW DATABASES";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop Table
+ *
+ * @access private
+ * @return bool
+ */
+ function _drop_table($table)
+ {
+ return "DROP TABLE IF EXISTS ".$this->db->_escape_table($table);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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_table($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_table($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))
+ {
+ $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)
+ {
+ // Do a little formatting...
+ $v = str_replace(array("\x00", "\x0a", "\x0d", "\x1a"), array('\0', '\n', '\r', '\Z'), $v);
+ $v = str_replace(array("\n", "\r", "\t"), array('\n', '\r', '\t'), $v);
+ $v = str_replace('\\', '\\\\', $v);
+ $v = str_replace('\'', '\\\'', $v);
+ $v = str_replace('\\\n', '\n', $v);
+ $v = str_replace('\\\r', '\r', $v);
+ $v = str_replace('\\\t', '\t', $v);
+
+ // Escape the data if it's not an integer type
+ $val_str .= ($is_int[$i] == FALSE) ? $this->db->escape($v) : $v;
+ $val_str .= ', ';
+
+ $i++;
+ }
+
+ $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;
+ }
+
+
+}
+
?> \ No newline at end of file
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index f8d3acf20..98e7f6c76 100644
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -1,483 +1,483 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.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 Rick Ellis
- * @link http://www.codeigniter.com/user_guide/database/
- */
-class CI_DB_mysqli_driver extends CI_DB {
-
- /**
- * 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()
- {
- return @mysqli_connect($this->hostname, $this->username, $this->password);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Persistent database connection
- *
- * @access private called by the base class
- * @return resource
- */
- function db_pconnect()
- {
- return $this->db_connect();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Select the database
- *
- * @access private called by the base class
- * @return resource
- */
- function db_select()
- {
- return @mysqli_select_db($this->conn_id, $this->database);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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
- * @return string
- */
- function escape_str($str)
- {
- if (get_magic_quotes_gpc())
- {
- return $str;
- }
-
- return mysqli_real_escape_string($this->conn_id, $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("SELECT COUNT(*) AS numrows FROM `".$this->dbprefix.$table."`");
-
- if ($query->num_rows() == 0)
- return '0';
-
- $row = $query->row();
- return $row->numrows;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * List table query
- *
- * Generates a platform-specific query string so that the table names can be fetched
- *
- * @access private
- * @return string
- */
- function _list_tables()
- {
- return "SHOW TABLES FROM `".$this->database."`";
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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->_escape_table($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 ".$this->_escape_table($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 Table Name
- *
- * This function adds backticks if the table name has a period
- * in it. Some DBs will get cranky unless periods are escaped
- *
- * @access private
- * @param string the table name
- * @return string
- */
- function _escape_table($table)
- {
- if (stristr($table, '.'))
- {
- $table = preg_replace("/\./", "`.`", $table);
- }
-
- return $table;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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 ".$this->_escape_table($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
- * @return string
- */
- function _update($table, $values, $where)
- {
- foreach($values as $key => $val)
- {
- $valstr[] = $key." = ".$val;
- }
-
- return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Delete statement
- *
- * Generates a platform-specific delete string from the supplied data
- *
- * @access public
- * @param string the table name
- * @param array the where clause
- * @return string
- */
- function _delete($table, $where)
- {
- return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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);
- }
-
-
-}
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.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 Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/database/
+ */
+class CI_DB_mysqli_driver extends CI_DB {
+
+ /**
+ * 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()
+ {
+ return @mysqli_connect($this->hostname, $this->username, $this->password);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Persistent database connection
+ *
+ * @access private called by the base class
+ * @return resource
+ */
+ function db_pconnect()
+ {
+ return $this->db_connect();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Select the database
+ *
+ * @access private called by the base class
+ * @return resource
+ */
+ function db_select()
+ {
+ return @mysqli_select_db($this->conn_id, $this->database);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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
+ * @return string
+ */
+ function escape_str($str)
+ {
+ if (get_magic_quotes_gpc())
+ {
+ return $str;
+ }
+
+ return mysqli_real_escape_string($this->conn_id, $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("SELECT COUNT(*) AS numrows FROM `".$this->dbprefix.$table."`");
+
+ if ($query->num_rows() == 0)
+ return '0';
+
+ $row = $query->row();
+ return $row->numrows;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * List table query
+ *
+ * Generates a platform-specific query string so that the table names can be fetched
+ *
+ * @access private
+ * @return string
+ */
+ function _list_tables()
+ {
+ return "SHOW TABLES FROM `".$this->database."`";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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->_escape_table($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 ".$this->_escape_table($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 Table Name
+ *
+ * This function adds backticks if the table name has a period
+ * in it. Some DBs will get cranky unless periods are escaped
+ *
+ * @access private
+ * @param string the table name
+ * @return string
+ */
+ function _escape_table($table)
+ {
+ if (stristr($table, '.'))
+ {
+ $table = preg_replace("/\./", "`.`", $table);
+ }
+
+ return $table;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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 ".$this->_escape_table($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
+ * @return string
+ */
+ function _update($table, $values, $where)
+ {
+ foreach($values as $key => $val)
+ {
+ $valstr[] = $key." = ".$val;
+ }
+
+ return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Delete statement
+ *
+ * Generates a platform-specific delete string from the supplied data
+ *
+ * @access public
+ * @param string the table name
+ * @param array the where clause
+ * @return string
+ */
+ function _delete($table, $where)
+ {
+ return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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);
+ }
+
+
+}
+
?> \ No newline at end of file
diff --git a/system/database/drivers/mysqli/mysqli_result.php b/system/database/drivers/mysqli/mysqli_result.php
index 57c89ea80..0f2eb5345 100644
--- a/system/database/drivers/mysqli/mysqli_result.php
+++ b/system/database/drivers/mysqli/mysqli_result.php
@@ -1,173 +1,173 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * MySQLi Result Class
- *
- * This class extends the parent result class: CI_DB_result
- *
- * @category Database
- * @author Rick Ellis
- * @link http://www.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;
- }
-
- // Deprecated
- function field_names()
- {
- return $this->list_fields();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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_resource($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);
- }
-
-}
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * MySQLi Result Class
+ *
+ * This class extends the parent result class: CI_DB_result
+ *
+ * @category Database
+ * @author Rick Ellis
+ * @link http://www.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;
+ }
+
+ // Deprecated
+ function field_names()
+ {
+ return $this->list_fields();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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_resource($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);
+ }
+
+}
+
?> \ No newline at end of file
diff --git a/system/database/drivers/mysqli/mysqli_utility.php b/system/database/drivers/mysqli/mysqli_utility.php
index d5dbf2fb0..3e2b8da6e 100644
--- a/system/database/drivers/mysqli/mysqli_utility.php
+++ b/system/database/drivers/mysqli/mysqli_utility.php
@@ -1,245 +1,245 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * MySQLi Utility Class
- *
- * @category Database
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/database/
- */
-class CI_DB_mysqli_utility extends CI_DB_utility {
-
- /**
- * 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 IF EXISTS ".$this->db->_escape_table($table);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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_table($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_table($table);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * MySQLi 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 = mysqli_fetch_field($query->result_id))
- {
- $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)
- {
- // Do a little formatting...
- $v = str_replace(array("\x00", "\x0a", "\x0d", "\x1a"), array('\0', '\n', '\r', '\Z'), $v);
- $v = str_replace(array("\n", "\r", "\t"), array('\n', '\r', '\t'), $v);
- $v = str_replace('\\', '\\\\', $v);
- $v = str_replace('\'', '\\\'', $v);
- $v = str_replace('\\\n', '\n', $v);
- $v = str_replace('\\\r', '\r', $v);
- $v = str_replace('\\\t', '\t', $v);
-
- // Escape the data if it's not an integer type
- $val_str .= ($is_int[$i] == FALSE) ? $this->db->escape($v) : $v;
- $val_str .= ', ';
-
- $i++;
- }
-
- $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;
- }
-
-
-
-}
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * MySQLi Utility Class
+ *
+ * @category Database
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/database/
+ */
+class CI_DB_mysqli_utility extends CI_DB_utility {
+
+ /**
+ * 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 IF EXISTS ".$this->db->_escape_table($table);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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_table($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_table($table);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * MySQLi 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 = mysqli_fetch_field($query->result_id))
+ {
+ $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)
+ {
+ // Do a little formatting...
+ $v = str_replace(array("\x00", "\x0a", "\x0d", "\x1a"), array('\0', '\n', '\r', '\Z'), $v);
+ $v = str_replace(array("\n", "\r", "\t"), array('\n', '\r', '\t'), $v);
+ $v = str_replace('\\', '\\\\', $v);
+ $v = str_replace('\'', '\\\'', $v);
+ $v = str_replace('\\\n', '\n', $v);
+ $v = str_replace('\\\r', '\r', $v);
+ $v = str_replace('\\\t', '\t', $v);
+
+ // Escape the data if it's not an integer type
+ $val_str .= ($is_int[$i] == FALSE) ? $this->db->escape($v) : $v;
+ $val_str .= ', ';
+
+ $i++;
+ }
+
+ $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;
+ }
+
+
+
+}
+
?> \ No newline at end of file
diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php
index ff301a57d..291e168eb 100644
--- a/system/database/drivers/oci8/oci8_driver.php
+++ b/system/database/drivers/oci8/oci8_driver.php
@@ -1,605 +1,605 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.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 Rick Ellis
- * @link http://www.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 {
-
- // 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);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Select the database
- *
- * @access private called by the base class
- * @return resource
- */
- function db_select()
- {
- 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->_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
- * @return string
- */
- function escape_str($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 0;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * "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("SELECT COUNT(1) AS numrows FROM ".$table);
-
- if ($query == FALSE)
- {
- return 0;
- }
-
- $row = $query->row();
- return $row->NUMROWS;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Show table query
- *
- * Generates a platform-specific query string so that the table names can be fetched
- *
- * @access private
- * @return string
- */
- function _list_tables()
- {
- return "SELECT TABLE_NAME FROM ALL_TABLES";
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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 ".$this->_escape_table($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 Table Name
- *
- * This function adds backticks if the table name has a period
- * in it. Some DBs will get cranky unless periods are escaped
- *
- * @access private
- * @param string the table name
- * @return string
- */
- function _escape_table($table)
- {
- if (stristr($table, '.'))
- {
- $table = preg_replace("/\./", "`.`", $table);
- }
-
- return $table;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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 ".$this->_escape_table($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
- * @return string
- */
- function _update($table, $values, $where)
- {
- foreach($values as $key => $val)
- {
- $valstr[] = $key." = ".$val;
- }
-
- return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Delete statement
- *
- * Generates a platform-specific delete string from the supplied data
- *
- * @access public
- * @param string the table name
- * @param array the where clause
- * @return string
- */
- function _delete($table, $where)
- {
- return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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);
- }
-
-
-}
-
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.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 Rick Ellis
+ * @link http://www.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 {
+
+ // 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);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Select the database
+ *
+ * @access private called by the base class
+ * @return resource
+ */
+ function db_select()
+ {
+ 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->_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
+ * @return string
+ */
+ function escape_str($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 0;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * "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("SELECT COUNT(1) AS numrows FROM ".$table);
+
+ if ($query == FALSE)
+ {
+ return 0;
+ }
+
+ $row = $query->row();
+ return $row->NUMROWS;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Show table query
+ *
+ * Generates a platform-specific query string so that the table names can be fetched
+ *
+ * @access private
+ * @return string
+ */
+ function _list_tables()
+ {
+ return "SELECT TABLE_NAME FROM ALL_TABLES";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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 ".$this->_escape_table($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 Table Name
+ *
+ * This function adds backticks if the table name has a period
+ * in it. Some DBs will get cranky unless periods are escaped
+ *
+ * @access private
+ * @param string the table name
+ * @return string
+ */
+ function _escape_table($table)
+ {
+ if (stristr($table, '.'))
+ {
+ $table = preg_replace("/\./", "`.`", $table);
+ }
+
+ return $table;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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 ".$this->_escape_table($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
+ * @return string
+ */
+ function _update($table, $values, $where)
+ {
+ foreach($values as $key => $val)
+ {
+ $valstr[] = $key." = ".$val;
+ }
+
+ return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Delete statement
+ *
+ * Generates a platform-specific delete string from the supplied data
+ *
+ * @access public
+ * @param string the table name
+ * @param array the where clause
+ * @return string
+ */
+ function _delete($table, $where)
+ {
+ return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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);
+ }
+
+
+}
+
+
?> \ No newline at end of file
diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php
index fb4ed1f0d..07f154489 100644
--- a/system/database/drivers/oci8/oci8_result.php
+++ b/system/database/drivers/oci8/oci8_result.php
@@ -1,251 +1,251 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * oci8 Result Class
- *
- * This class extends the parent result class: CI_DB_result
- *
- * @category Database
- * @author Rick Ellis
- * @link http://www.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;
- }
-
- // Deprecated
- function field_names()
- {
- return $this->list_fields();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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
- }
-
-}
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * oci8 Result Class
+ *
+ * This class extends the parent result class: CI_DB_result
+ *
+ * @category Database
+ * @author Rick Ellis
+ * @link http://www.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;
+ }
+
+ // Deprecated
+ function field_names()
+ {
+ return $this->list_fields();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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
+ }
+
+}
+
?> \ No newline at end of file
diff --git a/system/database/drivers/oci8/oci8_utility.php b/system/database/drivers/oci8/oci8_utility.php
index 1d83af1fe..1b49f4131 100644
--- a/system/database/drivers/oci8/oci8_utility.php
+++ b/system/database/drivers/oci8/oci8_utility.php
@@ -1,129 +1,129 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Oracle Utility Class
- *
- * @category Database
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/database/
- */
-class CI_DB_oci8_utility extends CI_DB_utility {
-
-
- /**
- * 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;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * List databases
- *
- * @access private
- * @return bool
- */
- function _list_databases()
- {
- return FALSE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Drop Table
- *
- * @access private
- * @return bool
- */
- function _drop_table($table)
- {
- 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');
- }
-
-}
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Oracle Utility Class
+ *
+ * @category Database
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/database/
+ */
+class CI_DB_oci8_utility extends CI_DB_utility {
+
+
+ /**
+ * 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;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * List databases
+ *
+ * @access private
+ * @return bool
+ */
+ function _list_databases()
+ {
+ return FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop Table
+ *
+ * @access private
+ * @return bool
+ */
+ function _drop_table($table)
+ {
+ 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');
+ }
+
+}
+
?> \ No newline at end of file
diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php
index 9d540c77f..d6451e04a 100644
--- a/system/database/drivers/odbc/odbc_driver.php
+++ b/system/database/drivers/odbc/odbc_driver.php
@@ -1,12 +1,12 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
- * Code Igniter
+ * CodeIgniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
* @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
* @license http://www.codeignitor.com/user_guide/license.html
* @link http://www.codeigniter.com
* @since Version 1.0
diff --git a/system/database/drivers/odbc/odbc_result.php b/system/database/drivers/odbc/odbc_result.php
index 47fb103b3..cced4d482 100644
--- a/system/database/drivers/odbc/odbc_result.php
+++ b/system/database/drivers/odbc/odbc_result.php
@@ -1,234 +1,234 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * ODBC Result Class
- *
- * This class extends the parent result class: CI_DB_result
- *
- * @category Database
- * @author Rick Ellis
- * @link http://www.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;
- }
-
- // Deprecated
- function field_names()
- {
- return $this->list_fields();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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;
- }
-
-}
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * ODBC Result Class
+ *
+ * This class extends the parent result class: CI_DB_result
+ *
+ * @category Database
+ * @author Rick Ellis
+ * @link http://www.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;
+ }
+
+ // Deprecated
+ function field_names()
+ {
+ return $this->list_fields();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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;
+ }
+
+}
+
?> \ No newline at end of file
diff --git a/system/database/drivers/odbc/odbc_utility.php b/system/database/drivers/odbc/odbc_utility.php
index 8af463b13..f8d9e3c42 100644
--- a/system/database/drivers/odbc/odbc_utility.php
+++ b/system/database/drivers/odbc/odbc_utility.php
@@ -1,161 +1,161 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * ODBC Utility Class
- *
- * @category Database
- * @author Rick Ellis
- * @link http://www.codeigniter.com/database/
- */
-class CI_DB_odbc_utility extends CI_DB_utility {
-
-
- /**
- * 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;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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');
- }
-
-}
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * ODBC Utility Class
+ *
+ * @category Database
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/database/
+ */
+class CI_DB_odbc_utility extends CI_DB_utility {
+
+
+ /**
+ * 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;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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');
+ }
+
+}
+
?> \ No newline at end of file
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 58cc69a96..bfb212cfd 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -1,12 +1,12 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
- * Code Igniter
+ * CodeIgniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
* @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
* @license http://www.codeignitor.com/user_guide/license.html
* @link http://www.codeigniter.com
* @since Version 1.0
diff --git a/system/database/drivers/postgre/postgre_result.php b/system/database/drivers/postgre/postgre_result.php
index f065e54fb..5b955ad12 100644
--- a/system/database/drivers/postgre/postgre_result.php
+++ b/system/database/drivers/postgre/postgre_result.php
@@ -1,173 +1,173 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Postgres Result Class
- *
- * This class extends the parent result class: CI_DB_result
- *
- * @category Database
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/database/
- */
-class CI_DB_postgre_result extends CI_DB_result {
-
- /**
- * Number of rows in the result set
- *
- * @access public
- * @return integer
- */
- function num_rows()
- {
- return @pg_num_rows($this->result_id);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Number of fields in the result set
- *
- * @access public
- * @return integer
- */
- function num_fields()
- {
- return @pg_num_fields($this->result_id);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Fetch Field Names
- *
- * Generates an array of column names
- *
- * @access public
- * @return array
- */
- function list_fields()
- {
- $field_names = array();
- for ($i = 0; $i < $this->num_fields(); $i++)
- {
- $Ffield_names[] = pg_field_name($this->result_id, $i);
- }
-
- return $field_names;
- }
-
- // Deprecated
- function field_names()
- {
- return $this->list_fields();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Field data
- *
- * Generates an array of objects containing field meta-data
- *
- * @access public
- * @return array
- */
- function field_data()
- {
- $retval = array();
- for ($i = 0; $i < $this->num_fields(); $i++)
- {
- $F = new stdClass();
- $F->name = pg_field_name($this->result_id, $i);
- $F->type = pg_field_type($this->result_id, $i);
- $F->max_length = pg_field_size($this->result_id, $i);
- $F->primary_key = $i == 0;
- $F->default = '';
-
- $retval[] = $F;
- }
-
- return $retval;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Free the result
- *
- * @return null
- */
- function free_result()
- {
- if (is_resource($this->result_id))
- {
- pg_free_result($this->result_id);
- $this->result_id = FALSE;
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Data Seek
- *
- * Moves the internal pointer to the desired offset. We call
- * this internally before fetching results to make sure the
- * result set starts at zero
- *
- * @access private
- * @return array
- */
- function _data_seek($n = 0)
- {
- return pg_result_seek($this->result_id, $n);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Result - associative array
- *
- * Returns the result set as an array
- *
- * @access private
- * @return array
- */
- function _fetch_assoc()
- {
- return pg_fetch_assoc($this->result_id);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Result - object
- *
- * Returns the result set as an object
- *
- * @access private
- * @return object
- */
- function _fetch_object()
- {
- return pg_fetch_object($this->result_id);
- }
-
-}
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Postgres Result Class
+ *
+ * This class extends the parent result class: CI_DB_result
+ *
+ * @category Database
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/database/
+ */
+class CI_DB_postgre_result extends CI_DB_result {
+
+ /**
+ * Number of rows in the result set
+ *
+ * @access public
+ * @return integer
+ */
+ function num_rows()
+ {
+ return @pg_num_rows($this->result_id);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Number of fields in the result set
+ *
+ * @access public
+ * @return integer
+ */
+ function num_fields()
+ {
+ return @pg_num_fields($this->result_id);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch Field Names
+ *
+ * Generates an array of column names
+ *
+ * @access public
+ * @return array
+ */
+ function list_fields()
+ {
+ $field_names = array();
+ for ($i = 0; $i < $this->num_fields(); $i++)
+ {
+ $Ffield_names[] = pg_field_name($this->result_id, $i);
+ }
+
+ return $field_names;
+ }
+
+ // Deprecated
+ function field_names()
+ {
+ return $this->list_fields();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Field data
+ *
+ * Generates an array of objects containing field meta-data
+ *
+ * @access public
+ * @return array
+ */
+ function field_data()
+ {
+ $retval = array();
+ for ($i = 0; $i < $this->num_fields(); $i++)
+ {
+ $F = new stdClass();
+ $F->name = pg_field_name($this->result_id, $i);
+ $F->type = pg_field_type($this->result_id, $i);
+ $F->max_length = pg_field_size($this->result_id, $i);
+ $F->primary_key = $i == 0;
+ $F->default = '';
+
+ $retval[] = $F;
+ }
+
+ return $retval;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Free the result
+ *
+ * @return null
+ */
+ function free_result()
+ {
+ if (is_resource($this->result_id))
+ {
+ pg_free_result($this->result_id);
+ $this->result_id = FALSE;
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Data Seek
+ *
+ * Moves the internal pointer to the desired offset. We call
+ * this internally before fetching results to make sure the
+ * result set starts at zero
+ *
+ * @access private
+ * @return array
+ */
+ function _data_seek($n = 0)
+ {
+ return pg_result_seek($this->result_id, $n);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Result - associative array
+ *
+ * Returns the result set as an array
+ *
+ * @access private
+ * @return array
+ */
+ function _fetch_assoc()
+ {
+ return pg_fetch_assoc($this->result_id);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Result - object
+ *
+ * Returns the result set as an object
+ *
+ * @access private
+ * @return object
+ */
+ function _fetch_object()
+ {
+ return pg_fetch_object($this->result_id);
+ }
+
+}
+
?> \ No newline at end of file
diff --git a/system/database/drivers/postgre/postgre_utility.php b/system/database/drivers/postgre/postgre_utility.php
index bebe09415..9d56af363 100644
--- a/system/database/drivers/postgre/postgre_utility.php
+++ b/system/database/drivers/postgre/postgre_utility.php
@@ -1,129 +1,129 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Postgre Utility Class
- *
- * @category Database
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/database/
- */
-class CI_DB_postgre_utility extends CI_DB_utility {
-
-
- /**
- * 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;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * List databases
- *
- * @access private
- * @return bool
- */
- function _list_databases()
- {
- return "SELECT datname FROM pg_database";
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Drop Table
- *
- * @access private
- * @return bool
- */
- function _drop_table($table)
- {
- return "DROP TABLE ".$this->db->_escape_table($table)." CASCADE";
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Optimize table query
- *
- * Is table optimization supported in Postgre?
- *
- * @access private
- * @param string the table name
- * @return object
- */
- function _optimize_table($table)
- {
- return FALSE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Repair table query
- *
- * Are table repairs supported in Postgre?
- *
- * @access private
- * @param string the table name
- * @return object
- */
- function _repair_table($table)
- {
- return FALSE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Postgre Export
- *
- * @access private
- * @param array Preferences
- * @return mixed
- */
- function _backup($params = array())
- {
- // Currently unsupported
- return $this->db->display_error('db_unsuported_feature');
- }
-
-}
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Postgre Utility Class
+ *
+ * @category Database
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/database/
+ */
+class CI_DB_postgre_utility extends CI_DB_utility {
+
+
+ /**
+ * 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;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * List databases
+ *
+ * @access private
+ * @return bool
+ */
+ function _list_databases()
+ {
+ return "SELECT datname FROM pg_database";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop Table
+ *
+ * @access private
+ * @return bool
+ */
+ function _drop_table($table)
+ {
+ return "DROP TABLE ".$this->db->_escape_table($table)." CASCADE";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Optimize table query
+ *
+ * Is table optimization supported in Postgre?
+ *
+ * @access private
+ * @param string the table name
+ * @return object
+ */
+ function _optimize_table($table)
+ {
+ return FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Repair table query
+ *
+ * Are table repairs supported in Postgre?
+ *
+ * @access private
+ * @param string the table name
+ * @return object
+ */
+ function _repair_table($table)
+ {
+ return FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Postgre Export
+ *
+ * @access private
+ * @param array Preferences
+ * @return mixed
+ */
+ function _backup($params = array())
+ {
+ // Currently unsupported
+ return $this->db->display_error('db_unsuported_feature');
+ }
+
+}
+
?> \ No newline at end of file
diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php
index 877f445bb..b82618c6a 100644
--- a/system/database/drivers/sqlite/sqlite_driver.php
+++ b/system/database/drivers/sqlite/sqlite_driver.php
@@ -1,484 +1,484 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-
-
-/**
- * SQLite Database Adapter Class
- *
- * Note: _DB is an extender class that the app controller
- * creates dynamically based on whether the active record
- * class is being used or not.
- *
- * @package CodeIgniter
- * @subpackage Drivers
- * @category Database
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/database/
- */
-class CI_DB_sqlite_driver extends CI_DB {
-
- /**
- * Non-persistent database connection
- *
- * @access private called by the base class
- * @return resource
- */
- function db_connect()
- {
- if ( ! $conn_id = @sqlite_open($this->database, 0666, $error))
- {
- log_message('error', $error);
-
- if ($this->db_debug)
- {
- $this->display_error($error, '', TRUE);
- }
-
- return FALSE;
- }
-
- return $conn_id;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Persistent database connection
- *
- * @access private called by the base class
- * @return resource
- */
- function db_pconnect()
- {
- if ( ! $conn_id = @sqlite_popen($this->database, 0666, $error))
- {
- log_message('error', $error);
-
- if ($this->db_debug)
- {
- $this->display_error($error, '', TRUE);
- }
-
- return FALSE;
- }
-
- return $conn_id;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Select the database
- *
- * @access private called by the base class
- * @return resource
- */
- function db_select()
- {
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Version number query string
- *
- * @access public
- * @return string
- */
- function _version()
- {
- return sqlite_libversion();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Execute the query
- *
- * @access private called by the base class
- * @param string an SQL query
- * @return resource
- */
- function _execute($sql)
- {
- $sql = $this->_prep_query($sql);
- return @sqlite_query($this->conn_id, $sql);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Prep the query
- *
- * If needed, each database adapter can prep the query string
- *
- * @access private called by execute()
- * @param string an SQL query
- * @return string
- */
- function _prep_query($sql)
- {
- return $sql;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Begin Transaction
- *
- * @access public
- * @return bool
- */
- function trans_begin($test_mode = FALSE)
- {
- if ( ! $this->trans_enabled)
- {
- return TRUE;
- }
-
- // When transactions are nested we only begin/commit/rollback the outermost ones
- if ($this->_trans_depth > 0)
- {
- return TRUE;
- }
-
- // Reset the transaction failure flag.
- // If the $test_mode flag is set to TRUE transactions will be rolled back
- // even if the queries produce a successful result.
- $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
-
- $this->simple_query('BEGIN TRANSACTION');
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Commit Transaction
- *
- * @access public
- * @return bool
- */
- function trans_commit()
- {
- if ( ! $this->trans_enabled)
- {
- return TRUE;
- }
-
- // When transactions are nested we only begin/commit/rollback the outermost ones
- if ($this->_trans_depth > 0)
- {
- return TRUE;
- }
-
- $this->simple_query('COMMIT');
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Rollback Transaction
- *
- * @access public
- * @return bool
- */
- function trans_rollback()
- {
- if ( ! $this->trans_enabled)
- {
- return TRUE;
- }
-
- // When transactions are nested we only begin/commit/rollback the outermost ones
- if ($this->_trans_depth > 0)
- {
- return TRUE;
- }
-
- $this->simple_query('ROLLBACK');
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Escape String
- *
- * @access public
- * @param string
- * @return string
- */
- function escape_str($str)
- {
- return sqlite_escape_string($str);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Affected Rows
- *
- * @access public
- * @return integer
- */
- function affected_rows()
- {
- return sqlite_changes($this->conn_id);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Insert ID
- *
- * @access public
- * @return integer
- */
- function insert_id()
- {
- return @sqlite_last_insert_rowid($this->conn_id);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * "Count All" query
- *
- * Generates a platform-specific query string that counts all records in
- * the specified database
- *
- * @access public
- * @param string
- * @return string
- */
- function count_all($table = '')
- {
- if ($table == '')
- return '0';
-
- $query = $this->query("SELECT COUNT(*) AS numrows FROM `".$this->dbprefix.$table."`");
-
- if ($query->num_rows() == 0)
- return '0';
-
- $row = $query->row();
- return $row->numrows;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * List table query
- *
- * Generates a platform-specific query string so that the table names can be fetched
- *
- * @access private
- * @return string
- */
- function _list_tables()
- {
- return "SELECT name from sqlite_master WHERE type='table'";
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Show column query
- *
- * Generates a platform-specific query string so that the column names can be fetched
- *
- * @access public
- * @param string the table name
- * @return string
- */
- function _list_columns($table = '')
- {
- // Not supported
- return FALSE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Field data query
- *
- * Generates a platform-specific query so that the column data can be retrieved
- *
- * @access public
- * @param string the table name
- * @return object
- */
- function _field_data($table)
- {
- return "SELECT * FROM ".$this->_escape_table($table)." LIMIT 1";
- }
-
- // --------------------------------------------------------------------
-
- /**
- * The error message string
- *
- * @access private
- * @return string
- */
- function _error_message()
- {
- return sqlite_error_string(sqlite_last_error($this->conn_id));
- }
-
- // --------------------------------------------------------------------
-
- /**
- * The error message number
- *
- * @access private
- * @return integer
- */
- function _error_number()
- {
- return sqlite_last_error($this->conn_id);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Escape Table Name
- *
- * This function adds backticks if the table name has a period
- * in it. Some DBs will get cranky unless periods are escaped
- *
- * @access private
- * @param string the table name
- * @return string
- */
- function _escape_table($table)
- {
- if (stristr($table, '.'))
- {
- $table = preg_replace("/\./", "`.`", $table);
- }
-
- return $table;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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 ".$this->_escape_table($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
- * @return string
- */
- function _update($table, $values, $where)
- {
- foreach($values as $key => $val)
- {
- $valstr[] = $key." = ".$val;
- }
-
- return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Delete statement
- *
- * Generates a platform-specific delete string from the supplied data
- *
- * @access public
- * @param string the table name
- * @param array the where clause
- * @return string
- */
- function _delete($table, $where)
- {
- return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Limit string
- *
- * Generates a platform-specific LIMIT clause
- *
- * @access public
- * @param string the sql query string
- * @param integer the number of rows to limit the query to
- * @param integer the offset value
- * @return string
- */
- function _limit($sql, $limit, $offset)
- {
- if ($offset == 0)
- {
- $offset = '';
- }
- else
- {
- $offset .= ", ";
- }
-
- return $sql."LIMIT ".$offset.$limit;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Close DB Connection
- *
- * @access public
- * @param resource
- * @return void
- */
- function _close($conn_id)
- {
- @sqlite_close($conn_id);
- }
-
-
-}
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+
+
+/**
+ * SQLite Database Adapter Class
+ *
+ * Note: _DB is an extender class that the app controller
+ * creates dynamically based on whether the active record
+ * class is being used or not.
+ *
+ * @package CodeIgniter
+ * @subpackage Drivers
+ * @category Database
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/database/
+ */
+class CI_DB_sqlite_driver extends CI_DB {
+
+ /**
+ * Non-persistent database connection
+ *
+ * @access private called by the base class
+ * @return resource
+ */
+ function db_connect()
+ {
+ if ( ! $conn_id = @sqlite_open($this->database, 0666, $error))
+ {
+ log_message('error', $error);
+
+ if ($this->db_debug)
+ {
+ $this->display_error($error, '', TRUE);
+ }
+
+ return FALSE;
+ }
+
+ return $conn_id;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Persistent database connection
+ *
+ * @access private called by the base class
+ * @return resource
+ */
+ function db_pconnect()
+ {
+ if ( ! $conn_id = @sqlite_popen($this->database, 0666, $error))
+ {
+ log_message('error', $error);
+
+ if ($this->db_debug)
+ {
+ $this->display_error($error, '', TRUE);
+ }
+
+ return FALSE;
+ }
+
+ return $conn_id;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Select the database
+ *
+ * @access private called by the base class
+ * @return resource
+ */
+ function db_select()
+ {
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Version number query string
+ *
+ * @access public
+ * @return string
+ */
+ function _version()
+ {
+ return sqlite_libversion();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Execute the query
+ *
+ * @access private called by the base class
+ * @param string an SQL query
+ * @return resource
+ */
+ function _execute($sql)
+ {
+ $sql = $this->_prep_query($sql);
+ return @sqlite_query($this->conn_id, $sql);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Prep the query
+ *
+ * If needed, each database adapter can prep the query string
+ *
+ * @access private called by execute()
+ * @param string an SQL query
+ * @return string
+ */
+ function _prep_query($sql)
+ {
+ return $sql;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Begin Transaction
+ *
+ * @access public
+ * @return bool
+ */
+ function trans_begin($test_mode = FALSE)
+ {
+ if ( ! $this->trans_enabled)
+ {
+ return TRUE;
+ }
+
+ // When transactions are nested we only begin/commit/rollback the outermost ones
+ if ($this->_trans_depth > 0)
+ {
+ return TRUE;
+ }
+
+ // Reset the transaction failure flag.
+ // If the $test_mode flag is set to TRUE transactions will be rolled back
+ // even if the queries produce a successful result.
+ $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
+
+ $this->simple_query('BEGIN TRANSACTION');
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Commit Transaction
+ *
+ * @access public
+ * @return bool
+ */
+ function trans_commit()
+ {
+ if ( ! $this->trans_enabled)
+ {
+ return TRUE;
+ }
+
+ // When transactions are nested we only begin/commit/rollback the outermost ones
+ if ($this->_trans_depth > 0)
+ {
+ return TRUE;
+ }
+
+ $this->simple_query('COMMIT');
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Rollback Transaction
+ *
+ * @access public
+ * @return bool
+ */
+ function trans_rollback()
+ {
+ if ( ! $this->trans_enabled)
+ {
+ return TRUE;
+ }
+
+ // When transactions are nested we only begin/commit/rollback the outermost ones
+ if ($this->_trans_depth > 0)
+ {
+ return TRUE;
+ }
+
+ $this->simple_query('ROLLBACK');
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Escape String
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function escape_str($str)
+ {
+ return sqlite_escape_string($str);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Affected Rows
+ *
+ * @access public
+ * @return integer
+ */
+ function affected_rows()
+ {
+ return sqlite_changes($this->conn_id);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Insert ID
+ *
+ * @access public
+ * @return integer
+ */
+ function insert_id()
+ {
+ return @sqlite_last_insert_rowid($this->conn_id);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * "Count All" query
+ *
+ * Generates a platform-specific query string that counts all records in
+ * the specified database
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function count_all($table = '')
+ {
+ if ($table == '')
+ return '0';
+
+ $query = $this->query("SELECT COUNT(*) AS numrows FROM `".$this->dbprefix.$table."`");
+
+ if ($query->num_rows() == 0)
+ return '0';
+
+ $row = $query->row();
+ return $row->numrows;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * List table query
+ *
+ * Generates a platform-specific query string so that the table names can be fetched
+ *
+ * @access private
+ * @return string
+ */
+ function _list_tables()
+ {
+ return "SELECT name from sqlite_master WHERE type='table'";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Show column query
+ *
+ * Generates a platform-specific query string so that the column names can be fetched
+ *
+ * @access public
+ * @param string the table name
+ * @return string
+ */
+ function _list_columns($table = '')
+ {
+ // Not supported
+ return FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Field data query
+ *
+ * Generates a platform-specific query so that the column data can be retrieved
+ *
+ * @access public
+ * @param string the table name
+ * @return object
+ */
+ function _field_data($table)
+ {
+ return "SELECT * FROM ".$this->_escape_table($table)." LIMIT 1";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * The error message string
+ *
+ * @access private
+ * @return string
+ */
+ function _error_message()
+ {
+ return sqlite_error_string(sqlite_last_error($this->conn_id));
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * The error message number
+ *
+ * @access private
+ * @return integer
+ */
+ function _error_number()
+ {
+ return sqlite_last_error($this->conn_id);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Escape Table Name
+ *
+ * This function adds backticks if the table name has a period
+ * in it. Some DBs will get cranky unless periods are escaped
+ *
+ * @access private
+ * @param string the table name
+ * @return string
+ */
+ function _escape_table($table)
+ {
+ if (stristr($table, '.'))
+ {
+ $table = preg_replace("/\./", "`.`", $table);
+ }
+
+ return $table;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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 ".$this->_escape_table($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
+ * @return string
+ */
+ function _update($table, $values, $where)
+ {
+ foreach($values as $key => $val)
+ {
+ $valstr[] = $key." = ".$val;
+ }
+
+ return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Delete statement
+ *
+ * Generates a platform-specific delete string from the supplied data
+ *
+ * @access public
+ * @param string the table name
+ * @param array the where clause
+ * @return string
+ */
+ function _delete($table, $where)
+ {
+ return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Limit string
+ *
+ * Generates a platform-specific LIMIT clause
+ *
+ * @access public
+ * @param string the sql query string
+ * @param integer the number of rows to limit the query to
+ * @param integer the offset value
+ * @return string
+ */
+ function _limit($sql, $limit, $offset)
+ {
+ if ($offset == 0)
+ {
+ $offset = '';
+ }
+ else
+ {
+ $offset .= ", ";
+ }
+
+ return $sql."LIMIT ".$offset.$limit;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Close DB Connection
+ *
+ * @access public
+ * @param resource
+ * @return void
+ */
+ function _close($conn_id)
+ {
+ @sqlite_close($conn_id);
+ }
+
+
+}
+
?> \ No newline at end of file
diff --git a/system/database/drivers/sqlite/sqlite_result.php b/system/database/drivers/sqlite/sqlite_result.php
index a406a935c..a16a5b054 100644
--- a/system/database/drivers/sqlite/sqlite_result.php
+++ b/system/database/drivers/sqlite/sqlite_result.php
@@ -1,176 +1,176 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * SQLite Result Class
- *
- * This class extends the parent result class: CI_DB_result
- *
- * @category Database
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/database/
- */
-class CI_DB_sqlite_result extends CI_DB_result {
-
- /**
- * Number of rows in the result set
- *
- * @access public
- * @return integer
- */
- function num_rows()
- {
- return @sqlite_num_rows($this->result_id);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Number of fields in the result set
- *
- * @access public
- * @return integer
- */
- function num_fields()
- {
- return @sqlite_num_fields($this->result_id);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Fetch Field Names
- *
- * Generates an array of column names
- *
- * @access public
- * @return array
- */
- function list_fields()
- {
- $field_names = array();
- for ($i = 0; $i < $this->num_fields(); $i++)
- {
- $Ffield_names[] = sqlite_field_name($this->result_id, $i);
- }
-
- return $field_names;
- }
-
- // Deprecated
- function field_names()
- {
- return $this->list_fields();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Field data
- *
- * Generates an array of objects containing field meta-data
- *
- * @access public
- * @return array
- */
- function field_data()
- {
- $retval = array();
- for ($i = 0; $i < $this->num_fields(); $i++)
- {
- $F = new stdClass();
- $F->name = sqlite_field_name($this->result_id, $i);
- $F->type = 'varchar';
- $F->max_length = 0;
- $F->primary_key = 0;
- $F->default = '';
-
- $retval[] = $F;
- }
-
- return $retval;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Free the result
- *
- * @return null
- */
- function free_result()
- {
- // Not implemented in SQLite
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Data Seek
- *
- * Moves the internal pointer to the desired offset. We call
- * this internally before fetching results to make sure the
- * result set starts at zero
- *
- * @access private
- * @return array
- */
- function _data_seek($n = 0)
- {
- return sqlite_seek($this->result_id, $n);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Result - associative array
- *
- * Returns the result set as an array
- *
- * @access private
- * @return array
- */
- function _fetch_assoc()
- {
- return sqlite_fetch_array($this->result_id);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Result - object
- *
- * Returns the result set as an object
- *
- * @access private
- * @return object
- */
- function _fetch_object()
- {
- if (function_exists('sqlite_fetch_object'))
- {
- return sqlite_fetch_object($this->result_id);
- }
- else
- {
- return $this->_fetch_assoc();
- }
- }
-
-}
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * SQLite Result Class
+ *
+ * This class extends the parent result class: CI_DB_result
+ *
+ * @category Database
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/database/
+ */
+class CI_DB_sqlite_result extends CI_DB_result {
+
+ /**
+ * Number of rows in the result set
+ *
+ * @access public
+ * @return integer
+ */
+ function num_rows()
+ {
+ return @sqlite_num_rows($this->result_id);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Number of fields in the result set
+ *
+ * @access public
+ * @return integer
+ */
+ function num_fields()
+ {
+ return @sqlite_num_fields($this->result_id);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch Field Names
+ *
+ * Generates an array of column names
+ *
+ * @access public
+ * @return array
+ */
+ function list_fields()
+ {
+ $field_names = array();
+ for ($i = 0; $i < $this->num_fields(); $i++)
+ {
+ $Ffield_names[] = sqlite_field_name($this->result_id, $i);
+ }
+
+ return $field_names;
+ }
+
+ // Deprecated
+ function field_names()
+ {
+ return $this->list_fields();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Field data
+ *
+ * Generates an array of objects containing field meta-data
+ *
+ * @access public
+ * @return array
+ */
+ function field_data()
+ {
+ $retval = array();
+ for ($i = 0; $i < $this->num_fields(); $i++)
+ {
+ $F = new stdClass();
+ $F->name = sqlite_field_name($this->result_id, $i);
+ $F->type = 'varchar';
+ $F->max_length = 0;
+ $F->primary_key = 0;
+ $F->default = '';
+
+ $retval[] = $F;
+ }
+
+ return $retval;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Free the result
+ *
+ * @return null
+ */
+ function free_result()
+ {
+ // Not implemented in SQLite
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Data Seek
+ *
+ * Moves the internal pointer to the desired offset. We call
+ * this internally before fetching results to make sure the
+ * result set starts at zero
+ *
+ * @access private
+ * @return array
+ */
+ function _data_seek($n = 0)
+ {
+ return sqlite_seek($this->result_id, $n);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Result - associative array
+ *
+ * Returns the result set as an array
+ *
+ * @access private
+ * @return array
+ */
+ function _fetch_assoc()
+ {
+ return sqlite_fetch_array($this->result_id);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Result - object
+ *
+ * Returns the result set as an object
+ *
+ * @access private
+ * @return object
+ */
+ function _fetch_object()
+ {
+ if (function_exists('sqlite_fetch_object'))
+ {
+ return sqlite_fetch_object($this->result_id);
+ }
+ else
+ {
+ return $this->_fetch_assoc();
+ }
+ }
+
+}
+
?> \ No newline at end of file
diff --git a/system/database/drivers/sqlite/sqlite_utility.php b/system/database/drivers/sqlite/sqlite_utility.php
index 91649c78d..9683b1756 100644
--- a/system/database/drivers/sqlite/sqlite_utility.php
+++ b/system/database/drivers/sqlite/sqlite_utility.php
@@ -1,154 +1,154 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * SQLite Utility Class
- *
- * @category Database
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/database/
- */
-class CI_DB_sqlite_utility extends CI_DB_utility {
-
-
- /**
- * Create database
- *
- * @access public
- * @param string the database name
- * @return bool
- */
- function _create_database()
- {
- // In SQLite, a database is created when you connect to the database.
- // We'll return TRUE so that an error isn't generated
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Drop database
- *
- * @access private
- * @param string the database name
- * @return bool
- */
- function _drop_database($name)
- {
- if ( ! @file_exists($this->db->database) OR ! @unlink($this->db->database))
- {
- if ($this->db->db_debug)
- {
- return $this->db->display_error('db_unable_to_drop');
- }
- return FALSE;
- }
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * List databases
- *
- * I don't believe you can do a database listing with SQLite
- * since each database is its own file. I suppose we could
- * try reading a directory looking for SQLite files, but
- * that doesn't seem like a terribly good idea
- *
- * @access private
- * @return bool
- */
- function _list_databases()
- {
- if ($this->db_debug)
- {
- return $this->display_error('db_unsuported_feature');
- }
- return array();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Drop Table
- *
- * Unsupported feature in SQLite
- *
- * @access private
- * @return bool
- */
- function _drop_table($table)
- {
- if ($this->db->db_debug)
- {
- return $this->db->display_error('db_unsuported_feature');
- }
- return array();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Optimize table query
- *
- * Is optimization even supported in SQLite?
- *
- * @access private
- * @param string the table name
- * @return object
- */
- function _optimize_table($table)
- {
- return FALSE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Repair table query
- *
- * Are table repairs even supported in SQLite?
- *
- * @access private
- * @param string the table name
- * @return object
- */
- function _repair_table($table)
- {
- return FALSE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * SQLite Export
- *
- * @access private
- * @param array Preferences
- * @return mixed
- */
- function _backup($params = array())
- {
- // Currently unsupported
- return $this->db->display_error('db_unsuported_feature');
- }
-
-}
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * SQLite Utility Class
+ *
+ * @category Database
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/database/
+ */
+class CI_DB_sqlite_utility extends CI_DB_utility {
+
+
+ /**
+ * Create database
+ *
+ * @access public
+ * @param string the database name
+ * @return bool
+ */
+ function _create_database()
+ {
+ // In SQLite, a database is created when you connect to the database.
+ // We'll return TRUE so that an error isn't generated
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop database
+ *
+ * @access private
+ * @param string the database name
+ * @return bool
+ */
+ function _drop_database($name)
+ {
+ if ( ! @file_exists($this->db->database) OR ! @unlink($this->db->database))
+ {
+ if ($this->db->db_debug)
+ {
+ return $this->db->display_error('db_unable_to_drop');
+ }
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * List databases
+ *
+ * I don't believe you can do a database listing with SQLite
+ * since each database is its own file. I suppose we could
+ * try reading a directory looking for SQLite files, but
+ * that doesn't seem like a terribly good idea
+ *
+ * @access private
+ * @return bool
+ */
+ function _list_databases()
+ {
+ if ($this->db_debug)
+ {
+ return $this->display_error('db_unsuported_feature');
+ }
+ return array();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop Table
+ *
+ * Unsupported feature in SQLite
+ *
+ * @access private
+ * @return bool
+ */
+ function _drop_table($table)
+ {
+ if ($this->db->db_debug)
+ {
+ return $this->db->display_error('db_unsuported_feature');
+ }
+ return array();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Optimize table query
+ *
+ * Is optimization even supported in SQLite?
+ *
+ * @access private
+ * @param string the table name
+ * @return object
+ */
+ function _optimize_table($table)
+ {
+ return FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Repair table query
+ *
+ * Are table repairs even supported in SQLite?
+ *
+ * @access private
+ * @param string the table name
+ * @return object
+ */
+ function _repair_table($table)
+ {
+ return FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * SQLite Export
+ *
+ * @access private
+ * @param array Preferences
+ * @return mixed
+ */
+ function _backup($params = array())
+ {
+ // Currently unsupported
+ return $this->db->display_error('db_unsuported_feature');
+ }
+
+}
+
?> \ No newline at end of file
diff --git a/system/helpers/array_helper.php b/system/helpers/array_helper.php
index 491c61577..674ef3bec 100644
--- a/system/helpers/array_helper.php
+++ b/system/helpers/array_helper.php
@@ -1,71 +1,71 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Igniter Array Helpers
- *
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/helpers/array_helper.html
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Element
- *
- * Lets you determine whether an array index is set and whether it has a value.
- * If the element is empty it returns FALSE (or whatever you specify as the default value.)
- *
- * @access public
- * @param string
- * @param array
- * @param mixed
- * @return mixed depends on what the array contains
- */
-function element($item, $array, $default = FALSE)
-{
- if ( ! isset($array[$item]) OR $array[$item] == "")
- {
- return $default;
- }
-
- return $array[$item];
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Random Element - Takes an array as input and returns a random element
- *
- * @access public
- * @param array
- * @return mixed depends on what the array contains
- */
-function random_element($array)
-{
- if ( ! is_array($array))
- {
- return $array;
- }
- return $array[array_rand($array)];
-}
-
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Array Helpers
+ *
+ * @package CodeIgniter
+ * @subpackage Helpers
+ * @category Helpers
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/helpers/array_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Element
+ *
+ * Lets you determine whether an array index is set and whether it has a value.
+ * If the element is empty it returns FALSE (or whatever you specify as the default value.)
+ *
+ * @access public
+ * @param string
+ * @param array
+ * @param mixed
+ * @return mixed depends on what the array contains
+ */
+function element($item, $array, $default = FALSE)
+{
+ if ( ! isset($array[$item]) OR $array[$item] == "")
+ {
+ return $default;
+ }
+
+ return $array[$item];
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Random Element - Takes an array as input and returns a random element
+ *
+ * @access public
+ * @param array
+ * @return mixed depends on what the array contains
+ */
+function random_element($array)
+{
+ if ( ! is_array($array))
+ {
+ return $array;
+ }
+ return $array[array_rand($array)];
+}
+
+
?> \ No newline at end of file
diff --git a/system/helpers/cookie_helper.php b/system/helpers/cookie_helper.php
index b117816e2..9dc5df9b1 100644
--- a/system/helpers/cookie_helper.php
+++ b/system/helpers/cookie_helper.php
@@ -1,126 +1,126 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Igniter Cookie Helpers
- *
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/helpers/cookie_helper.html
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Set cookie
- *
- * Accepts six parameter, or you can submit an associative
- * array in the first parameter containing all the values.
- *
- * @access public
- * @param mixed
- * @param string the value of the cookie
- * @param string the number of seconds until expiration
- * @param string the cookie domain. Usually: .yourdomain.com
- * @param string the cookie path
- * @param string the cookie prefix
- * @return void
- */
-function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '')
-{
- if (is_array($name))
- {
- foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'name') as $item)
- {
- if (isset($name[$item]))
- {
- $$item = $name[$item];
- }
- }
- }
-
- // Set the config file options
- $CI =& get_instance();
-
- if ($prefix == '' AND $CI->config->item('cookie_prefix') != '')
- {
- $CI->config->item('cookie_prefix');
- }
- if ($domain == '' AND $CI->config->item('cookie_domain') != '')
- {
- $CI->config->item('cookie_domain');
- }
- if ($prefix == '/' AND $CI->config->item('cookie_path') != '/')
- {
- $CI->config->item('cookie_path');
- }
-
- if ( ! is_numeric($expire))
- {
- $expire = time() - 86500;
- }
- else
- {
- if ($expire > 0)
- {
- $expire = time() + $expire;
- }
- else
- {
- $expire = 0;
- }
- }
-
- setcookie($prefix.$name, $value, $expire, $path, $domain, 0);
-}
-
-// --------------------------------------------------------------------
-
-/**
- * Fetch an item from the COOKIE array
- *
- * @access public
- * @param string
- * @param bool
- * @return mixed
- */
-function get_cookie($index = '', $xss_clean = FALSE)
-{
- $CI =& get_instance();
- return $CI->input->cookie($index, $xss_clean);
-}
-
-// --------------------------------------------------------------------
-
-/**
- * Delete a COOKIE
- *
- * @param mixed
- * @param string the cookie domain. Usually: .yourdomain.com
- * @param string the cookie path
- * @param string the cookie prefix
- * @return void
- */
-function delete_cookie($name = '', $domain = '', $path = '/', $prefix = '')
-{
- set_cookie($name, '', '', $domain, $path, $prefix);
-}
-
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Cookie Helpers
+ *
+ * @package CodeIgniter
+ * @subpackage Helpers
+ * @category Helpers
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/helpers/cookie_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Set cookie
+ *
+ * Accepts six parameter, or you can submit an associative
+ * array in the first parameter containing all the values.
+ *
+ * @access public
+ * @param mixed
+ * @param string the value of the cookie
+ * @param string the number of seconds until expiration
+ * @param string the cookie domain. Usually: .yourdomain.com
+ * @param string the cookie path
+ * @param string the cookie prefix
+ * @return void
+ */
+function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '')
+{
+ if (is_array($name))
+ {
+ foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'name') as $item)
+ {
+ if (isset($name[$item]))
+ {
+ $$item = $name[$item];
+ }
+ }
+ }
+
+ // Set the config file options
+ $CI =& get_instance();
+
+ if ($prefix == '' AND $CI->config->item('cookie_prefix') != '')
+ {
+ $CI->config->item('cookie_prefix');
+ }
+ if ($domain == '' AND $CI->config->item('cookie_domain') != '')
+ {
+ $CI->config->item('cookie_domain');
+ }
+ if ($prefix == '/' AND $CI->config->item('cookie_path') != '/')
+ {
+ $CI->config->item('cookie_path');
+ }
+
+ if ( ! is_numeric($expire))
+ {
+ $expire = time() - 86500;
+ }
+ else
+ {
+ if ($expire > 0)
+ {
+ $expire = time() + $expire;
+ }
+ else
+ {
+ $expire = 0;
+ }
+ }
+
+ setcookie($prefix.$name, $value, $expire, $path, $domain, 0);
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Fetch an item from the COOKIE array
+ *
+ * @access public
+ * @param string
+ * @param bool
+ * @return mixed
+ */
+function get_cookie($index = '', $xss_clean = FALSE)
+{
+ $CI =& get_instance();
+ return $CI->input->cookie($index, $xss_clean);
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Delete a COOKIE
+ *
+ * @param mixed
+ * @param string the cookie domain. Usually: .yourdomain.com
+ * @param string the cookie path
+ * @param string the cookie prefix
+ * @return void
+ */
+function delete_cookie($name = '', $domain = '', $path = '/', $prefix = '')
+{
+ set_cookie($name, '', '', $domain, $path, $prefix);
+}
+
+
?> \ No newline at end of file
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
index 504a962ce..c67e3da2d 100644
--- a/system/helpers/date_helper.php
+++ b/system/helpers/date_helper.php
@@ -1,12 +1,12 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
- * Code Igniter
+ * CodeIgniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
* @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
* @license http://www.codeignitor.com/user_guide/license.html
* @link http://www.codeigniter.com
* @since Version 1.0
@@ -16,7 +16,7 @@
// ------------------------------------------------------------------------
/**
- * Code Igniter Date Helpers
+ * CodeIgniter Date Helpers
*
* @package CodeIgniter
* @subpackage Helpers
diff --git a/system/helpers/directory_helper.php b/system/helpers/directory_helper.php
index ad868519d..71f3778a1 100644
--- a/system/helpers/directory_helper.php
+++ b/system/helpers/directory_helper.php
@@ -1,67 +1,67 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Igniter Directory Helpers
- *
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/helpers/directory_helper.html
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Create a Directory Map
- *
- * Reads the specified directory and builds an array
- * representation of it. Sub-folders contained with the
- * directory will be mapped as well.
- *
- * @access public
- * @param string path to source
- * @param bool whether to limit the result to the top level only
- * @return array
- */
-function directory_map($source_dir, $top_level_only = FALSE)
-{
- if ($fp = @opendir($source_dir))
- {
- $filedata = array();
- while (FALSE !== ($file = readdir($fp)))
- {
- if (@is_dir($source_dir.$file) && substr($file, 0, 1) != '.' AND $top_level_only == FALSE)
- {
- $temp_array = array();
-
- $temp_array = directory_map($source_dir.$file."/");
-
- $filedata[$file] = $temp_array;
- }
- elseif (substr($file, 0, 1) != ".")
- {
- $filedata[] = $file;
- }
- }
- return $filedata;
- }
-}
-
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Directory Helpers
+ *
+ * @package CodeIgniter
+ * @subpackage Helpers
+ * @category Helpers
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/helpers/directory_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Create a Directory Map
+ *
+ * Reads the specified directory and builds an array
+ * representation of it. Sub-folders contained with the
+ * directory will be mapped as well.
+ *
+ * @access public
+ * @param string path to source
+ * @param bool whether to limit the result to the top level only
+ * @return array
+ */
+function directory_map($source_dir, $top_level_only = FALSE)
+{
+ if ($fp = @opendir($source_dir))
+ {
+ $filedata = array();
+ while (FALSE !== ($file = readdir($fp)))
+ {
+ if (@is_dir($source_dir.$file) && substr($file, 0, 1) != '.' AND $top_level_only == FALSE)
+ {
+ $temp_array = array();
+
+ $temp_array = directory_map($source_dir.$file."/");
+
+ $filedata[$file] = $temp_array;
+ }
+ elseif (substr($file, 0, 1) != ".")
+ {
+ $filedata[] = $file;
+ }
+ }
+ return $filedata;
+ }
+}
+
+
?> \ No newline at end of file
diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php
index 34cc152cc..c9d81f692 100644
--- a/system/helpers/download_helper.php
+++ b/system/helpers/download_helper.php
@@ -1,12 +1,12 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
- * Code Igniter
+ * CodeIgniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
* @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
* @license http://www.codeignitor.com/user_guide/license.html
* @link http://www.codeigniter.com
* @since Version 1.0
@@ -16,7 +16,7 @@
// ------------------------------------------------------------------------
/**
- * Code Igniter Download Helpers
+ * CodeIgniter Download Helpers
*
* @package CodeIgniter
* @subpackage Helpers
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
index 4da62ade6..89801c0bf 100644
--- a/system/helpers/file_helper.php
+++ b/system/helpers/file_helper.php
@@ -1,179 +1,179 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Igniter File Helpers
- *
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/helpers/file_helpers.html
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Read File
- *
- * Opens the file specfied in the path and returns it as a string.
- *
- * @access public
- * @param string path to file
- * @return string
- */
-function read_file($file)
-{
- if ( ! file_exists($file))
- {
- return FALSE;
- }
-
- if (function_exists('file_get_contents'))
- {
- return file_get_contents($file);
- }
-
- if ( ! $fp = @fopen($file, 'rb'))
- {
- return FALSE;
- }
-
- flock($fp, LOCK_SH);
-
- $data = '';
- if (filesize($file) > 0)
- {
- $data =& fread($fp, filesize($file));
- }
-
- flock($fp, LOCK_UN);
- fclose($fp);
-
- return $data;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Write File
- *
- * Writes data to the file specified in the path.
- * Creates a new file if non-existent.
- *
- * @access public
- * @param string path to file
- * @param string file data
- * @return bool
- */
-function write_file($path, $data, $mode = 'wb')
-{
- if ( ! $fp = @fopen($path, $mode))
- {
- return FALSE;
- }
-
- flock($fp, LOCK_EX);
- fwrite($fp, $data);
- flock($fp, LOCK_UN);
- fclose($fp);
-
- return TRUE;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Delete Files
- *
- * Deletes all files contained in the supplied directory path.
- * Files must be writable or owned by the system in order to be deleted.
- * If the second parameter is set to TRUE, any directories contained
- * within the supplied base directory will be nuked as well.
- *
- * @access public
- * @param string path to file
- * @param bool whether to delete any directories found in the path
- * @return bool
- */
-function delete_files($path, $del_dir = FALSE, $level = 0)
-{
- // Trim the trailing slash
- $path = preg_replace("|^(.+?)/*$|", "\\1", $path);
-
- if ( ! $current_dir = @opendir($path))
- return;
-
- while(FALSE !== ($filename = @readdir($current_dir)))
- {
- if ($filename != "." and $filename != "..")
- {
- if (is_dir($path.'/'.$filename))
- {
- $level++;
- delete_files($path.'/'.$filename, $del_dir, $level);
- }
- else
- {
- unlink($path.'/'.$filename);
- }
- }
- }
- @closedir($current_dir);
-
- if ($del_dir == TRUE AND $level > 0)
- {
- @rmdir($path);
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Get Filenames
- *
- * Reads the specified directory and builds an array containing the filenames.
- * Any sub-folders contained within the specified path are read as well.
- *
- * @access public
- * @param string path to source
- * @param bool whether to include the path as part of the filename
- * @return array
- */
-function get_filenames($source_dir, $include_path = FALSE)
-{
- static $_filedata = array();
-
- if ($fp = @opendir($source_dir))
- {
- while (FALSE !== ($file = readdir($fp)))
- {
- if (@is_dir($source_dir.$file) && substr($file, 0, 1) != '.')
- {
- get_filenames($source_dir.$file."/", $include_path);
- }
- elseif (substr($file, 0, 1) != ".")
- {
-
- $_filedata[] = ($include_path == TRUE) ? $source_dir.$file : $file;
- }
- }
- return $_filedata;
- }
-}
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter File Helpers
+ *
+ * @package CodeIgniter
+ * @subpackage Helpers
+ * @category Helpers
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/helpers/file_helpers.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Read File
+ *
+ * Opens the file specfied in the path and returns it as a string.
+ *
+ * @access public
+ * @param string path to file
+ * @return string
+ */
+function read_file($file)
+{
+ if ( ! file_exists($file))
+ {
+ return FALSE;
+ }
+
+ if (function_exists('file_get_contents'))
+ {
+ return file_get_contents($file);
+ }
+
+ if ( ! $fp = @fopen($file, 'rb'))
+ {
+ return FALSE;
+ }
+
+ flock($fp, LOCK_SH);
+
+ $data = '';
+ if (filesize($file) > 0)
+ {
+ $data =& fread($fp, filesize($file));
+ }
+
+ flock($fp, LOCK_UN);
+ fclose($fp);
+
+ return $data;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Write File
+ *
+ * Writes data to the file specified in the path.
+ * Creates a new file if non-existent.
+ *
+ * @access public
+ * @param string path to file
+ * @param string file data
+ * @return bool
+ */
+function write_file($path, $data, $mode = 'wb')
+{
+ if ( ! $fp = @fopen($path, $mode))
+ {
+ return FALSE;
+ }
+
+ flock($fp, LOCK_EX);
+ fwrite($fp, $data);
+ flock($fp, LOCK_UN);
+ fclose($fp);
+
+ return TRUE;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Delete Files
+ *
+ * Deletes all files contained in the supplied directory path.
+ * Files must be writable or owned by the system in order to be deleted.
+ * If the second parameter is set to TRUE, any directories contained
+ * within the supplied base directory will be nuked as well.
+ *
+ * @access public
+ * @param string path to file
+ * @param bool whether to delete any directories found in the path
+ * @return bool
+ */
+function delete_files($path, $del_dir = FALSE, $level = 0)
+{
+ // Trim the trailing slash
+ $path = preg_replace("|^(.+?)/*$|", "\\1", $path);
+
+ if ( ! $current_dir = @opendir($path))
+ return;
+
+ while(FALSE !== ($filename = @readdir($current_dir)))
+ {
+ if ($filename != "." and $filename != "..")
+ {
+ if (is_dir($path.'/'.$filename))
+ {
+ $level++;
+ delete_files($path.'/'.$filename, $del_dir, $level);
+ }
+ else
+ {
+ unlink($path.'/'.$filename);
+ }
+ }
+ }
+ @closedir($current_dir);
+
+ if ($del_dir == TRUE AND $level > 0)
+ {
+ @rmdir($path);
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Get Filenames
+ *
+ * Reads the specified directory and builds an array containing the filenames.
+ * Any sub-folders contained within the specified path are read as well.
+ *
+ * @access public
+ * @param string path to source
+ * @param bool whether to include the path as part of the filename
+ * @return array
+ */
+function get_filenames($source_dir, $include_path = FALSE)
+{
+ static $_filedata = array();
+
+ if ($fp = @opendir($source_dir))
+ {
+ while (FALSE !== ($file = readdir($fp)))
+ {
+ if (@is_dir($source_dir.$file) && substr($file, 0, 1) != '.')
+ {
+ get_filenames($source_dir.$file."/", $include_path);
+ }
+ elseif (substr($file, 0, 1) != ".")
+ {
+
+ $_filedata[] = ($include_path == TRUE) ? $source_dir.$file : $file;
+ }
+ }
+ return $_filedata;
+ }
+}
+
?> \ No newline at end of file
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index a166198fb..adbddd5ad 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -1,12 +1,12 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
- * Code Igniter
+ * CodeIgniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
* @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
* @license http://www.codeignitor.com/user_guide/license.html
* @link http://www.codeigniter.com
* @since Version 1.0
@@ -16,7 +16,7 @@
// ------------------------------------------------------------------------
/**
- * Code Igniter Form Helpers
+ * CodeIgniter Form Helpers
*
* @package CodeIgniter
* @subpackage Helpers
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php
index 90a776386..152d18b76 100644
--- a/system/helpers/html_helper.php
+++ b/system/helpers/html_helper.php
@@ -1,204 +1,204 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Igniter HTML Helpers
- *
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/helpers/html_helper.html
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Heading
- *
- * Generates an HTML heading tag. First param is the data.
- * Second param is the size of the heading tag.
- *
- * @access public
- * @param string
- * @param integer
- * @return string
- */
-function heading($data = '', $h = '1')
-{
- return "<h".$h.">".$data."</h".$h.">";
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Unordered List
- *
- * Generates an HTML unordered list from an single or multi-dimensional array.
- *
- * @access public
- * @param array
- * @param mixed
- * @return string
- */
-function ul($list, $attributes = '')
-{
- return _list('ul', $list, $attributes);
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Ordered List
- *
- * Generates an HTML ordered list from an single or multi-dimensional array.
- *
- * @access public
- * @param array
- * @param mixed
- * @return string
- */
-function ol($list, $attributes = '')
-{
- return _list('ol', $list, $attributes);
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Generates the list
- *
- * Generates an HTML ordered list from an single or multi-dimensional array.
- *
- * @access private
- * @param string
- * @param mixed
- * @param mixed
- * @param intiger
- * @return string
- */
-function _list($type = 'ul', $list, $attributes = '', $depth = 0)
-{
- // If an array wasn't submitted there's nothing to do...
- if ( ! is_array($list))
- {
- return $list;
- }
-
- // Set the indentation based on the depth
- $out = str_repeat(" ", $depth);
-
- // Were any attributes submitted? If so generate a string
- if (is_array($attributes))
- {
- $atts = '';
- foreach ($attributes as $key => $val)
- {
- $atts .= ' ' . $key . '="' . $val . '"';
- }
- $attributes = $atts;
- }
-
- // Write the opening list tag
- $out .= "<".$type.$attributes.">\n";
-
- // Cycle through the list elements. If an array is
- // encountered we will recursively call _list()
-
- static $_last_list_item = '';
- foreach ($list as $key => $val)
- {
- $_last_list_item = $key;
-
- $out .= str_repeat(" ", $depth + 2);
- $out .= "<li>";
-
- if ( ! is_array($val))
- {
- $out .= $val;
- }
- else
- {
- $out .= $_last_list_item."\n";
- $out .= _list($type, $val, '', $depth + 4);
- $out .= str_repeat(" ", $depth + 2);
- }
-
- $out .= "</li>\n";
- }
-
- // Set the indentation for the closing tag
- $out .= str_repeat(" ", $depth);
-
- // Write the closing list tag
- $out .= "</".$type.">\n";
-
- return $out;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Generates HTML BR tags based on number supplied
- *
- * @access public
- * @param integer
- * @return string
- */
-function br($num = 1)
-{
- return str_repeat("<br />", $num);
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Generates non-breaking space entities based on number supplied
- *
- * @access public
- * @param integer
- * @return string
- */
-function nbs($num = 1)
-{
- return str_repeat("&nbsp;", $num);
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Generates meta tags from an array of key/values
- *
- * @access public
- * @param array
- * @return string
- */
-function meta($meta = array(), $newline = "\n")
-{
- $str = '';
- foreach ($meta as $key => $val)
- {
- $str .= '<meta http-equiv="'.$key.'" content="'.$val.'" />'.$newline;
- }
-
- return $str;
-}
-
-
-
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter HTML Helpers
+ *
+ * @package CodeIgniter
+ * @subpackage Helpers
+ * @category Helpers
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/helpers/html_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Heading
+ *
+ * Generates an HTML heading tag. First param is the data.
+ * Second param is the size of the heading tag.
+ *
+ * @access public
+ * @param string
+ * @param integer
+ * @return string
+ */
+function heading($data = '', $h = '1')
+{
+ return "<h".$h.">".$data."</h".$h.">";
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Unordered List
+ *
+ * Generates an HTML unordered list from an single or multi-dimensional array.
+ *
+ * @access public
+ * @param array
+ * @param mixed
+ * @return string
+ */
+function ul($list, $attributes = '')
+{
+ return _list('ul', $list, $attributes);
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Ordered List
+ *
+ * Generates an HTML ordered list from an single or multi-dimensional array.
+ *
+ * @access public
+ * @param array
+ * @param mixed
+ * @return string
+ */
+function ol($list, $attributes = '')
+{
+ return _list('ol', $list, $attributes);
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Generates the list
+ *
+ * Generates an HTML ordered list from an single or multi-dimensional array.
+ *
+ * @access private
+ * @param string
+ * @param mixed
+ * @param mixed
+ * @param intiger
+ * @return string
+ */
+function _list($type = 'ul', $list, $attributes = '', $depth = 0)
+{
+ // If an array wasn't submitted there's nothing to do...
+ if ( ! is_array($list))
+ {
+ return $list;
+ }
+
+ // Set the indentation based on the depth
+ $out = str_repeat(" ", $depth);
+
+ // Were any attributes submitted? If so generate a string
+ if (is_array($attributes))
+ {
+ $atts = '';
+ foreach ($attributes as $key => $val)
+ {
+ $atts .= ' ' . $key . '="' . $val . '"';
+ }
+ $attributes = $atts;
+ }
+
+ // Write the opening list tag
+ $out .= "<".$type.$attributes.">\n";
+
+ // Cycle through the list elements. If an array is
+ // encountered we will recursively call _list()
+
+ static $_last_list_item = '';
+ foreach ($list as $key => $val)
+ {
+ $_last_list_item = $key;
+
+ $out .= str_repeat(" ", $depth + 2);
+ $out .= "<li>";
+
+ if ( ! is_array($val))
+ {
+ $out .= $val;
+ }
+ else
+ {
+ $out .= $_last_list_item."\n";
+ $out .= _list($type, $val, '', $depth + 4);
+ $out .= str_repeat(" ", $depth + 2);
+ }
+
+ $out .= "</li>\n";
+ }
+
+ // Set the indentation for the closing tag
+ $out .= str_repeat(" ", $depth);
+
+ // Write the closing list tag
+ $out .= "</".$type.">\n";
+
+ return $out;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Generates HTML BR tags based on number supplied
+ *
+ * @access public
+ * @param integer
+ * @return string
+ */
+function br($num = 1)
+{
+ return str_repeat("<br />", $num);
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Generates non-breaking space entities based on number supplied
+ *
+ * @access public
+ * @param integer
+ * @return string
+ */
+function nbs($num = 1)
+{
+ return str_repeat("&nbsp;", $num);
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Generates meta tags from an array of key/values
+ *
+ * @access public
+ * @param array
+ * @return string
+ */
+function meta($meta = array(), $newline = "\n")
+{
+ $str = '';
+ foreach ($meta as $key => $val)
+ {
+ $str .= '<meta http-equiv="'.$key.'" content="'.$val.'" />'.$newline;
+ }
+
+ return $str;
+}
+
+
+
+
?> \ No newline at end of file
diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php
index 666ec40b8..fbe851f3b 100644
--- a/system/helpers/inflector_helper.php
+++ b/system/helpers/inflector_helper.php
@@ -1,140 +1,140 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Igniter Inflector Helpers
- *
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/helpers/directory_helper.html
- */
-
-
-// --------------------------------------------------------------------
-
-/**
- * Singular
- *
- * Takes a singular word and makes it plural
- *
- * @access public
- * @param string
- * @return str
- */
-function singular($str)
-{
- $str = strtolower(trim($str));
- $end = substr($str, -3);
-
- if ($end == 'ies')
- {
- $str = substr($str, 0, strlen($str)-3).'y';
- }
- else
- {
- $end = substr($str, -1);
-
- if ($end == 's')
- {
- $str = substr($str, 0, strlen($str)-1);
- }
- }
-
- return $str;
-}
-
-// --------------------------------------------------------------------
-
-/**
- * Plural
- *
- * Takes a plural word and makes it singular
- *
- * @access public
- * @param string
- * @return str
- */
-function plural($str)
-{
- $str = strtolower(trim($str));
- $end = substr($str, -1);
-
- if ($end == 'y')
- {
- $str = substr($str, 0, strlen($str)-1).'ies';
- }
- elseif ($end != 's')
- {
- $str .= 's';
- }
-
- return $str;
-}
-
-// --------------------------------------------------------------------
-
-/**
- * Camelize
- *
- * Takes multiple words separated by spaces or underscores and camelizes them
- *
- * @access public
- * @param string
- * @return str
- */
-function camelize($str)
-{
- $str = 'x'.strtolower(trim($str));
- $str = ucwords(preg_replace('/[\s_]+/', ' ', $str));
- return substr(str_replace(' ', '', $str), 1);
-}
-
-// --------------------------------------------------------------------
-
-/**
- * Underscore
- *
- * Takes multiple words separated by spaces and underscores them
- *
- * @access public
- * @param string
- * @return str
- */
-function underscore($str)
-{
- return preg_replace('/[\s]+/', '_', strtolower(trim($str)));
-}
-
-// --------------------------------------------------------------------
-
-/**
- * Humanize
- *
- * Takes multiple words separated by underscores and changes them to spaces
- *
- * @access public
- * @param string
- * @return str
- */
-function humanize($str)
-{
- return ucwords(preg_replace('/[_]+/', ' ', strtolower(trim($str))));
-}
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Inflector Helpers
+ *
+ * @package CodeIgniter
+ * @subpackage Helpers
+ * @category Helpers
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/helpers/directory_helper.html
+ */
+
+
+// --------------------------------------------------------------------
+
+/**
+ * Singular
+ *
+ * Takes a singular word and makes it plural
+ *
+ * @access public
+ * @param string
+ * @return str
+ */
+function singular($str)
+{
+ $str = strtolower(trim($str));
+ $end = substr($str, -3);
+
+ if ($end == 'ies')
+ {
+ $str = substr($str, 0, strlen($str)-3).'y';
+ }
+ else
+ {
+ $end = substr($str, -1);
+
+ if ($end == 's')
+ {
+ $str = substr($str, 0, strlen($str)-1);
+ }
+ }
+
+ return $str;
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Plural
+ *
+ * Takes a plural word and makes it singular
+ *
+ * @access public
+ * @param string
+ * @return str
+ */
+function plural($str)
+{
+ $str = strtolower(trim($str));
+ $end = substr($str, -1);
+
+ if ($end == 'y')
+ {
+ $str = substr($str, 0, strlen($str)-1).'ies';
+ }
+ elseif ($end != 's')
+ {
+ $str .= 's';
+ }
+
+ return $str;
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Camelize
+ *
+ * Takes multiple words separated by spaces or underscores and camelizes them
+ *
+ * @access public
+ * @param string
+ * @return str
+ */
+function camelize($str)
+{
+ $str = 'x'.strtolower(trim($str));
+ $str = ucwords(preg_replace('/[\s_]+/', ' ', $str));
+ return substr(str_replace(' ', '', $str), 1);
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Underscore
+ *
+ * Takes multiple words separated by spaces and underscores them
+ *
+ * @access public
+ * @param string
+ * @return str
+ */
+function underscore($str)
+{
+ return preg_replace('/[\s]+/', '_', strtolower(trim($str)));
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Humanize
+ *
+ * Takes multiple words separated by underscores and changes them to spaces
+ *
+ * @access public
+ * @param string
+ * @return str
+ */
+function humanize($str)
+{
+ return ucwords(preg_replace('/[_]+/', ' ', strtolower(trim($str))));
+}
+
?> \ No newline at end of file
diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php
index 06228468f..eec04015d 100644
--- a/system/helpers/security_helper.php
+++ b/system/helpers/security_helper.php
@@ -1,112 +1,112 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Igniter Security Helpers
- *
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/helpers/security_helper.html
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * XSS Filtering
- *
- * @access public
- * @param string
- * @param string the character set of your data
- * @return string
- */
-function xss_clean($str, $charset = 'ISO-8859-1')
-{
- $CI =& get_instance();
- return $CI->input->xss_clean($str, $charset);
-}
-
-// --------------------------------------------------------------------
-
-/**
- * Hash encode a string
- *
- * @access public
- * @param string
- * @return string
- */
-function dohash($str, $type = 'sha1')
-{
- if ($type == 'sha1')
- {
- if ( ! function_exists('sha1'))
- {
- if ( ! function_exists('mhash'))
- {
- require_once(BASEPATH.'libraries/Sha1'.EXT);
- $SH = new CI_SHA;
- return $SH->generate($str);
- }
- else
- {
- return bin2hex(mhash(MHASH_SHA1, $str));
- }
- }
- else
- {
- return sha1($str);
- }
- }
- else
- {
- return md5($str);
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Strip Image Tags
- *
- * @access public
- * @param string
- * @return string
- */
-function strip_image_tags($str)
-{
- $str = preg_replace("#<img\s+.*?src\s*=\s*[\"'](.+?)[\"'].*?\>#", "\\1", $str);
- $str = preg_replace("#<img\s+.*?src\s*=\s*(.+?).*?\>#", "\\1", $str);
-
- return $str;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Convert PHP tags to entities
- *
- * @access public
- * @param string
- * @return string
- */
-function encode_php_tags($str)
-{
- return str_replace(array('<?php', '<?PHP', '<?', '?>'), array('&lt;?php', '&lt;?PHP', '&lt;?', '?&gt;'), $str);
-}
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Security Helpers
+ *
+ * @package CodeIgniter
+ * @subpackage Helpers
+ * @category Helpers
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/helpers/security_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * XSS Filtering
+ *
+ * @access public
+ * @param string
+ * @param string the character set of your data
+ * @return string
+ */
+function xss_clean($str, $charset = 'ISO-8859-1')
+{
+ $CI =& get_instance();
+ return $CI->input->xss_clean($str, $charset);
+}
+
+// --------------------------------------------------------------------
+
+/**
+ * Hash encode a string
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+function dohash($str, $type = 'sha1')
+{
+ if ($type == 'sha1')
+ {
+ if ( ! function_exists('sha1'))
+ {
+ if ( ! function_exists('mhash'))
+ {
+ require_once(BASEPATH.'libraries/Sha1'.EXT);
+ $SH = new CI_SHA;
+ return $SH->generate($str);
+ }
+ else
+ {
+ return bin2hex(mhash(MHASH_SHA1, $str));
+ }
+ }
+ else
+ {
+ return sha1($str);
+ }
+ }
+ else
+ {
+ return md5($str);
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Strip Image Tags
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+function strip_image_tags($str)
+{
+ $str = preg_replace("#<img\s+.*?src\s*=\s*[\"'](.+?)[\"'].*?\>#", "\\1", $str);
+ $str = preg_replace("#<img\s+.*?src\s*=\s*(.+?).*?\>#", "\\1", $str);
+
+ return $str;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Convert PHP tags to entities
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+function encode_php_tags($str)
+{
+ return str_replace(array('<?php', '<?PHP', '<?', '?>'), array('&lt;?php', '&lt;?PHP', '&lt;?', '?&gt;'), $str);
+}
+
?> \ No newline at end of file
diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php
index a07337246..9f16d3132 100644
--- a/system/helpers/smiley_helper.php
+++ b/system/helpers/smiley_helper.php
@@ -1,165 +1,165 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Igniter Smiley Helpers
- *
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/helpers/smiley_helper.html
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * JS Insert Smiley
- *
- * Generates the javascrip function needed to insert smileys into a form field
- *
- * @access public
- * @param string form name
- * @param string field name
- * @return string
- */
-function js_insert_smiley($form_name = '', $form_field = '')
-{
-return <<<EOF
-<script type="text/javascript">
- function insert_smiley(smiley)
- {
- document.{$form_name}.{$form_field}.value += " " + smiley;
- }
-</script>
-EOF;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Get Clickable Smileys
- *
- * Returns an array of image tag links that can be clicked to be inserted
- * into a form field.
- *
- * @access public
- * @param string the URL to the folder containing the smiley images
- * @return array
- */
-function get_clickable_smileys($image_url = '', $smileys = NULL)
-{
- if ( ! is_array($smileys))
- {
- if (FALSE === ($smileys = _get_smiley_array()))
- {
- return $str;
- }
- }
-
- // Add a trailing slash to the file path if needed
- $image_url = preg_replace("/(.+?)\/*$/", "\\1/", $image_url);
-
- $used = array();
- foreach ($smileys as $key => $val)
- {
- // Keep duplicates from being used, which can happen if the
- // mapping array contains multiple identical replacements. For example:
- // :-) and :) might be replaced with the same image so both smileys
- // will be in the array.
- if (isset($used[$smileys[$key][0]]))
- {
- continue;
- }
-
- $link[] = "<a href=\"javascript:void(0);\" onClick=\"insert_smiley('".$key."')\"><img src=\"".$image_url.$smileys[$key][0]."\" width=\"".$smileys[$key][1]."\" height=\"".$smileys[$key][2]."\" alt=\"".$smileys[$key][3]."\" style=\"border:0;\" /></a>";
-
- $used[$smileys[$key][0]] = TRUE;
- }
-
- return $link;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Parse Smileys
- *
- * Takes a string as input and swaps any contained smileys for the actual image
- *
- * @access public
- * @param string the text to be parsed
- * @param string the URL to the folder containing the smiley images
- * @return string
- */
-function parse_smileys($str = '', $image_url = '', $smileys = NULL)
-{
- if ($image_url == '')
- {
- return $str;
- }
-
- if ( ! is_array($smileys))
- {
- if (FALSE === ($smileys = _get_smiley_array()))
- {
- return $str;
- }
- }
-
- // Add a trailing slash to the file path if needed
- $image_url = preg_replace("/(.+?)\/*$/", "\\1/", $image_url);
-
- foreach ($smileys as $key => $val)
- {
- $str = str_replace($key, "<img src=\"".$image_url.$smileys[$key][0]."\" width=\"".$smileys[$key][1]."\" height=\"".$smileys[$key][2]."\" alt=\"".$smileys[$key][3]."\" style=\"border:0;\" />", $str);
- }
-
- return $str;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Get Smiley Array
- *
- * Fetches the config/smiley.php file
- *
- * @access private
- * @return mixed
- */
-function _get_smiley_array()
-{
- if ( ! file_exists(APPPATH.'config/smileys'.EXT))
- {
- return FALSE;
- }
-
- include(APPPATH.'config/smileys'.EXT);
-
- if ( ! isset($smileys) OR ! is_array($smileys))
- {
- return FALSE;
- }
-
- return $smileys;
-}
-
-
-
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Smiley Helpers
+ *
+ * @package CodeIgniter
+ * @subpackage Helpers
+ * @category Helpers
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/helpers/smiley_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * JS Insert Smiley
+ *
+ * Generates the javascrip function needed to insert smileys into a form field
+ *
+ * @access public
+ * @param string form name
+ * @param string field name
+ * @return string
+ */
+function js_insert_smiley($form_name = '', $form_field = '')
+{
+return <<<EOF
+<script type="text/javascript">
+ function insert_smiley(smiley)
+ {
+ document.{$form_name}.{$form_field}.value += " " + smiley;
+ }
+</script>
+EOF;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Get Clickable Smileys
+ *
+ * Returns an array of image tag links that can be clicked to be inserted
+ * into a form field.
+ *
+ * @access public
+ * @param string the URL to the folder containing the smiley images
+ * @return array
+ */
+function get_clickable_smileys($image_url = '', $smileys = NULL)
+{
+ if ( ! is_array($smileys))
+ {
+ if (FALSE === ($smileys = _get_smiley_array()))
+ {
+ return $str;
+ }
+ }
+
+ // Add a trailing slash to the file path if needed
+ $image_url = preg_replace("/(.+?)\/*$/", "\\1/", $image_url);
+
+ $used = array();
+ foreach ($smileys as $key => $val)
+ {
+ // Keep duplicates from being used, which can happen if the
+ // mapping array contains multiple identical replacements. For example:
+ // :-) and :) might be replaced with the same image so both smileys
+ // will be in the array.
+ if (isset($used[$smileys[$key][0]]))
+ {
+ continue;
+ }
+
+ $link[] = "<a href=\"javascript:void(0);\" onClick=\"insert_smiley('".$key."')\"><img src=\"".$image_url.$smileys[$key][0]."\" width=\"".$smileys[$key][1]."\" height=\"".$smileys[$key][2]."\" alt=\"".$smileys[$key][3]."\" style=\"border:0;\" /></a>";
+
+ $used[$smileys[$key][0]] = TRUE;
+ }
+
+ return $link;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Parse Smileys
+ *
+ * Takes a string as input and swaps any contained smileys for the actual image
+ *
+ * @access public
+ * @param string the text to be parsed
+ * @param string the URL to the folder containing the smiley images
+ * @return string
+ */
+function parse_smileys($str = '', $image_url = '', $smileys = NULL)
+{
+ if ($image_url == '')
+ {
+ return $str;
+ }
+
+ if ( ! is_array($smileys))
+ {
+ if (FALSE === ($smileys = _get_smiley_array()))
+ {
+ return $str;
+ }
+ }
+
+ // Add a trailing slash to the file path if needed
+ $image_url = preg_replace("/(.+?)\/*$/", "\\1/", $image_url);
+
+ foreach ($smileys as $key => $val)
+ {
+ $str = str_replace($key, "<img src=\"".$image_url.$smileys[$key][0]."\" width=\"".$smileys[$key][1]."\" height=\"".$smileys[$key][2]."\" alt=\"".$smileys[$key][3]."\" style=\"border:0;\" />", $str);
+ }
+
+ return $str;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Get Smiley Array
+ *
+ * Fetches the config/smiley.php file
+ *
+ * @access private
+ * @return mixed
+ */
+function _get_smiley_array()
+{
+ if ( ! file_exists(APPPATH.'config/smileys'.EXT))
+ {
+ return FALSE;
+ }
+
+ include(APPPATH.'config/smileys'.EXT);
+
+ if ( ! isset($smileys) OR ! is_array($smileys))
+ {
+ return FALSE;
+ }
+
+ return $smileys;
+}
+
+
+
+
?> \ No newline at end of file
diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php
index c0a8854dc..04c3a592a 100644
--- a/system/helpers/string_helper.php
+++ b/system/helpers/string_helper.php
@@ -1,12 +1,12 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
- * Code Igniter
+ * CodeIgniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
* @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
* @license http://www.codeignitor.com/user_guide/license.html
* @link http://www.codeigniter.com
* @since Version 1.0
@@ -16,7 +16,7 @@
// ------------------------------------------------------------------------
/**
- * Code Igniter String Helpers
+ * CodeIgniter String Helpers
*
* @package CodeIgniter
* @subpackage Helpers
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index 655d6e531..3c7270b9b 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -1,421 +1,421 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Igniter Text Helpers
- *
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/helpers/text_helper.html
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Word Limiter
- *
- * Limits a string to X number of words.
- *
- * @access public
- * @param string
- * @param integer
- * @param string the end character. Usually an ellipsis
- * @return string
- */
-function word_limiter($str, $n = 100, $end_char = '&#8230;')
-{
- if (strlen($str) < $n)
- {
- return $str;
- }
-
- $words = explode(' ', preg_replace("/\s+/", ' ', preg_replace("/(\r\n|\r|\n)/", " ", $str)));
-
- if (count($words) <= $n)
- {
- return $str;
- }
-
- $str = '';
- for ($i = 0; $i < $n; $i++)
- {
- $str .= $words[$i].' ';
- }
-
- return trim($str).$end_char;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Character Limiter
- *
- * Limits the string based on the character count. Preserves complete words
- * so the character count may not be exactly as specified.
- *
- * @access public
- * @param string
- * @param integer
- * @param string the end character. Usually an ellipsis
- * @return string
- */
-function character_limiter($str, $n = 500, $end_char = '&#8230;')
-{
- if (strlen($str) < $n)
- {
- return $str;
- }
-
- $str = preg_replace("/\s+/", ' ', preg_replace("/(\r\n|\r|\n)/", " ", $str));
-
- if (strlen($str) <= $n)
- {
- return $str;
- }
-
- $out = "";
- foreach (explode(' ', trim($str)) as $val)
- {
- $out .= $val.' ';
- if (strlen($out) >= $n)
- {
- return trim($out).$end_char;
- }
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * High ASCII to Entities
- *
- * Converts High ascii text and MS Word special characters to character entities
- *
- * @access public
- * @param string
- * @return string
- */
-function ascii_to_entities($str)
-{
- $count = 1;
- $out = '';
- $temp = array();
-
- for ($i = 0, $s = strlen($str); $i < $s; $i++)
- {
- $ordinal = ord($str[$i]);
-
- if ($ordinal < 128)
- {
- $out .= $str[$i];
- }
- else
- {
- if (count($temp) == 0)
- {
- $count = ($ordinal < 224) ? 2 : 3;
- }
-
- $temp[] = $ordinal;
-
- if (count($temp) == $count)
- {
- $number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64);
-
- $out .= '&#'.$number.';';
- $count = 1;
- $temp = array();
- }
- }
- }
-
- return $out;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Entities to ASCII
- *
- * Converts character entities back to ASCII
- *
- * @access public
- * @param string
- * @param bool
- * @return string
- */
-function entities_to_ascii($str, $all = TRUE)
-{
- if (preg_match_all('/\&#(\d+)\;/', $str, $matches))
- {
- for ($i = 0, $s = count($matches['0']); $i < $s; $i++)
- {
- $digits = $matches['1'][$i];
-
- $out = '';
-
- if ($digits < 128)
- {
- $out .= chr($digits);
-
- }
- elseif ($digits < 2048)
- {
- $out .= chr(192 + (($digits - ($digits % 64)) / 64));
- $out .= chr(128 + ($digits % 64));
- }
- else
- {
- $out .= chr(224 + (($digits - ($digits % 4096)) / 4096));
- $out .= chr(128 + ((($digits % 4096) - ($digits % 64)) / 64));
- $out .= chr(128 + ($digits % 64));
- }
-
- $str = str_replace($matches['0'][$i], $out, $str);
- }
- }
-
- if ($all)
- {
- $str = str_replace(array("&amp;", "&lt;", "&gt;", "&quot;", "&apos;", "&#45;"),
- array("&","<",">","\"", "'", "-"),
- $str);
- }
-
- return $str;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Word Censoring Function
- *
- * Supply a string and an array of disallowed words and any
- * matched words will be converted to #### or to the replacement
- * word you've submitted.
- *
- * @access public
- * @param string the text string
- * @param string the array of censoered words
- * @param string the optional replacement value
- * @return string
- */
-function word_censor($str, $censored, $replacement = '')
-{
- if ( ! is_array($censored))
- {
- return $str;
- }
-
- $str = ' '.$str.' ';
- foreach ($censored as $badword)
- {
- if ($replacement != '')
- {
- $str = preg_replace("/\b(".str_replace('\*', '\w*?', preg_quote($badword)).")\b/i", $replacement, $str);
- }
- else
- {
- $str = preg_replace("/\b(".str_replace('\*', '\w*?', preg_quote($badword)).")\b/ie", "str_repeat('#', strlen('\\1'))", $str);
- }
- }
-
- return trim($str);
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Highlighter
- *
- * Colorizes code strings
- *
- * @access public
- * @param string the text string
- * @return string
- */
-function highlight_code($str)
-{
- // The highlight string function encodes and highlights
- // brackets so we need them to start raw
- $str = str_replace(array('&lt;', '&gt;'), array('<', '>'), $str);
-
- // Replace any existing PHP tags to temporary markers so they don't accidentally
- // break the string out of PHP, and thus, thwart the highlighting.
-
- $str = str_replace(array('&lt;?php', '?&gt;', '\\'), array('phptagopen', 'phptagclose', 'backslashtmp'), $str);
-
- // The highlight_string function requires that the text be surrounded
- // by PHP tags. Since we don't know if A) the submitted text has PHP tags,
- // or B) whether the PHP tags enclose the entire string, we will add our
- // own PHP tags around the string along with some markers to make replacement easier later
-
- $str = '<?php //tempstart'."\n".$str.'//tempend ?>';
-
- // All the magic happens here, baby!
- $str = highlight_string($str, TRUE);
-
- // Prior to PHP 5, the highlight function used icky font tags
- // so we'll replace them with span tags.
- if (abs(phpversion()) < 5)
- {
- $str = str_replace(array('<font ', '</font>'), array('<span ', '</span>'), $str);
- $str = preg_replace('#color="(.*?)"#', 'style="color: \\1"', $str);
- }
-
- // Remove our artificially added PHP
- $str = preg_replace("#\<code\>.+?//tempstart\<br />\</span\>#is", "<code>\n", $str);
- $str = preg_replace("#\<code\>.+?//tempstart\<br />#is", "<code>\n", $str);
- $str = preg_replace("#//tempend.+#is", "</span>\n</code>", $str);
-
- // Replace our markers back to PHP tags.
- $str = str_replace(array('phptagopen', 'phptagclose', 'backslashtmp'), array('&lt;?php', '?&gt;', '\\'), $str); //<?
-
- return $str;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Phrase Highlighter
- *
- * Highlights a phrase within a text string
- *
- * @access public
- * @param string the text string
- * @param string the phrase you'd like to highlight
- * @param string the openging tag to precede the phrase with
- * @param string the closing tag to end the phrase with
- * @return string
- */
-function highlight_phrase($str, $phrase, $tag_open = '<strong>', $tag_close = '</strong>')
-{
- if ($str == '')
- {
- return '';
- }
-
- if ($phrase != '')
- {
- return preg_replace('/('.preg_quote($phrase).')/i', $tag_open."\\1".$tag_close, $str);
- }
-
- return $str;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Word Wrap
- *
- * Wraps text at the specified character. Maintains the integrity of words.
- * Anything placed between {unwrap}{/unwrap} will not be word wrapped, nor
- * will URLs.
- *
- * @access public
- * @param string the text string
- * @param integer the number of characters to wrap at
- * @return string
- */
-function word_wrap($str, $charlim = '76')
-{
- // Se the character limit
- if ( ! is_numeric($charlim))
- $charlim = 76;
-
- // Reduce multiple spaces
- $str = preg_replace("| +|", " ", $str);
-
- // Standardize newlines
- $str = preg_replace("/\r\n|\r/", "\n", $str);
-
- // If the current word is surrounded by {unwrap} tags we'll
- // strip the entire chunk and replace it with a marker.
- $unwrap = array();
- if (preg_match_all("|(\{unwrap\}.+?\{/unwrap\})|s", $str, $matches))
- {
- for ($i = 0; $i < count($matches['0']); $i++)
- {
- $unwrap[] = $matches['1'][$i];
- $str = str_replace($matches['1'][$i], "{{unwrapped".$i."}}", $str);
- }
- }
-
- // Use PHP's native function to do the initial wordwrap.
- // We set the cut flag to FALSE so that any individual words that are
- // too long get left alone. In the next step we'll deal with them.
- $str = wordwrap($str, $charlim, "\n", FALSE);
-
- // Split the string into individual lines of text and cycle through them
- $output = "";
- foreach (explode("\n", $str) as $line)
- {
- // Is the line within the allowed character count?
- // If so we'll join it to the output and continue
- if (strlen($line) <= $charlim)
- {
- $output .= $line."\n";
- continue;
- }
-
- $temp = '';
- while((strlen($line)) > $charlim)
- {
- // If the over-length word is a URL we won't wrap it
- if (preg_match("!\[url.+\]|://|wwww.!", $line))
- {
- break;
- }
-
- // Trim the word down
- $temp .= substr($line, 0, $charlim-1);
- $line = substr($line, $charlim-1);
- }
-
- // If $temp contains data it means we had to split up an over-length
- // word into smaller chunks so we'll add it back to our current line
- if ($temp != '')
- {
- $output .= $temp.$this->newline.$line;
- }
- else
- {
- $output .= $line;
- }
-
- $output .= "\n";
- }
-
- // Put our markers back
- if (count($unwrap) > 0)
- {
- foreach ($unwrap as $key => $val)
- {
- $output = str_replace("{{unwrapped".$key."}}", $val, $output);
- }
- }
-
- // Remove the unwrap tags
- $output = str_replace(array('{unwrap}', '{/unwrap}'), '', $output);
-
- return $output;
-}
-
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Text Helpers
+ *
+ * @package CodeIgniter
+ * @subpackage Helpers
+ * @category Helpers
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/helpers/text_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Word Limiter
+ *
+ * Limits a string to X number of words.
+ *
+ * @access public
+ * @param string
+ * @param integer
+ * @param string the end character. Usually an ellipsis
+ * @return string
+ */
+function word_limiter($str, $n = 100, $end_char = '&#8230;')
+{
+ if (strlen($str) < $n)
+ {
+ return $str;
+ }
+
+ $words = explode(' ', preg_replace("/\s+/", ' ', preg_replace("/(\r\n|\r|\n)/", " ", $str)));
+
+ if (count($words) <= $n)
+ {
+ return $str;
+ }
+
+ $str = '';
+ for ($i = 0; $i < $n; $i++)
+ {
+ $str .= $words[$i].' ';
+ }
+
+ return trim($str).$end_char;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Character Limiter
+ *
+ * Limits the string based on the character count. Preserves complete words
+ * so the character count may not be exactly as specified.
+ *
+ * @access public
+ * @param string
+ * @param integer
+ * @param string the end character. Usually an ellipsis
+ * @return string
+ */
+function character_limiter($str, $n = 500, $end_char = '&#8230;')
+{
+ if (strlen($str) < $n)
+ {
+ return $str;
+ }
+
+ $str = preg_replace("/\s+/", ' ', preg_replace("/(\r\n|\r|\n)/", " ", $str));
+
+ if (strlen($str) <= $n)
+ {
+ return $str;
+ }
+
+ $out = "";
+ foreach (explode(' ', trim($str)) as $val)
+ {
+ $out .= $val.' ';
+ if (strlen($out) >= $n)
+ {
+ return trim($out).$end_char;
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * High ASCII to Entities
+ *
+ * Converts High ascii text and MS Word special characters to character entities
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+function ascii_to_entities($str)
+{
+ $count = 1;
+ $out = '';
+ $temp = array();
+
+ for ($i = 0, $s = strlen($str); $i < $s; $i++)
+ {
+ $ordinal = ord($str[$i]);
+
+ if ($ordinal < 128)
+ {
+ $out .= $str[$i];
+ }
+ else
+ {
+ if (count($temp) == 0)
+ {
+ $count = ($ordinal < 224) ? 2 : 3;
+ }
+
+ $temp[] = $ordinal;
+
+ if (count($temp) == $count)
+ {
+ $number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64);
+
+ $out .= '&#'.$number.';';
+ $count = 1;
+ $temp = array();
+ }
+ }
+ }
+
+ return $out;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Entities to ASCII
+ *
+ * Converts character entities back to ASCII
+ *
+ * @access public
+ * @param string
+ * @param bool
+ * @return string
+ */
+function entities_to_ascii($str, $all = TRUE)
+{
+ if (preg_match_all('/\&#(\d+)\;/', $str, $matches))
+ {
+ for ($i = 0, $s = count($matches['0']); $i < $s; $i++)
+ {
+ $digits = $matches['1'][$i];
+
+ $out = '';
+
+ if ($digits < 128)
+ {
+ $out .= chr($digits);
+
+ }
+ elseif ($digits < 2048)
+ {
+ $out .= chr(192 + (($digits - ($digits % 64)) / 64));
+ $out .= chr(128 + ($digits % 64));
+ }
+ else
+ {
+ $out .= chr(224 + (($digits - ($digits % 4096)) / 4096));
+ $out .= chr(128 + ((($digits % 4096) - ($digits % 64)) / 64));
+ $out .= chr(128 + ($digits % 64));
+ }
+
+ $str = str_replace($matches['0'][$i], $out, $str);
+ }
+ }
+
+ if ($all)
+ {
+ $str = str_replace(array("&amp;", "&lt;", "&gt;", "&quot;", "&apos;", "&#45;"),
+ array("&","<",">","\"", "'", "-"),
+ $str);
+ }
+
+ return $str;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Word Censoring Function
+ *
+ * Supply a string and an array of disallowed words and any
+ * matched words will be converted to #### or to the replacement
+ * word you've submitted.
+ *
+ * @access public
+ * @param string the text string
+ * @param string the array of censoered words
+ * @param string the optional replacement value
+ * @return string
+ */
+function word_censor($str, $censored, $replacement = '')
+{
+ if ( ! is_array($censored))
+ {
+ return $str;
+ }
+
+ $str = ' '.$str.' ';
+ foreach ($censored as $badword)
+ {
+ if ($replacement != '')
+ {
+ $str = preg_replace("/\b(".str_replace('\*', '\w*?', preg_quote($badword)).")\b/i", $replacement, $str);
+ }
+ else
+ {
+ $str = preg_replace("/\b(".str_replace('\*', '\w*?', preg_quote($badword)).")\b/ie", "str_repeat('#', strlen('\\1'))", $str);
+ }
+ }
+
+ return trim($str);
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Code Highlighter
+ *
+ * Colorizes code strings
+ *
+ * @access public
+ * @param string the text string
+ * @return string
+ */
+function highlight_code($str)
+{
+ // The highlight string function encodes and highlights
+ // brackets so we need them to start raw
+ $str = str_replace(array('&lt;', '&gt;'), array('<', '>'), $str);
+
+ // Replace any existing PHP tags to temporary markers so they don't accidentally
+ // break the string out of PHP, and thus, thwart the highlighting.
+
+ $str = str_replace(array('&lt;?php', '?&gt;', '\\'), array('phptagopen', 'phptagclose', 'backslashtmp'), $str);
+
+ // The highlight_string function requires that the text be surrounded
+ // by PHP tags. Since we don't know if A) the submitted text has PHP tags,
+ // or B) whether the PHP tags enclose the entire string, we will add our
+ // own PHP tags around the string along with some markers to make replacement easier later
+
+ $str = '<?php //tempstart'."\n".$str.'//tempend ?>';
+
+ // All the magic happens here, baby!
+ $str = highlight_string($str, TRUE);
+
+ // Prior to PHP 5, the highlight function used icky font tags
+ // so we'll replace them with span tags.
+ if (abs(phpversion()) < 5)
+ {
+ $str = str_replace(array('<font ', '</font>'), array('<span ', '</span>'), $str);
+ $str = preg_replace('#color="(.*?)"#', 'style="color: \\1"', $str);
+ }
+
+ // Remove our artificially added PHP
+ $str = preg_replace("#\<code\>.+?//tempstart\<br />\</span\>#is", "<code>\n", $str);
+ $str = preg_replace("#\<code\>.+?//tempstart\<br />#is", "<code>\n", $str);
+ $str = preg_replace("#//tempend.+#is", "</span>\n</code>", $str);
+
+ // Replace our markers back to PHP tags.
+ $str = str_replace(array('phptagopen', 'phptagclose', 'backslashtmp'), array('&lt;?php', '?&gt;', '\\'), $str); //<?
+
+ return $str;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Phrase Highlighter
+ *
+ * Highlights a phrase within a text string
+ *
+ * @access public
+ * @param string the text string
+ * @param string the phrase you'd like to highlight
+ * @param string the openging tag to precede the phrase with
+ * @param string the closing tag to end the phrase with
+ * @return string
+ */
+function highlight_phrase($str, $phrase, $tag_open = '<strong>', $tag_close = '</strong>')
+{
+ if ($str == '')
+ {
+ return '';
+ }
+
+ if ($phrase != '')
+ {
+ return preg_replace('/('.preg_quote($phrase).')/i', $tag_open."\\1".$tag_close, $str);
+ }
+
+ return $str;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Word Wrap
+ *
+ * Wraps text at the specified character. Maintains the integrity of words.
+ * Anything placed between {unwrap}{/unwrap} will not be word wrapped, nor
+ * will URLs.
+ *
+ * @access public
+ * @param string the text string
+ * @param integer the number of characters to wrap at
+ * @return string
+ */
+function word_wrap($str, $charlim = '76')
+{
+ // Se the character limit
+ if ( ! is_numeric($charlim))
+ $charlim = 76;
+
+ // Reduce multiple spaces
+ $str = preg_replace("| +|", " ", $str);
+
+ // Standardize newlines
+ $str = preg_replace("/\r\n|\r/", "\n", $str);
+
+ // If the current word is surrounded by {unwrap} tags we'll
+ // strip the entire chunk and replace it with a marker.
+ $unwrap = array();
+ if (preg_match_all("|(\{unwrap\}.+?\{/unwrap\})|s", $str, $matches))
+ {
+ for ($i = 0; $i < count($matches['0']); $i++)
+ {
+ $unwrap[] = $matches['1'][$i];
+ $str = str_replace($matches['1'][$i], "{{unwrapped".$i."}}", $str);
+ }
+ }
+
+ // Use PHP's native function to do the initial wordwrap.
+ // We set the cut flag to FALSE so that any individual words that are
+ // too long get left alone. In the next step we'll deal with them.
+ $str = wordwrap($str, $charlim, "\n", FALSE);
+
+ // Split the string into individual lines of text and cycle through them
+ $output = "";
+ foreach (explode("\n", $str) as $line)
+ {
+ // Is the line within the allowed character count?
+ // If so we'll join it to the output and continue
+ if (strlen($line) <= $charlim)
+ {
+ $output .= $line."\n";
+ continue;
+ }
+
+ $temp = '';
+ while((strlen($line)) > $charlim)
+ {
+ // If the over-length word is a URL we won't wrap it
+ if (preg_match("!\[url.+\]|://|wwww.!", $line))
+ {
+ break;
+ }
+
+ // Trim the word down
+ $temp .= substr($line, 0, $charlim-1);
+ $line = substr($line, $charlim-1);
+ }
+
+ // If $temp contains data it means we had to split up an over-length
+ // word into smaller chunks so we'll add it back to our current line
+ if ($temp != '')
+ {
+ $output .= $temp.$this->newline.$line;
+ }
+ else
+ {
+ $output .= $line;
+ }
+
+ $output .= "\n";
+ }
+
+ // Put our markers back
+ if (count($unwrap) > 0)
+ {
+ foreach ($unwrap as $key => $val)
+ {
+ $output = str_replace("{{unwrapped".$key."}}", $val, $output);
+ }
+ }
+
+ // Remove the unwrap tags
+ $output = str_replace(array('{unwrap}', '{/unwrap}'), '', $output);
+
+ return $output;
+}
+
+
?> \ No newline at end of file
diff --git a/system/helpers/typography_helper.php b/system/helpers/typography_helper.php
index 1681fa37c..131358c6a 100644
--- a/system/helpers/typography_helper.php
+++ b/system/helpers/typography_helper.php
@@ -1,540 +1,540 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Igniter Typography Helpers
- *
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/helpers/typography_helper.html
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Convert newlines to HTML line breaks except within PRE tags
- *
- * @access public
- * @param string
- * @return string
- */
-function nl2br_except_pre($str)
-{
- $ex = explode("pre>",$str);
- $ct = count($ex);
-
- $newstr = "";
- for ($i = 0; $i < $ct; $i++)
- {
- if (($i % 2) == 0)
- {
- $newstr .= nl2br($ex[$i]);
- }
- else
- {
- $newstr .= $ex[$i];
- }
-
- if ($ct - 1 != $i)
- $newstr .= "pre>";
- }
-
- return $newstr;
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Auto Typography Wrapper Function
- *
- *
- * @access public
- * @param string
- * @return string
- */
-function auto_typography($str)
-{
- $TYPE = new Auto_typography();
- return $TYPE->convert($str);
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Auto Typography Class
- *
- *
- * @access private
- * @category Helpers
- * @author Rick Ellis
- * @author Paul Burdick
- * @link http://www.codeigniter.com/user_guide/helpers/
- */
-class Auto_typography {
-
- // Block level elements that should not be wrapped inside <p> tags
- var $block_elements = 'div|blockquote|pre|code|h\d|script|ol|un';
-
- // Elements that should not have <p> and <br /> tags within them.
- var $skip_elements = 'pre|ol|ul';
-
- // Tags we want the parser to completely ignore when splitting the string.
- var $ignore_elements = 'a|b|i|em|strong|span|img|li';
-
-
- /**
- * Main Processing Function
- *
- */
- function convert($str)
- {
- if ($str == '')
- {
- return '';
- }
-
- $str = ' '.$str.' ';
-
- // Standardize Newlines to make matching easier
- $str = preg_replace("/(\r\n|\r)/", "\n", $str);
-
- /*
- * Reduce line breaks
- *
- * If there are more than two consecutive line
- * breaks we'll compress them down to a maximum
- * of two since there's no benefit to more.
- *
- */
- $str = preg_replace("/\n\n+/", "\n\n", $str);
-
- /*
- * Convert quotes within tags to temporary marker
- *
- * We don't want quotes converted within
- * tags so we'll temporarily convert them to
- * {@DQ} and {@SQ}
- *
- */
- if (preg_match_all("#\<.+?>#si", $str, $matches))
- {
- for ($i = 0; $i < count($matches['0']); $i++)
- {
- $str = str_replace($matches['0'][$i],
- str_replace(array("'",'"'), array('{@SQ}', '{@DQ}'), $matches['0'][$i]),
- $str);
- }
- }
-
-
- /*
- * Add closing/opening paragraph tags before/after "block" elements
- *
- * Since block elements (like <blockquotes>, <pre>, etc.) do not get
- * wrapped in paragraph tags we will add a closing </p> tag just before
- * each block element starts and an opening <p> tag right after the block element
- * ends. Later on we'll do some further clean up.
- *
- */
- $str = preg_replace("#(<.*?)(".$this->block_elements.")(.*?>)#", "</p>\\1\\2\\3", $str);
- $str = preg_replace("#(</.*?)(".$this->block_elements.")(.*?>)#", "\\1\\2\\3<p>", $str);
-
- /*
- * Convert "ignore" tags to temporary marker
- *
- * The parser splits out the string at every tag
- * it encounters. Certain inline tags, like image
- * tags, links, span tags, etc. will be adversely
- * affected if they are split out so we'll convert
- * the opening < temporarily to: {@TAG}
- *
- */
- $str = preg_replace("#<(/*)(".$this->ignore_elements.")#i", "{@TAG}\\1\\2", $str);
-
- /*
- * Split the string at every tag
- *
- * This creates an array with this prototype:
- *
- * [array]
- * {
- * [0] = <opening tag>
- * [1] = Content contained between the tags
- * [2] = <closing tag>
- * Etc...
- * }
- *
- */
- $chunks = preg_split('/(<(?:[^<>]+(?:"[^"]*"|\'[^\']*\')?)+>)/', $str, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
-
- /*
- * Build our finalized string
- *
- * We'll cycle through the array, skipping tags,
- * and processing the contained text
- *
- */
- $str = '';
- $process = TRUE;
- foreach ($chunks as $chunk)
- {
- /*
- * Are we dealing with a tag?
- *
- * If so, we'll skip the processing for this cycle.
- * Well also set the "process" flag which allows us
- * to skip <pre> tags and a few other things.
- *
- */
- if (preg_match("#<(/*)(".$this->block_elements.").*?\>#", $chunk, $match))
- {
- if (preg_match("#".$this->skip_elements."#", $match['2']))
- {
- $process = ($match['1'] == '/') ? TRUE : FALSE;
- }
-
- $str .= $chunk;
- continue;
- }
-
- if ($process == FALSE)
- {
- $str .= $chunk;
- continue;
- }
-
- // Convert Newlines into <p> and <br /> tags
- $str .= $this->format_newlines($chunk);
- }
-
- // FINAL CLEAN UP
- // IMPORTANT: DO NOT ALTER THE ORDER OF THE ITEMS BELOW!
-
- /*
- * Clean up paragraph tags before/after "block" elements
- *
- * Earlier we added <p></p> tags before/after block level elements.
- * Then, we added paragraph tags around double line breaks. This
- * potentially created incorrectly formatted paragraphs so we'll
- * clean it up here.
- *
- */
- $str = preg_replace("#<p>({@TAG}.*?)(".$this->block_elements.")(.*?>)#", "\\1\\2\\3", $str);
- $str = preg_replace("#({@TAG}/.*?)(".$this->block_elements.")(.*?>)</p>#", "\\1\\2\\3", $str);
-
- // Convert Quotes and other characters
- $str = $this->format_characters($str);
-
- // Fix an artifact that happens during the paragraph replacement
- $str = preg_replace('#(<p>\n*</p>)#', '', $str);
-
- // If the user submitted their own paragraph tags with class data
- // in them we will retain them instead of using our tags.
- $str = preg_replace('#(<p.*?>)<p>#', "\\1", $str);
-
- // Final clean up
- $str = str_replace(
- array(
- '</p></p>',
- '</p><p>',
- '<p> ',
- ' </p>',
- '{@TAG}',
- '{@DQ}',
- '{@SQ}',
- '<p></p>'
- ),
- array(
- '</p>',
- '<p>',
- '<p>',
- '</p>',
- '<',
- '"',
- "'",
- ''
- ),
- $str
- );
-
- return $str;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Format Characters
- *
- * This function mainly converts double and single quotes
- * to entities, but since these are directional, it does
- * it based on some rules. It also converts em-dashes
- * and a couple other things.
- */
- function format_characters($str)
- {
- $table = array(
- ' "' => " &#8220;",
- '" ' => "&#8221; ",
- " '" => " &#8216;",
- "' " => "&#8217; ",
-
- '>"' => ">&#8220;",
- '"<' => "&#8221;<",
- ">'" => ">&#8216;",
- "'<" => "&#8217;<",
-
- "\"." => "&#8221;.",
- "\"," => "&#8221;,",
- "\";" => "&#8221;;",
- "\":" => "&#8221;:",
- "\"!" => "&#8221;!",
- "\"?" => "&#8221;?",
-
- ". " => ".&nbsp; ",
- "? " => "?&nbsp; ",
- "! " => "!&nbsp; ",
- ": " => ":&nbsp; ",
- );
-
- // These deal with quotes within quotes, like: "'hi here'"
- $start = 0;
- $space = array("\n", "\t", " ");
-
- while(TRUE)
- {
- $current = strpos(substr($str, $start), "\"'");
-
- if ($current === FALSE) break;
-
- $one_before = substr($str, $start+$current-1, 1);
- $one_after = substr($str, $start+$current+2, 1);
-
- if ( ! in_array($one_after, $space, TRUE) && $one_after != "<")
- {
- $str = str_replace( $one_before."\"'".$one_after,
- $one_before."&#8220;&#8216;".$one_after,
- $str);
- }
- elseif ( ! in_array($one_before, $space, TRUE) && (in_array($one_after, $space, TRUE) OR $one_after == '<'))
- {
- $str = str_replace( $one_before."\"'".$one_after,
- $one_before."&#8221;&#8217;".$one_after,
- $str);
- }
-
- $start = $start+$current+2;
- }
-
- $start = 0;
-
- while(TRUE)
- {
- $current = strpos(substr($str, $start), "'\"");
-
- if ($current === FALSE) break;
-
- $one_before = substr($str, $start+$current-1, 1);
- $one_after = substr($str, $start+$current+2, 1);
-
- if ( in_array($one_before, $space, TRUE) && ! in_array($one_after, $space, TRUE) && $one_after != "<")
- {
- $str = str_replace( $one_before."'\"".$one_after,
- $one_before."&#8216;&#8220;".$one_after,
- $str);
- }
- elseif ( ! in_array($one_before, $space, TRUE) && $one_before != ">")
- {
- $str = str_replace( $one_before."'\"".$one_after,
- $one_before."&#8217;&#8221;".$one_after,
- $str);
- }
-
- $start = $start+$current+2;
- }
-
- // Are there quotes within a word, as in: ("something")
- if (preg_match_all("/(.)\"(\S+?)\"(.)/", $str, $matches))
- {
- for ($i=0, $s=sizeof($matches['0']); $i < $s; ++$i)
- {
- if ( ! in_array($matches['1'][$i], $space, TRUE) && ! in_array($matches['3'][$i], $space, TRUE))
- {
- $str = str_replace( $matches['0'][$i],
- $matches['1'][$i]."&#8220;".$matches['2'][$i]."&#8221;".$matches['3'][$i],
- $str);
- }
- }
- }
-
- if (preg_match_all("/(.)\'(\S+?)\'(.)/", $str, $matches))
- {
- for ($i=0, $s=sizeof($matches['0']); $i < $s; ++$i)
- {
- if ( ! in_array($matches['1'][$i], $space, TRUE) && ! in_array($matches['3'][$i], $space, TRUE))
- {
- $str = str_replace( $matches['0'][$i],
- $matches['1'][$i]."&#8216;".$matches['2'][$i]."&#8217;".$matches['3'][$i],
- $str);
- }
- }
- }
-
- // How about one apostrophe, as in Rick's
- $start = 0;
-
- while(TRUE)
- {
- $current = strpos(substr($str, $start), "'");
-
- if ($current === FALSE) break;
-
- $one_before = substr($str, $start+$current-1, 1);
- $one_after = substr($str, $start+$current+1, 1);
-
- if ( ! in_array($one_before, $space, TRUE) && ! in_array($one_after, $space, TRUE))
- {
- $str = str_replace( $one_before."'".$one_after,
- $one_before."&#8217;".$one_after,
- $str);
- }
-
- $start = $start+$current+2;
- }
-
- // Em-dashes
- $start = 0;
- while(TRUE)
- {
- $current = strpos(substr($str, $start), "--");
-
- if ($current === FALSE) break;
-
- $one_before = substr($str, $start+$current-1, 1);
- $one_after = substr($str, $start+$current+2, 1);
- $two_before = substr($str, $start+$current-2, 1);
- $two_after = substr($str, $start+$current+3, 1);
-
- if (( ! in_array($one_before, $space, TRUE) && ! in_array($one_after, $space, TRUE))
- OR
- ( ! in_array($two_before, $space, TRUE) && ! in_array($two_after, $space, TRUE) && $one_before == ' ' && $one_after == ' ')
- )
- {
- $str = str_replace( $two_before.$one_before."--".$one_after.$two_after,
- $two_before.trim($one_before)."&#8212;".trim($one_after).$two_after,
- $str);
- }
-
- $start = $start+$current+2;
- }
-
- // Ellipsis
- $str = preg_replace("#(\w)\.\.\.(\s|<br />|</p>)#", "\\1&#8230;\\2", $str);
- $str = preg_replace("#(\s|<br />|</p>)\.\.\.(\w)#", "\\1&#8230;\\2", $str);
-
- // Run the translation array we defined above
- $str = str_replace(array_keys($table), array_values($table), $str);
-
- // If there are any stray double quotes we'll catch them here
-
- $start = 0;
-
- while(TRUE)
- {
- $current = strpos(substr($str, $start), '"');
-
- if ($current === FALSE) break;
-
- $one_before = substr($str, $start+$current-1, 1);
- $one_after = substr($str, $start+$current+1, 1);
-
- if ( ! in_array($one_after, $space, TRUE))
- {
- $str = str_replace( $one_before.'"'.$one_after,
- $one_before."&#8220;".$one_after,
- $str);
- }
- elseif( ! in_array($one_before, $space, TRUE))
- {
- $str = str_replace( $one_before."'".$one_after,
- $one_before."&#8221;".$one_after,
- $str);
- }
-
- $start = $start+$current+2;
- }
-
- $start = 0;
-
- while(TRUE)
- {
- $current = strpos(substr($str, $start), "'");
-
- if ($current === FALSE) break;
-
- $one_before = substr($str, $start+$current-1, 1);
- $one_after = substr($str, $start+$current+1, 1);
-
- if ( ! in_array($one_after, $space, TRUE))
- {
- $str = str_replace( $one_before."'".$one_after,
- $one_before."&#8216;".$one_after,
- $str);
- }
- elseif( ! in_array($one_before, $space, TRUE))
- {
- $str = str_replace( $one_before."'".$one_after,
- $one_before."&#8217;".$one_after,
- $str);
- }
-
- $start = $start+$current+2;
- }
-
- return $str;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Format Newlines
- *
- * Converts newline characters into either <p> tags or <br />
- *
- */
- function format_newlines($str)
- {
- if ($str == '')
- {
- return $str;
- }
-
- if (strpos($str, "\n") === FALSE)
- {
- return '<p>'.$str.'</p>';
- }
-
- $str = str_replace("\n\n", "</p>\n\n<p>", $str);
- $str = preg_replace("/([^\n])(\n)([^\n])/", "\\1<br />\\2\\3", $str);
-
- return '<p>'.$str.'</p>';
- }
-}
-
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Typography Helpers
+ *
+ * @package CodeIgniter
+ * @subpackage Helpers
+ * @category Helpers
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/helpers/typography_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Convert newlines to HTML line breaks except within PRE tags
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+function nl2br_except_pre($str)
+{
+ $ex = explode("pre>",$str);
+ $ct = count($ex);
+
+ $newstr = "";
+ for ($i = 0; $i < $ct; $i++)
+ {
+ if (($i % 2) == 0)
+ {
+ $newstr .= nl2br($ex[$i]);
+ }
+ else
+ {
+ $newstr .= $ex[$i];
+ }
+
+ if ($ct - 1 != $i)
+ $newstr .= "pre>";
+ }
+
+ return $newstr;
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Auto Typography Wrapper Function
+ *
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+function auto_typography($str)
+{
+ $TYPE = new Auto_typography();
+ return $TYPE->convert($str);
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Auto Typography Class
+ *
+ *
+ * @access private
+ * @category Helpers
+ * @author Rick Ellis
+ * @author Paul Burdick
+ * @link http://www.codeigniter.com/user_guide/helpers/
+ */
+class Auto_typography {
+
+ // Block level elements that should not be wrapped inside <p> tags
+ var $block_elements = 'div|blockquote|pre|code|h\d|script|ol|un';
+
+ // Elements that should not have <p> and <br /> tags within them.
+ var $skip_elements = 'pre|ol|ul';
+
+ // Tags we want the parser to completely ignore when splitting the string.
+ var $ignore_elements = 'a|b|i|em|strong|span|img|li';
+
+
+ /**
+ * Main Processing Function
+ *
+ */
+ function convert($str)
+ {
+ if ($str == '')
+ {
+ return '';
+ }
+
+ $str = ' '.$str.' ';
+
+ // Standardize Newlines to make matching easier
+ $str = preg_replace("/(\r\n|\r)/", "\n", $str);
+
+ /*
+ * Reduce line breaks
+ *
+ * If there are more than two consecutive line
+ * breaks we'll compress them down to a maximum
+ * of two since there's no benefit to more.
+ *
+ */
+ $str = preg_replace("/\n\n+/", "\n\n", $str);
+
+ /*
+ * Convert quotes within tags to temporary marker
+ *
+ * We don't want quotes converted within
+ * tags so we'll temporarily convert them to
+ * {@DQ} and {@SQ}
+ *
+ */
+ if (preg_match_all("#\<.+?>#si", $str, $matches))
+ {
+ for ($i = 0; $i < count($matches['0']); $i++)
+ {
+ $str = str_replace($matches['0'][$i],
+ str_replace(array("'",'"'), array('{@SQ}', '{@DQ}'), $matches['0'][$i]),
+ $str);
+ }
+ }
+
+
+ /*
+ * Add closing/opening paragraph tags before/after "block" elements
+ *
+ * Since block elements (like <blockquotes>, <pre>, etc.) do not get
+ * wrapped in paragraph tags we will add a closing </p> tag just before
+ * each block element starts and an opening <p> tag right after the block element
+ * ends. Later on we'll do some further clean up.
+ *
+ */
+ $str = preg_replace("#(<.*?)(".$this->block_elements.")(.*?>)#", "</p>\\1\\2\\3", $str);
+ $str = preg_replace("#(</.*?)(".$this->block_elements.")(.*?>)#", "\\1\\2\\3<p>", $str);
+
+ /*
+ * Convert "ignore" tags to temporary marker
+ *
+ * The parser splits out the string at every tag
+ * it encounters. Certain inline tags, like image
+ * tags, links, span tags, etc. will be adversely
+ * affected if they are split out so we'll convert
+ * the opening < temporarily to: {@TAG}
+ *
+ */
+ $str = preg_replace("#<(/*)(".$this->ignore_elements.")#i", "{@TAG}\\1\\2", $str);
+
+ /*
+ * Split the string at every tag
+ *
+ * This creates an array with this prototype:
+ *
+ * [array]
+ * {
+ * [0] = <opening tag>
+ * [1] = Content contained between the tags
+ * [2] = <closing tag>
+ * Etc...
+ * }
+ *
+ */
+ $chunks = preg_split('/(<(?:[^<>]+(?:"[^"]*"|\'[^\']*\')?)+>)/', $str, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
+
+ /*
+ * Build our finalized string
+ *
+ * We'll cycle through the array, skipping tags,
+ * and processing the contained text
+ *
+ */
+ $str = '';
+ $process = TRUE;
+ foreach ($chunks as $chunk)
+ {
+ /*
+ * Are we dealing with a tag?
+ *
+ * If so, we'll skip the processing for this cycle.
+ * Well also set the "process" flag which allows us
+ * to skip <pre> tags and a few other things.
+ *
+ */
+ if (preg_match("#<(/*)(".$this->block_elements.").*?\>#", $chunk, $match))
+ {
+ if (preg_match("#".$this->skip_elements."#", $match['2']))
+ {
+ $process = ($match['1'] == '/') ? TRUE : FALSE;
+ }
+
+ $str .= $chunk;
+ continue;
+ }
+
+ if ($process == FALSE)
+ {
+ $str .= $chunk;
+ continue;
+ }
+
+ // Convert Newlines into <p> and <br /> tags
+ $str .= $this->format_newlines($chunk);
+ }
+
+ // FINAL CLEAN UP
+ // IMPORTANT: DO NOT ALTER THE ORDER OF THE ITEMS BELOW!
+
+ /*
+ * Clean up paragraph tags before/after "block" elements
+ *
+ * Earlier we added <p></p> tags before/after block level elements.
+ * Then, we added paragraph tags around double line breaks. This
+ * potentially created incorrectly formatted paragraphs so we'll
+ * clean it up here.
+ *
+ */
+ $str = preg_replace("#<p>({@TAG}.*?)(".$this->block_elements.")(.*?>)#", "\\1\\2\\3", $str);
+ $str = preg_replace("#({@TAG}/.*?)(".$this->block_elements.")(.*?>)</p>#", "\\1\\2\\3", $str);
+
+ // Convert Quotes and other characters
+ $str = $this->format_characters($str);
+
+ // Fix an artifact that happens during the paragraph replacement
+ $str = preg_replace('#(<p>\n*</p>)#', '', $str);
+
+ // If the user submitted their own paragraph tags with class data
+ // in them we will retain them instead of using our tags.
+ $str = preg_replace('#(<p.*?>)<p>#', "\\1", $str);
+
+ // Final clean up
+ $str = str_replace(
+ array(
+ '</p></p>',
+ '</p><p>',
+ '<p> ',
+ ' </p>',
+ '{@TAG}',
+ '{@DQ}',
+ '{@SQ}',
+ '<p></p>'
+ ),
+ array(
+ '</p>',
+ '<p>',
+ '<p>',
+ '</p>',
+ '<',
+ '"',
+ "'",
+ ''
+ ),
+ $str
+ );
+
+ return $str;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Format Characters
+ *
+ * This function mainly converts double and single quotes
+ * to entities, but since these are directional, it does
+ * it based on some rules. It also converts em-dashes
+ * and a couple other things.
+ */
+ function format_characters($str)
+ {
+ $table = array(
+ ' "' => " &#8220;",
+ '" ' => "&#8221; ",
+ " '" => " &#8216;",
+ "' " => "&#8217; ",
+
+ '>"' => ">&#8220;",
+ '"<' => "&#8221;<",
+ ">'" => ">&#8216;",
+ "'<" => "&#8217;<",
+
+ "\"." => "&#8221;.",
+ "\"," => "&#8221;,",
+ "\";" => "&#8221;;",
+ "\":" => "&#8221;:",
+ "\"!" => "&#8221;!",
+ "\"?" => "&#8221;?",
+
+ ". " => ".&nbsp; ",
+ "? " => "?&nbsp; ",
+ "! " => "!&nbsp; ",
+ ": " => ":&nbsp; ",
+ );
+
+ // These deal with quotes within quotes, like: "'hi here'"
+ $start = 0;
+ $space = array("\n", "\t", " ");
+
+ while(TRUE)
+ {
+ $current = strpos(substr($str, $start), "\"'");
+
+ if ($current === FALSE) break;
+
+ $one_before = substr($str, $start+$current-1, 1);
+ $one_after = substr($str, $start+$current+2, 1);
+
+ if ( ! in_array($one_after, $space, TRUE) && $one_after != "<")
+ {
+ $str = str_replace( $one_before."\"'".$one_after,
+ $one_before."&#8220;&#8216;".$one_after,
+ $str);
+ }
+ elseif ( ! in_array($one_before, $space, TRUE) && (in_array($one_after, $space, TRUE) OR $one_after == '<'))
+ {
+ $str = str_replace( $one_before."\"'".$one_after,
+ $one_before."&#8221;&#8217;".$one_after,
+ $str);
+ }
+
+ $start = $start+$current+2;
+ }
+
+ $start = 0;
+
+ while(TRUE)
+ {
+ $current = strpos(substr($str, $start), "'\"");
+
+ if ($current === FALSE) break;
+
+ $one_before = substr($str, $start+$current-1, 1);
+ $one_after = substr($str, $start+$current+2, 1);
+
+ if ( in_array($one_before, $space, TRUE) && ! in_array($one_after, $space, TRUE) && $one_after != "<")
+ {
+ $str = str_replace( $one_before."'\"".$one_after,
+ $one_before."&#8216;&#8220;".$one_after,
+ $str);
+ }
+ elseif ( ! in_array($one_before, $space, TRUE) && $one_before != ">")
+ {
+ $str = str_replace( $one_before."'\"".$one_after,
+ $one_before."&#8217;&#8221;".$one_after,
+ $str);
+ }
+
+ $start = $start+$current+2;
+ }
+
+ // Are there quotes within a word, as in: ("something")
+ if (preg_match_all("/(.)\"(\S+?)\"(.)/", $str, $matches))
+ {
+ for ($i=0, $s=sizeof($matches['0']); $i < $s; ++$i)
+ {
+ if ( ! in_array($matches['1'][$i], $space, TRUE) && ! in_array($matches['3'][$i], $space, TRUE))
+ {
+ $str = str_replace( $matches['0'][$i],
+ $matches['1'][$i]."&#8220;".$matches['2'][$i]."&#8221;".$matches['3'][$i],
+ $str);
+ }
+ }
+ }
+
+ if (preg_match_all("/(.)\'(\S+?)\'(.)/", $str, $matches))
+ {
+ for ($i=0, $s=sizeof($matches['0']); $i < $s; ++$i)
+ {
+ if ( ! in_array($matches['1'][$i], $space, TRUE) && ! in_array($matches['3'][$i], $space, TRUE))
+ {
+ $str = str_replace( $matches['0'][$i],
+ $matches['1'][$i]."&#8216;".$matches['2'][$i]."&#8217;".$matches['3'][$i],
+ $str);
+ }
+ }
+ }
+
+ // How about one apostrophe, as in Rick's
+ $start = 0;
+
+ while(TRUE)
+ {
+ $current = strpos(substr($str, $start), "'");
+
+ if ($current === FALSE) break;
+
+ $one_before = substr($str, $start+$current-1, 1);
+ $one_after = substr($str, $start+$current+1, 1);
+
+ if ( ! in_array($one_before, $space, TRUE) && ! in_array($one_after, $space, TRUE))
+ {
+ $str = str_replace( $one_before."'".$one_after,
+ $one_before."&#8217;".$one_after,
+ $str);
+ }
+
+ $start = $start+$current+2;
+ }
+
+ // Em-dashes
+ $start = 0;
+ while(TRUE)
+ {
+ $current = strpos(substr($str, $start), "--");
+
+ if ($current === FALSE) break;
+
+ $one_before = substr($str, $start+$current-1, 1);
+ $one_after = substr($str, $start+$current+2, 1);
+ $two_before = substr($str, $start+$current-2, 1);
+ $two_after = substr($str, $start+$current+3, 1);
+
+ if (( ! in_array($one_before, $space, TRUE) && ! in_array($one_after, $space, TRUE))
+ OR
+ ( ! in_array($two_before, $space, TRUE) && ! in_array($two_after, $space, TRUE) && $one_before == ' ' && $one_after == ' ')
+ )
+ {
+ $str = str_replace( $two_before.$one_before."--".$one_after.$two_after,
+ $two_before.trim($one_before)."&#8212;".trim($one_after).$two_after,
+ $str);
+ }
+
+ $start = $start+$current+2;
+ }
+
+ // Ellipsis
+ $str = preg_replace("#(\w)\.\.\.(\s|<br />|</p>)#", "\\1&#8230;\\2", $str);
+ $str = preg_replace("#(\s|<br />|</p>)\.\.\.(\w)#", "\\1&#8230;\\2", $str);
+
+ // Run the translation array we defined above
+ $str = str_replace(array_keys($table), array_values($table), $str);
+
+ // If there are any stray double quotes we'll catch them here
+
+ $start = 0;
+
+ while(TRUE)
+ {
+ $current = strpos(substr($str, $start), '"');
+
+ if ($current === FALSE) break;
+
+ $one_before = substr($str, $start+$current-1, 1);
+ $one_after = substr($str, $start+$current+1, 1);
+
+ if ( ! in_array($one_after, $space, TRUE))
+ {
+ $str = str_replace( $one_before.'"'.$one_after,
+ $one_before."&#8220;".$one_after,
+ $str);
+ }
+ elseif( ! in_array($one_before, $space, TRUE))
+ {
+ $str = str_replace( $one_before."'".$one_after,
+ $one_before."&#8221;".$one_after,
+ $str);
+ }
+
+ $start = $start+$current+2;
+ }
+
+ $start = 0;
+
+ while(TRUE)
+ {
+ $current = strpos(substr($str, $start), "'");
+
+ if ($current === FALSE) break;
+
+ $one_before = substr($str, $start+$current-1, 1);
+ $one_after = substr($str, $start+$current+1, 1);
+
+ if ( ! in_array($one_after, $space, TRUE))
+ {
+ $str = str_replace( $one_before."'".$one_after,
+ $one_before."&#8216;".$one_after,
+ $str);
+ }
+ elseif( ! in_array($one_before, $space, TRUE))
+ {
+ $str = str_replace( $one_before."'".$one_after,
+ $one_before."&#8217;".$one_after,
+ $str);
+ }
+
+ $start = $start+$current+2;
+ }
+
+ return $str;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Format Newlines
+ *
+ * Converts newline characters into either <p> tags or <br />
+ *
+ */
+ function format_newlines($str)
+ {
+ if ($str == '')
+ {
+ return $str;
+ }
+
+ if (strpos($str, "\n") === FALSE)
+ {
+ return '<p>'.$str.'</p>';
+ }
+
+ $str = str_replace("\n\n", "</p>\n\n<p>", $str);
+ $str = preg_replace("/([^\n])(\n)([^\n])/", "\\1<br />\\2\\3", $str);
+
+ return '<p>'.$str.'</p>';
+ }
+}
+
+
?> \ No newline at end of file
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index baac0e5d8..c05bc2088 100644
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -1,12 +1,12 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
- * Code Igniter
+ * CodeIgniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
* @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
* @license http://www.codeignitor.com/user_guide/license.html
* @link http://www.codeigniter.com
* @since Version 1.0
@@ -16,7 +16,7 @@
// ------------------------------------------------------------------------
/**
- * Code Igniter URL Helpers
+ * CodeIgniter URL Helpers
*
* @package CodeIgniter
* @subpackage Helpers
diff --git a/system/helpers/xml_helper.php b/system/helpers/xml_helper.php
index 856722b32..398b07e3f 100644
--- a/system/helpers/xml_helper.php
+++ b/system/helpers/xml_helper.php
@@ -1,58 +1,58 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Igniter XML Helpers
- *
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/helpers/xml_helper.html
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Convert Reserved XML characters to Entities
- *
- * @access public
- * @param string
- * @return string
- */
-function xml_convert($str)
-{
- $temp = '__TEMP_AMPERSANDS__';
-
- // Replace entities to temporary markers so that
- // ampersands won't get messed up
- $str = preg_replace("/&#(\d+);/", "$temp\\1;", $str);
- $str = preg_replace("/&(\w+);/", "$temp\\1;", $str);
-
- $str = str_replace(array("&","<",">","\"", "'", "-"),
- array("&amp;", "&lt;", "&gt;", "&quot;", "&#39;", "&#45;"),
- $str);
-
- // Decode the temp markers back to entities
- $str = preg_replace("/$temp(\d+);/","&#\\1;",$str);
- $str = preg_replace("/$temp(\w+);/","&\\1;", $str);
-
- return $str;
-}
-
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter XML Helpers
+ *
+ * @package CodeIgniter
+ * @subpackage Helpers
+ * @category Helpers
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/helpers/xml_helper.html
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Convert Reserved XML characters to Entities
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+function xml_convert($str)
+{
+ $temp = '__TEMP_AMPERSANDS__';
+
+ // Replace entities to temporary markers so that
+ // ampersands won't get messed up
+ $str = preg_replace("/&#(\d+);/", "$temp\\1;", $str);
+ $str = preg_replace("/&(\w+);/", "$temp\\1;", $str);
+
+ $str = str_replace(array("&","<",">","\"", "'", "-"),
+ array("&amp;", "&lt;", "&gt;", "&quot;", "&#39;", "&#45;"),
+ $str);
+
+ // Decode the temp markers back to entities
+ $str = preg_replace("/$temp(\d+);/","&#\\1;",$str);
+ $str = preg_replace("/$temp(\w+);/","&\\1;", $str);
+
+ return $str;
+}
+
+
?> \ No newline at end of file
diff --git a/system/libraries/Benchmark.php b/system/libraries/Benchmark.php
index 66e8a24cf..cf980a81e 100644
--- a/system/libraries/Benchmark.php
+++ b/system/libraries/Benchmark.php
@@ -1,111 +1,111 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Igniter 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 Rick Ellis
- * @link http://www.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
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.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 Rick Ellis
+ * @link http://www.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
?> \ No newline at end of file
diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php
index fdef5dd75..ef6a3f841 100644
--- a/system/libraries/Calendar.php
+++ b/system/libraries/Calendar.php
@@ -1,475 +1,475 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Igniter Calendar Class
- *
- * This class enables the creation of calendars
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Libraries
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/libraries/calendar.html
- */
-class CI_Calendar {
-
- var $CI;
- var $lang;
- var $local_time;
- var $template = '';
- var $start_day = 'sunday';
- var $month_type = 'long';
- var $day_type = 'abr';
- var $show_next_prev = FALSE;
- var $next_prev_url = '';
-
- /**
- * Constructor
- *
- * Loads the calendar language file and sets the default time reference
- *
- * @access public
- */
- function CI_Calendar($config = array())
- {
- $this->CI =& get_instance();
-
- if ( ! in_array('calendar_lang'.EXT, $this->CI->lang->is_loaded, TRUE))
- {
- $this->CI->lang->load('calendar');
- }
-
- $this->local_time = time();
-
- if (count($config) > 0)
- {
- $this->initialize($config);
- }
-
- log_message('debug', "Calendar Class Initialized");
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Initialize the user preferences
- *
- * Accepts an associative array as input, containing display preferences
- *
- * @access public
- * @param array config preferences
- * @return void
- */
- function initialize($config = array())
- {
- foreach ($config as $key => $val)
- {
- if (isset($this->$key))
- {
- $this->$key = $val;
- }
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Generate the calendar
- *
- * @access public
- * @param integer the year
- * @param integer the month
- * @param array the data to be shown in the calendar cells
- * @return string
- */
- function generate($year = '', $month = '', $data = array())
- {
- // Set and validate the supplied month/year
- if ($year == '')
- $year = date("Y", $this->local_time);
-
- if ($month == '')
- $month = date("m", $this->local_time);
-
- if (strlen($year) == 1)
- $year = '200'.$year;
-
- if (strlen($year) == 2)
- $year = '20'.$year;
-
- if (strlen($month) == 1)
- $month = '0'.$month;
-
- $adjusted_date = $this->adjust_date($month, $year);
-
- $month = $adjusted_date['month'];
- $year = $adjusted_date['year'];
-
- // Determine the total days in the month
- $total_days = $this->get_total_days($month, $year);
-
- // Set the starting day of the week
- $start_days = array('sunday' => 0, 'monday' => 1, 'tuesday' => 2, 'wednesday' => 3, 'thursday' => 4, 'friday' => 5, 'saturday' => 6);
- $start_day = ( ! isset($start_days[$this->start_day])) ? 0 : $start_days[$this->start_day];
-
- // Set the starting day number
- $local_date = mktime(12, 0, 0, $month, 1, $year);
- $date = getdate($local_date);
- $day = $start_day + 1 - $date["wday"];
-
- while ($day > 1)
- {
- $day -= 7;
- }
-
- // Set the current month/year/day
- // We use this to determine the "today" date
- $cur_year = date("Y", $this->local_time);
- $cur_month = date("m", $this->local_time);
- $cur_day = date("j", $this->local_time);
-
- $is_current_month = ($cur_year == $year AND $cur_month == $month) ? TRUE : FALSE;
-
- // Generate the template data array
- $this->parse_template();
-
- // Begin building the calendar output
- $out = $this->temp['table_open'];
- $out .= "\n";
-
- $out .= "\n";
- $out .= $this->temp['heading_row_start'];
- $out .= "\n";
-
- // "previous" month link
- if ($this->show_next_prev == TRUE)
- {
- // Add a trailing slash to the URL if needed
- $this->next_prev_url = preg_replace("/(.+?)\/*$/", "\\1/", $this->next_prev_url);
-
- $adjusted_date = $this->adjust_date($month - 1, $year);
- $out .= str_replace('{previous_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_previous_cell']);
- $out .= "\n";
- }
-
- // Heading containing the month/year
- $colspan = ($this->show_next_prev == TRUE) ? 5 : 7;
-
- $this->temp['heading_title_cell'] = str_replace('{colspan}', $colspan, $this->temp['heading_title_cell']);
- $this->temp['heading_title_cell'] = str_replace('{heading}', $this->get_month_name($month)."&nbsp;".$year, $this->temp['heading_title_cell']);
-
- $out .= $this->temp['heading_title_cell'];
- $out .= "\n";
-
- // "next" month link
- if ($this->show_next_prev == TRUE)
- {
- $adjusted_date = $this->adjust_date($month + 1, $year);
- $out .= str_replace('{next_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_next_cell']);
- }
-
- $out .= "\n";
- $out .= $this->temp['heading_row_end'];
- $out .= "\n";
-
- // Write the cells containing the days of the week
- $out .= "\n";
- $out .= $this->temp['week_row_start'];
- $out .= "\n";
-
- $day_names = $this->get_day_names();
-
- for ($i = 0; $i < 7; $i ++)
- {
- $out .= str_replace('{week_day}', $day_names[($start_day + $i) %7], $this->temp['week_day_cell']);
- }
-
- $out .= "\n";
- $out .= $this->temp['week_row_end'];
- $out .= "\n";
-
- // Build the main body of the calendar
- while ($day <= $total_days)
- {
- $out .= "\n";
- $out .= $this->temp['cal_row_start'];
- $out .= "\n";
-
- for ($i = 0; $i < 7; $i++)
- {
- $out .= ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_start_today'] : $this->temp['cal_cell_start'];
-
- if ($day > 0 AND $day <= $total_days)
- {
- if (isset($data[$day]))
- {
- // Cells with content
- $temp = ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content'];
- $out .= str_replace('{day}', $day, str_replace('{content}', $data[$day], $temp));
- }
- else
- {
- // Cells with no content
- $temp = ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_no_content_today'] : $this->temp['cal_cell_no_content'];
- $out .= str_replace('{day}', $day, $temp);
- }
- }
- else
- {
- // Blank cells
- $out .= $this->temp['cal_cell_blank'];
- }
-
- $out .= ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_end_today'] : $this->temp['cal_cell_end'];
- $day++;
- }
-
- $out .= "\n";
- $out .= $this->temp['cal_row_end'];
- $out .= "\n";
- }
-
- $out .= "\n";
- $out .= $this->temp['table_close'];
-
- return $out;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Get Month Name
- *
- * Generates a textual month name based on the numeric
- * month provided.
- *
- * @access public
- * @param integer the month
- * @return string
- */
- function get_month_name($month)
- {
- if ($this->month_type == 'short')
- {
- $month_names = array('01' => 'cal_jan', '02' => 'cal_feb', '03' => 'cal_mar', '04' => 'cal_apr', '05' => 'cal_may', '06' => 'cal_jun', '07' => 'cal_jul', '08' => 'cal_aug', '09' => 'cal_sep', '10' => 'cal_oct', '11' => 'cal_nov', '12' => 'cal_dec');
- }
- else
- {
- $month_names = array('01' => 'cal_january', '02' => 'cal_february', '03' => 'cal_march', '04' => 'cal_april', '05' => 'cal_mayl', '06' => 'cal_june', '07' => 'cal_july', '08' => 'cal_august', '09' => 'cal_september', '10' => 'cal_october', '11' => 'cal_november', '12' => 'cal_december');
- }
-
- $month = $month_names[$month];
-
- if ($this->CI->lang->line($month) === FALSE)
- {
- return ucfirst(str_replace('cal_', '', $month));
- }
-
- return $this->CI->lang->line($month);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Get Day Names
- *
- * Returns an array of day names (Sunday, Monday, etc.) based
- * on the type. Options: long, short, abrev
- *
- * @access public
- * @param string
- * @return array
- */
- function get_day_names($day_type = '')
- {
- if ($day_type != '')
- $this->day_type = $day_type;
-
- if ($this->day_type == 'long')
- {
- $day_names = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
- }
- elseif ($this->day_type == 'short')
- {
- $day_names = array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat');
- }
- else
- {
- $day_names = array('su', 'mo', 'tu', 'we', 'th', 'fr', 'sa');
- }
-
- $days = array();
- foreach ($day_names as $val)
- {
- $days[] = ($this->CI->lang->line('cal_'.$val) === FALSE) ? ucfirst($val) : $this->CI->lang->line('cal_'.$val);
- }
-
- return $days;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Adjust Date
- *
- * This function makes sure that we have a valid month/year.
- * For example, if you submit 13 as the month, the year will
- * increment and the month will become January.
- *
- * @access public
- * @param integer the month
- * @param integer the year
- * @return array
- */
- function adjust_date($month, $year)
- {
- $date = array();
-
- $date['month'] = $month;
- $date['year'] = $year;
-
- while ($date['month'] > 12)
- {
- $date['month'] -= 12;
- $date['year']++;
- }
-
- while ($date['month'] <= 0)
- {
- $date['month'] += 12;
- $date['year']--;
- }
-
- if (strlen($date['month']) == 1)
- {
- $date['month'] = '0'.$date['month'];
- }
-
- return $date;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Total days in a given month
- *
- * @access public
- * @param integer the month
- * @param integer the year
- * @return integer
- */
- function get_total_days($month, $year)
- {
- $days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
-
- if ($month < 1 OR $month > 12)
- {
- return 0;
- }
-
- // Is the year a leap year?
- if ($month == 2)
- {
- if ($year % 400 == 0 OR ($year % 4 == 0 AND $year % 100 != 0))
- {
- return 29;
- }
- }
-
- return $days_in_month[$month - 1];
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Default Template Data
- *
- * This is used in the event that the user has not created their own template
- *
- * @access public
- * @return array
- */
- function default_template()
- {
- return array (
- 'table_open' => '<table border="0" cellpadding="4" cellspacing="0">',
- 'heading_row_start' => '<tr>',
- 'heading_previous_cell' => '<th><a href="{previous_url}">&lt;&lt;</a></th>',
- 'heading_title_cell' => '<th colspan="{colspan}">{heading}</th>',
- 'heading_next_cell' => '<th><a href="{next_url}">&gt;&gt;</a></th>',
- 'heading_row_end' => '</tr>',
- 'week_row_start' => '<tr>',
- 'week_day_cell' => '<td>{week_day}</td>',
- 'week_row_end' => '</tr>',
- 'cal_row_start' => '<tr>',
- 'cal_cell_start' => '<td>',
- 'cal_cell_start_today' => '<td>',
- 'cal_cell_content' => '<a href="{content}">{day}</a>',
- 'cal_cell_content_today' => '<a href="{content}"><strong>{day}</strong></a>',
- 'cal_cell_no_content' => '{day}',
- 'cal_cell_no_content_today' => '<strong>{day}</strong>',
- 'cal_cell_blank' => '&nbsp;',
- 'cal_cell_end' => '</td>',
- 'cal_cell_end_today' => '</td>',
- 'cal_row_end' => '</tr>',
- 'table_close' => '</table>'
- );
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Parse Template
- *
- * Harvests the data within the template {pseudo-variables}
- * used to display the calendar
- *
- * @access public
- * @return void
- */
- function parse_template()
- {
- $this->temp = $this->default_template();
-
- if ($this->template == '')
- {
- return;
- }
-
- $today = array('cal_cell_start_today', 'cal_cell_content_today', 'cal_cell_no_content_today', 'cal_cell_end_today');
-
- foreach (array('table_open', 'table_close', 'heading_row_start', 'heading_previous_cell', 'heading_title_cell', 'heading_next_cell', 'heading_row_end', 'week_row_start', 'week_day_cell', 'week_row_end', 'cal_row_start', 'cal_cell_start', 'cal_cell_content', 'cal_cell_no_content', 'cal_cell_blank', 'cal_cell_end', 'cal_row_end', 'cal_cell_start_today', 'cal_cell_content_today', 'cal_cell_no_content_today', 'cal_cell_end_today') as $val)
- {
- if (preg_match("/\{".$val."\}(.*?)\{\/".$val."\}/si", $this->template, $match))
- {
- $this->temp[$val] = $match['1'];
- }
- else
- {
- if (in_array($val, $today, TRUE))
- {
- $this->temp[$val] = $this->temp[str_replace('_today', '', $val)];
- }
- }
- }
- }
-
-}
-
-// END CI_Calendar class
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Calendar Class
+ *
+ * This class enables the creation of calendars
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category Libraries
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/libraries/calendar.html
+ */
+class CI_Calendar {
+
+ var $CI;
+ var $lang;
+ var $local_time;
+ var $template = '';
+ var $start_day = 'sunday';
+ var $month_type = 'long';
+ var $day_type = 'abr';
+ var $show_next_prev = FALSE;
+ var $next_prev_url = '';
+
+ /**
+ * Constructor
+ *
+ * Loads the calendar language file and sets the default time reference
+ *
+ * @access public
+ */
+ function CI_Calendar($config = array())
+ {
+ $this->CI =& get_instance();
+
+ if ( ! in_array('calendar_lang'.EXT, $this->CI->lang->is_loaded, TRUE))
+ {
+ $this->CI->lang->load('calendar');
+ }
+
+ $this->local_time = time();
+
+ if (count($config) > 0)
+ {
+ $this->initialize($config);
+ }
+
+ log_message('debug', "Calendar Class Initialized");
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Initialize the user preferences
+ *
+ * Accepts an associative array as input, containing display preferences
+ *
+ * @access public
+ * @param array config preferences
+ * @return void
+ */
+ function initialize($config = array())
+ {
+ foreach ($config as $key => $val)
+ {
+ if (isset($this->$key))
+ {
+ $this->$key = $val;
+ }
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Generate the calendar
+ *
+ * @access public
+ * @param integer the year
+ * @param integer the month
+ * @param array the data to be shown in the calendar cells
+ * @return string
+ */
+ function generate($year = '', $month = '', $data = array())
+ {
+ // Set and validate the supplied month/year
+ if ($year == '')
+ $year = date("Y", $this->local_time);
+
+ if ($month == '')
+ $month = date("m", $this->local_time);
+
+ if (strlen($year) == 1)
+ $year = '200'.$year;
+
+ if (strlen($year) == 2)
+ $year = '20'.$year;
+
+ if (strlen($month) == 1)
+ $month = '0'.$month;
+
+ $adjusted_date = $this->adjust_date($month, $year);
+
+ $month = $adjusted_date['month'];
+ $year = $adjusted_date['year'];
+
+ // Determine the total days in the month
+ $total_days = $this->get_total_days($month, $year);
+
+ // Set the starting day of the week
+ $start_days = array('sunday' => 0, 'monday' => 1, 'tuesday' => 2, 'wednesday' => 3, 'thursday' => 4, 'friday' => 5, 'saturday' => 6);
+ $start_day = ( ! isset($start_days[$this->start_day])) ? 0 : $start_days[$this->start_day];
+
+ // Set the starting day number
+ $local_date = mktime(12, 0, 0, $month, 1, $year);
+ $date = getdate($local_date);
+ $day = $start_day + 1 - $date["wday"];
+
+ while ($day > 1)
+ {
+ $day -= 7;
+ }
+
+ // Set the current month/year/day
+ // We use this to determine the "today" date
+ $cur_year = date("Y", $this->local_time);
+ $cur_month = date("m", $this->local_time);
+ $cur_day = date("j", $this->local_time);
+
+ $is_current_month = ($cur_year == $year AND $cur_month == $month) ? TRUE : FALSE;
+
+ // Generate the template data array
+ $this->parse_template();
+
+ // Begin building the calendar output
+ $out = $this->temp['table_open'];
+ $out .= "\n";
+
+ $out .= "\n";
+ $out .= $this->temp['heading_row_start'];
+ $out .= "\n";
+
+ // "previous" month link
+ if ($this->show_next_prev == TRUE)
+ {
+ // Add a trailing slash to the URL if needed
+ $this->next_prev_url = preg_replace("/(.+?)\/*$/", "\\1/", $this->next_prev_url);
+
+ $adjusted_date = $this->adjust_date($month - 1, $year);
+ $out .= str_replace('{previous_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_previous_cell']);
+ $out .= "\n";
+ }
+
+ // Heading containing the month/year
+ $colspan = ($this->show_next_prev == TRUE) ? 5 : 7;
+
+ $this->temp['heading_title_cell'] = str_replace('{colspan}', $colspan, $this->temp['heading_title_cell']);
+ $this->temp['heading_title_cell'] = str_replace('{heading}', $this->get_month_name($month)."&nbsp;".$year, $this->temp['heading_title_cell']);
+
+ $out .= $this->temp['heading_title_cell'];
+ $out .= "\n";
+
+ // "next" month link
+ if ($this->show_next_prev == TRUE)
+ {
+ $adjusted_date = $this->adjust_date($month + 1, $year);
+ $out .= str_replace('{next_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_next_cell']);
+ }
+
+ $out .= "\n";
+ $out .= $this->temp['heading_row_end'];
+ $out .= "\n";
+
+ // Write the cells containing the days of the week
+ $out .= "\n";
+ $out .= $this->temp['week_row_start'];
+ $out .= "\n";
+
+ $day_names = $this->get_day_names();
+
+ for ($i = 0; $i < 7; $i ++)
+ {
+ $out .= str_replace('{week_day}', $day_names[($start_day + $i) %7], $this->temp['week_day_cell']);
+ }
+
+ $out .= "\n";
+ $out .= $this->temp['week_row_end'];
+ $out .= "\n";
+
+ // Build the main body of the calendar
+ while ($day <= $total_days)
+ {
+ $out .= "\n";
+ $out .= $this->temp['cal_row_start'];
+ $out .= "\n";
+
+ for ($i = 0; $i < 7; $i++)
+ {
+ $out .= ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_start_today'] : $this->temp['cal_cell_start'];
+
+ if ($day > 0 AND $day <= $total_days)
+ {
+ if (isset($data[$day]))
+ {
+ // Cells with content
+ $temp = ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content'];
+ $out .= str_replace('{day}', $day, str_replace('{content}', $data[$day], $temp));
+ }
+ else
+ {
+ // Cells with no content
+ $temp = ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_no_content_today'] : $this->temp['cal_cell_no_content'];
+ $out .= str_replace('{day}', $day, $temp);
+ }
+ }
+ else
+ {
+ // Blank cells
+ $out .= $this->temp['cal_cell_blank'];
+ }
+
+ $out .= ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_end_today'] : $this->temp['cal_cell_end'];
+ $day++;
+ }
+
+ $out .= "\n";
+ $out .= $this->temp['cal_row_end'];
+ $out .= "\n";
+ }
+
+ $out .= "\n";
+ $out .= $this->temp['table_close'];
+
+ return $out;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get Month Name
+ *
+ * Generates a textual month name based on the numeric
+ * month provided.
+ *
+ * @access public
+ * @param integer the month
+ * @return string
+ */
+ function get_month_name($month)
+ {
+ if ($this->month_type == 'short')
+ {
+ $month_names = array('01' => 'cal_jan', '02' => 'cal_feb', '03' => 'cal_mar', '04' => 'cal_apr', '05' => 'cal_may', '06' => 'cal_jun', '07' => 'cal_jul', '08' => 'cal_aug', '09' => 'cal_sep', '10' => 'cal_oct', '11' => 'cal_nov', '12' => 'cal_dec');
+ }
+ else
+ {
+ $month_names = array('01' => 'cal_january', '02' => 'cal_february', '03' => 'cal_march', '04' => 'cal_april', '05' => 'cal_mayl', '06' => 'cal_june', '07' => 'cal_july', '08' => 'cal_august', '09' => 'cal_september', '10' => 'cal_october', '11' => 'cal_november', '12' => 'cal_december');
+ }
+
+ $month = $month_names[$month];
+
+ if ($this->CI->lang->line($month) === FALSE)
+ {
+ return ucfirst(str_replace('cal_', '', $month));
+ }
+
+ return $this->CI->lang->line($month);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get Day Names
+ *
+ * Returns an array of day names (Sunday, Monday, etc.) based
+ * on the type. Options: long, short, abrev
+ *
+ * @access public
+ * @param string
+ * @return array
+ */
+ function get_day_names($day_type = '')
+ {
+ if ($day_type != '')
+ $this->day_type = $day_type;
+
+ if ($this->day_type == 'long')
+ {
+ $day_names = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
+ }
+ elseif ($this->day_type == 'short')
+ {
+ $day_names = array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat');
+ }
+ else
+ {
+ $day_names = array('su', 'mo', 'tu', 'we', 'th', 'fr', 'sa');
+ }
+
+ $days = array();
+ foreach ($day_names as $val)
+ {
+ $days[] = ($this->CI->lang->line('cal_'.$val) === FALSE) ? ucfirst($val) : $this->CI->lang->line('cal_'.$val);
+ }
+
+ return $days;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Adjust Date
+ *
+ * This function makes sure that we have a valid month/year.
+ * For example, if you submit 13 as the month, the year will
+ * increment and the month will become January.
+ *
+ * @access public
+ * @param integer the month
+ * @param integer the year
+ * @return array
+ */
+ function adjust_date($month, $year)
+ {
+ $date = array();
+
+ $date['month'] = $month;
+ $date['year'] = $year;
+
+ while ($date['month'] > 12)
+ {
+ $date['month'] -= 12;
+ $date['year']++;
+ }
+
+ while ($date['month'] <= 0)
+ {
+ $date['month'] += 12;
+ $date['year']--;
+ }
+
+ if (strlen($date['month']) == 1)
+ {
+ $date['month'] = '0'.$date['month'];
+ }
+
+ return $date;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Total days in a given month
+ *
+ * @access public
+ * @param integer the month
+ * @param integer the year
+ * @return integer
+ */
+ function get_total_days($month, $year)
+ {
+ $days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
+
+ if ($month < 1 OR $month > 12)
+ {
+ return 0;
+ }
+
+ // Is the year a leap year?
+ if ($month == 2)
+ {
+ if ($year % 400 == 0 OR ($year % 4 == 0 AND $year % 100 != 0))
+ {
+ return 29;
+ }
+ }
+
+ return $days_in_month[$month - 1];
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Default Template Data
+ *
+ * This is used in the event that the user has not created their own template
+ *
+ * @access public
+ * @return array
+ */
+ function default_template()
+ {
+ return array (
+ 'table_open' => '<table border="0" cellpadding="4" cellspacing="0">',
+ 'heading_row_start' => '<tr>',
+ 'heading_previous_cell' => '<th><a href="{previous_url}">&lt;&lt;</a></th>',
+ 'heading_title_cell' => '<th colspan="{colspan}">{heading}</th>',
+ 'heading_next_cell' => '<th><a href="{next_url}">&gt;&gt;</a></th>',
+ 'heading_row_end' => '</tr>',
+ 'week_row_start' => '<tr>',
+ 'week_day_cell' => '<td>{week_day}</td>',
+ 'week_row_end' => '</tr>',
+ 'cal_row_start' => '<tr>',
+ 'cal_cell_start' => '<td>',
+ 'cal_cell_start_today' => '<td>',
+ 'cal_cell_content' => '<a href="{content}">{day}</a>',
+ 'cal_cell_content_today' => '<a href="{content}"><strong>{day}</strong></a>',
+ 'cal_cell_no_content' => '{day}',
+ 'cal_cell_no_content_today' => '<strong>{day}</strong>',
+ 'cal_cell_blank' => '&nbsp;',
+ 'cal_cell_end' => '</td>',
+ 'cal_cell_end_today' => '</td>',
+ 'cal_row_end' => '</tr>',
+ 'table_close' => '</table>'
+ );
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Parse Template
+ *
+ * Harvests the data within the template {pseudo-variables}
+ * used to display the calendar
+ *
+ * @access public
+ * @return void
+ */
+ function parse_template()
+ {
+ $this->temp = $this->default_template();
+
+ if ($this->template == '')
+ {
+ return;
+ }
+
+ $today = array('cal_cell_start_today', 'cal_cell_content_today', 'cal_cell_no_content_today', 'cal_cell_end_today');
+
+ foreach (array('table_open', 'table_close', 'heading_row_start', 'heading_previous_cell', 'heading_title_cell', 'heading_next_cell', 'heading_row_end', 'week_row_start', 'week_day_cell', 'week_row_end', 'cal_row_start', 'cal_cell_start', 'cal_cell_content', 'cal_cell_no_content', 'cal_cell_blank', 'cal_cell_end', 'cal_row_end', 'cal_cell_start_today', 'cal_cell_content_today', 'cal_cell_no_content_today', 'cal_cell_end_today') as $val)
+ {
+ if (preg_match("/\{".$val."\}(.*?)\{\/".$val."\}/si", $this->template, $match))
+ {
+ $this->temp[$val] = $match['1'];
+ }
+ else
+ {
+ if (in_array($val, $today, TRUE))
+ {
+ $this->temp[$val] = $this->temp[str_replace('_today', '', $val)];
+ }
+ }
+ }
+ }
+
+}
+
+// END CI_Calendar class
?> \ No newline at end of file
diff --git a/system/libraries/Config.php b/system/libraries/Config.php
index 28409fbc4..831ba925d 100644
--- a/system/libraries/Config.php
+++ b/system/libraries/Config.php
@@ -1,245 +1,245 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Igniter Config Class
- *
- * This class contains functions that enable config files to be managed
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Libraries
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/libraries/config.html
- */
-class CI_Config {
-
- var $config = array();
- var $is_loaded = array();
-
- /**
- * 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 CI_Config()
- {
- $this->config =& get_config();
- log_message('debug', "Config Class Initialized");
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Load Config File
- *
- * @access public
- * @param string the config file name
- * @return boolean if the file was loaded correctly
- */
- function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
- {
- $file = ($file == '') ? 'config' : str_replace(EXT, '', $file);
-
- if (in_array($file, $this->is_loaded, TRUE))
- {
- return TRUE;
- }
-
- if ( ! file_exists(APPPATH.'config/'.$file.EXT))
- {
- if ($fail_gracefully === TRUE)
- {
- return FALSE;
- }
- show_error('The configuration file '.$file.EXT.' does not exist.');
- }
-
- include(APPPATH.'config/'.$file.EXT);
-
- if ( ! isset($config) OR ! is_array($config))
- {
- if ($fail_gracefully === TRUE)
- {
- return FALSE;
- }
- show_error('Your '.$file.EXT.' 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;
- unset($config);
-
- log_message('debug', 'Config file loaded: config/'.$file.EXT);
- 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;
- }
-
- $pref = $this->config[$item];
-
- if ($pref != '')
- {
- if (ereg("/$", $pref) === FALSE)
- {
- $pref .= '/';
- }
- }
-
- return $pref;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Site URL
- *
- * @access public
- * @param string the URI string
- * @return string
- */
- function site_url($uri = '')
- {
- if (is_array($uri))
- {
- $uri = implode('/', $uri);
- }
-
- if ($uri == '')
- {
- return $this->slash_item('base_url').$this->item('index_page');
- }
- else
- {
- $suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix');
- return $this->slash_item('base_url').$this->slash_item('index_page').preg_replace("|^/*(.+?)/*$|", "\\1", $uri).$suffix;
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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;
- }
-
-}
-
-// END CI_Config class
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.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 Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/libraries/config.html
+ */
+class CI_Config {
+
+ var $config = array();
+ var $is_loaded = array();
+
+ /**
+ * 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 CI_Config()
+ {
+ $this->config =& get_config();
+ log_message('debug', "Config Class Initialized");
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Load Config File
+ *
+ * @access public
+ * @param string the config file name
+ * @return boolean if the file was loaded correctly
+ */
+ function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
+ {
+ $file = ($file == '') ? 'config' : str_replace(EXT, '', $file);
+
+ if (in_array($file, $this->is_loaded, TRUE))
+ {
+ return TRUE;
+ }
+
+ if ( ! file_exists(APPPATH.'config/'.$file.EXT))
+ {
+ if ($fail_gracefully === TRUE)
+ {
+ return FALSE;
+ }
+ show_error('The configuration file '.$file.EXT.' does not exist.');
+ }
+
+ include(APPPATH.'config/'.$file.EXT);
+
+ if ( ! isset($config) OR ! is_array($config))
+ {
+ if ($fail_gracefully === TRUE)
+ {
+ return FALSE;
+ }
+ show_error('Your '.$file.EXT.' 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;
+ unset($config);
+
+ log_message('debug', 'Config file loaded: config/'.$file.EXT);
+ 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;
+ }
+
+ $pref = $this->config[$item];
+
+ if ($pref != '')
+ {
+ if (ereg("/$", $pref) === FALSE)
+ {
+ $pref .= '/';
+ }
+ }
+
+ return $pref;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Site URL
+ *
+ * @access public
+ * @param string the URI string
+ * @return string
+ */
+ function site_url($uri = '')
+ {
+ if (is_array($uri))
+ {
+ $uri = implode('/', $uri);
+ }
+
+ if ($uri == '')
+ {
+ return $this->slash_item('base_url').$this->item('index_page');
+ }
+ else
+ {
+ $suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix');
+ return $this->slash_item('base_url').$this->slash_item('index_page').preg_replace("|^/*(.+?)/*$|", "\\1", $uri).$suffix;
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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;
+ }
+
+}
+
+// END CI_Config class
?> \ No newline at end of file
diff --git a/system/libraries/Controller.php b/system/libraries/Controller.php
index c8fa646c7..81421cf31 100644
--- a/system/libraries/Controller.php
+++ b/system/libraries/Controller.php
@@ -1,115 +1,115 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Igniter Application Controller Class
- *
- * This class object is the super class the every library in
- * Code Igniter will be assigned to.
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Libraries
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/general/controllers.html
- */
-class Controller extends CI_Base {
-
- var $_ci_scaffolding = FALSE;
- var $_ci_scaff_table = FALSE;
-
- /**
- * Constructor
- *
- * Calls the initialize() function
- */
- function Controller()
- {
- parent::CI_Base();
- $this->_ci_initialize();
- log_message('debug', "Controller Class Initialized");
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Initialize
- *
- * Assigns all the bases classes loaded by the front controller to
- * variables in this class. Also calls the autoload routine.
- *
- * @access private
- * @return void
- */
- function _ci_initialize()
- {
- // Assign all the class objects that were instantiated by the
- // front controller to local class variables so that CI can be
- // run as one big super object.
- $classes = array(
- 'config' => 'Config',
- 'input' => 'Input',
- 'benchmark' => 'Benchmark',
- 'uri' => 'URI',
- 'output' => 'Output',
- 'lang' => 'Language'
- );
-
- foreach ($classes as $var => $class)
- {
- $this->$var =& load_class($class);
- }
-
- // In PHP 5 the Loader class is run as a discreet
- // class. In PHP 4 it extends the Controller
- if (floor(phpversion()) >= 5)
- {
- $this->load =& load_class('Loader');
- $this->load->_ci_autoloader();
- }
- else
- {
- $this->_ci_autoloader();
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Run Scaffolding
- *
- * @access private
- * @return void
- */
- function _ci_scaffolding()
- {
- if ($this->_ci_scaffolding === FALSE OR $this->_ci_scaff_table === FALSE)
- {
- show_404('Scaffolding unavailable');
- }
-
- $method = ( ! in_array($this->uri->segment(3), array('add', 'insert', 'edit', 'update', 'view', 'delete', 'do_delete'), TRUE)) ? 'view' : $this->uri->segment(3);
-
- require_once(BASEPATH.'scaffolding/Scaffolding'.EXT);
- $scaff = new Scaffolding($this->_ci_scaff_table);
- $scaff->$method();
- }
-
-
-}
-// END _Controller class
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Application Controller Class
+ *
+ * This class object is the super class the every library in
+ * CodeIgniter will be assigned to.
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category Libraries
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/general/controllers.html
+ */
+class Controller extends CI_Base {
+
+ var $_ci_scaffolding = FALSE;
+ var $_ci_scaff_table = FALSE;
+
+ /**
+ * Constructor
+ *
+ * Calls the initialize() function
+ */
+ function Controller()
+ {
+ parent::CI_Base();
+ $this->_ci_initialize();
+ log_message('debug', "Controller Class Initialized");
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Initialize
+ *
+ * Assigns all the bases classes loaded by the front controller to
+ * variables in this class. Also calls the autoload routine.
+ *
+ * @access private
+ * @return void
+ */
+ function _ci_initialize()
+ {
+ // Assign all the class objects that were instantiated by the
+ // front controller to local class variables so that CI can be
+ // run as one big super object.
+ $classes = array(
+ 'config' => 'Config',
+ 'input' => 'Input',
+ 'benchmark' => 'Benchmark',
+ 'uri' => 'URI',
+ 'output' => 'Output',
+ 'lang' => 'Language'
+ );
+
+ foreach ($classes as $var => $class)
+ {
+ $this->$var =& load_class($class);
+ }
+
+ // In PHP 5 the Loader class is run as a discreet
+ // class. In PHP 4 it extends the Controller
+ if (floor(phpversion()) >= 5)
+ {
+ $this->load =& load_class('Loader');
+ $this->load->_ci_autoloader();
+ }
+ else
+ {
+ $this->_ci_autoloader();
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Run Scaffolding
+ *
+ * @access private
+ * @return void
+ */
+ function _ci_scaffolding()
+ {
+ if ($this->_ci_scaffolding === FALSE OR $this->_ci_scaff_table === FALSE)
+ {
+ show_404('Scaffolding unavailable');
+ }
+
+ $method = ( ! in_array($this->uri->segment(3), array('add', 'insert', 'edit', 'update', 'view', 'delete', 'do_delete'), TRUE)) ? 'view' : $this->uri->segment(3);
+
+ require_once(BASEPATH.'scaffolding/Scaffolding'.EXT);
+ $scaff = new Scaffolding($this->_ci_scaff_table);
+ $scaff->$method();
+ }
+
+
+}
+// END _Controller class
?> \ No newline at end of file
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index e6dd614f4..a8acec674 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -1,1719 +1,1719 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Igniter Email Class
- *
- * Permits email to be sent using Mail, Sendmail, or SMTP.
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Libraries
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/libraries/email.html
- */
-class CI_Email {
-
- var $useragent = "Code Igniter";
- var $mailpath = "/usr/sbin/sendmail"; // Sendmail path
- var $protocol = "mail"; // mail/sendmail/smtp
- var $smtp_host = ""; // SMTP Server. Example: mail.earthlink.net
- var $smtp_user = ""; // SMTP Username
- var $smtp_pass = ""; // SMTP Password
- var $smtp_port = "25"; // SMTP Port
- var $smtp_timeout = 5; // SMTP Timeout in seconds
- var $wordwrap = TRUE; // true/false Turns word-wrap on/off
- var $wrapchars = "76"; // Number of characters to wrap at.
- var $mailtype = "text"; // text/html Defines email formatting
- var $charset = "utf-8"; // Default char set: iso-8859-1 or us-ascii
- var $multipart = "mixed"; // "mixed" (in the body) or "related" (separate)
- var $alt_message = ''; // Alternative message for HTML emails
- var $validate = FALSE; // true/false. Enables email validation
- var $priority = "3"; // Default priority (1 - 5)
- var $newline = "\n"; // Default newline. "\r\n" or "\n" (Use "\r\n" to comply with RFC 822)
- var $bcc_batch_mode = FALSE; // true/false Turns on/off Bcc batch feature
- var $bcc_batch_size = 200; // If bcc_batch_mode = true, sets max number of Bccs in each batch
- var $_subject = "";
- var $_body = "";
- var $_finalbody = "";
- var $_alt_boundary = "";
- var $_atc_boundary = "";
- var $_header_str = "";
- var $_smtp_connect = "";
- var $_encoding = "8bit";
- var $_safe_mode = FALSE;
- var $_IP = FALSE;
- var $_smtp_auth = FALSE;
- var $_replyto_flag = FALSE;
- var $_debug_msg = array();
- var $_recipients = array();
- var $_cc_array = array();
- var $_bcc_array = array();
- var $_headers = array();
- var $_attach_name = array();
- var $_attach_type = array();
- var $_attach_disp = array();
- var $_protocols = array('mail', 'sendmail', 'smtp');
- var $_base_charsets = array('iso-8859-1', 'us-ascii');
- var $_bit_depths = array('7bit', '8bit');
- var $_priorities = array('1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)');
-
-
- /**
- * Constructor - Sets Email Preferences
- *
- * The constructor can be passed an array of config values
- */
- function CI_Email($config = array())
- {
- if (count($config) > 0)
- {
- $this->initialize($config);
- }
-
- log_message('debug', "Email Class Initialized");
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Initialize preferences
- *
- * @access public
- * @param array
- * @return void
- */
- function initialize($config = array())
- {
- $this->clear();
- foreach ($config as $key => $val)
- {
- if (isset($this->$key))
- {
- $method = 'set_'.$key;
-
- if (method_exists($this, $method))
- {
- $this->$method($val);
- }
- else
- {
- $this->$key = $val;
- }
- }
- }
- $this->_smtp_auth = ($this->smtp_user == '' AND $this->smtp_pass == '') ? FALSE : TRUE;
- $this->_safe_mode = (@ini_get("safe_mode") == 0) ? FALSE : TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Initialize the Email Data
- *
- * @access public
- * @return void
- */
- function clear($clear_attachments = FALSE)
- {
- $this->_subject = "";
- $this->_body = "";
- $this->_finalbody = "";
- $this->_header_str = "";
- $this->_replyto_flag = FALSE;
- $this->_recipients = array();
- $this->_headers = array();
- $this->_debug_msg = array();
-
- $this->_set_header('User-Agent', $this->useragent);
- $this->_set_header('Date', $this->_set_date());
-
- if ($clear_attachments !== FALSE)
- {
- $this->_attach_name = array();
- $this->_attach_type = array();
- $this->_attach_disp = array();
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set FROM
- *
- * @access public
- * @param string
- * @param string
- * @return void
- */
- function from($from, $name = '')
- {
- if (preg_match( '/\<(.*)\>/', $from, $match))
- $from = $match['1'];
-
- if ($this->validate)
- $this->validate_email($this->_str_to_array($from));
-
- if ($name != '' && substr($name, 0, 1) != '"')
- {
- $name = '"'.$name.'"';
- }
-
- $this->_set_header('From', $name.' <'.$from.'>');
- $this->_set_header('Return-Path', '<'.$from.'>');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Reply-to
- *
- * @access public
- * @param string
- * @param string
- * @return void
- */
- function reply_to($replyto, $name = '')
- {
- if (preg_match( '/\<(.*)\>/', $replyto, $match))
- $replyto = $match['1'];
-
- if ($this->validate)
- $this->validate_email($this->_str_to_array($replyto));
-
- if ($name == '')
- {
- $name = $replyto;
- }
-
- if (substr($name, 0, 1) != '"')
- {
- $name = '"'.$name.'"';
- }
-
- $this->_set_header('Reply-To', $name.' <'.$replyto.'>');
- $this->_replyto_flag = TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Recipients
- *
- * @access public
- * @param string
- * @return void
- */
- function to($to)
- {
- $to = $this->_str_to_array($to);
- $to = $this->clean_email($to);
-
- if ($this->validate)
- $this->validate_email($to);
-
- if ($this->_get_protocol() != 'mail')
- $this->_set_header('To', implode(", ", $to));
-
- switch ($this->_get_protocol())
- {
- case 'smtp' : $this->_recipients = $to;
- break;
- case 'sendmail' : $this->_recipients = implode(", ", $to);
- break;
- case 'mail' : $this->_recipients = implode(", ", $to);
- break;
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set CC
- *
- * @access public
- * @param string
- * @return void
- */
- function cc($cc)
- {
- $cc = $this->_str_to_array($cc);
- $cc = $this->clean_email($cc);
-
- if ($this->validate)
- $this->validate_email($cc);
-
- $this->_set_header('Cc', implode(", ", $cc));
-
- if ($this->_get_protocol() == "smtp")
- $this->_cc_array = $cc;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set BCC
- *
- * @access public
- * @param string
- * @param string
- * @return void
- */
- function bcc($bcc, $limit = '')
- {
- if ($limit != '' && is_numeric($limit))
- {
- $this->bcc_batch_mode = true;
- $this->bcc_batch_size = $limit;
- }
-
- $bcc = $this->_str_to_array($bcc);
- $bcc = $this->clean_email($bcc);
-
- if ($this->validate)
- $this->validate_email($bcc);
-
- if (($this->_get_protocol() == "smtp") OR ($this->bcc_batch_mode && count($bcc) > $this->bcc_batch_size))
- $this->_bcc_array = $bcc;
- else
- $this->_set_header('Bcc', implode(", ", $bcc));
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Email Subject
- *
- * @access public
- * @param string
- * @return void
- */
- function subject($subject)
- {
- $subject = preg_replace("/(\r\n)|(\r)|(\n)/", "", $subject);
- $subject = preg_replace("/(\t)/", " ", $subject);
-
- $this->_set_header('Subject', trim($subject));
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Body
- *
- * @access public
- * @param string
- * @return void
- */
- function message($body)
- {
- $this->_body = stripslashes(rtrim(str_replace("\r", "", $body)));
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Assign file attachments
- *
- * @access public
- * @param string
- * @return string
- */
- function attach($filename, $disposition = 'attachment')
- {
- $this->_attach_name[] = $filename;
- $this->_attach_type[] = $this->_mime_types(next(explode('.', basename($filename))));
- $this->_attach_disp[] = $disposition; // Can also be 'inline' Not sure if it matters
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Add a Header Item
- *
- * @access public
- * @param string
- * @param string
- * @return void
- */
- function _set_header($header, $value)
- {
- $this->_headers[$header] = $value;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Convert a String to an Array
- *
- * @access public
- * @param string
- * @return array
- */
- function _str_to_array($email)
- {
- if ( ! is_array($email))
- {
- if (ereg(',$', $email))
- $email = substr($email, 0, -1);
-
- if (ereg('^,', $email))
- $email = substr($email, 1);
-
- if (ereg(',', $email))
- {
- $x = explode(',', $email);
- $email = array();
-
- for ($i = 0; $i < count($x); $i ++)
- $email[] = trim($x[$i]);
- }
- else
- {
- $email = trim($email);
- settype($email, "array");
- }
- }
- return $email;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Multipart Value
- *
- * @access public
- * @param string
- * @return void
- */
- function set_alt_message($str = '')
- {
- $this->alt_message = ($str == '') ? '' : $str;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Mailtype
- *
- * @access public
- * @param string
- * @return void
- */
- function set_mailtype($type = 'text')
- {
- $this->mailtype = ($type == 'html') ? 'html' : 'text';
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Wordwrap
- *
- * @access public
- * @param string
- * @return void
- */
- function set_wordwrap($wordwrap = TRUE)
- {
- $this->wordwrap = ($wordwrap === FALSE) ? FALSE : TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Protocol
- *
- * @access public
- * @param string
- * @return void
- */
- function set_protocol($protocol = 'mail')
- {
- $this->protocol = ( ! in_array($protocol, $this->_protocols, TRUE)) ? 'mail' : strtolower($protocol);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Priority
- *
- * @access public
- * @param integer
- * @return void
- */
- function set_priority($n = 3)
- {
- if ( ! is_numeric($n))
- {
- $this->priority = 3;
- return;
- }
-
- if ($n < 1 OR $n > 5)
- {
- $this->priority = 3;
- return;
- }
-
- $this->priority = $n;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Newline Character
- *
- * @access public
- * @param string
- * @return void
- */
- function set_newline($newline = "\n")
- {
- if ($newline != "\n" OR $newline != "\r\n" OR $newline != "\r")
- {
- $this->newline = "\n";
- return;
- }
-
- $this->newline = $newline;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Message Boundary
- *
- * @access private
- * @return void
- */
- function _set_boundaries()
- {
- $this->_alt_boundary = "B_ALT_".uniqid(''); // multipart/alternative
- $this->_atc_boundary = "B_ATC_".uniqid(''); // attachment boundary
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Get the Message ID
- *
- * @access private
- * @return string
- */
- function _get_message_id()
- {
- $from = $this->_headers['Return-Path'];
- $from = str_replace(">", "", $from);
- $from = str_replace("<", "", $from);
-
- return "<".uniqid('').strstr($from, '@').">";
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Get Mail Protocol
- *
- * @access private
- * @param bool
- * @return string
- */
- function _get_protocol($return = true)
- {
- $this->protocol = strtolower($this->protocol);
- $this->protocol = ( ! in_array($this->protocol, $this->_protocols, TRUE)) ? 'mail' : $this->protocol;
-
- if ($return == true)
- return $this->protocol;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Get Mail Encoding
- *
- * @access private
- * @param bool
- * @return string
- */
- function _get_encoding($return = true)
- {
- $this->_encoding = ( ! in_array($this->_encoding, $this->_bit_depths)) ? '7bit' : $this->_encoding;
-
- if ( ! in_array($this->charset, $this->_base_charsets, TRUE))
- $this->_encoding = "8bit";
-
- if ($return == true)
- return $this->_encoding;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Get content type (text/html/attachment)
- *
- * @access private
- * @return string
- */
- function _get_content_type()
- {
- if ($this->mailtype == 'html' && count($this->_attach_name) == 0)
- return 'html';
-
- elseif ($this->mailtype == 'html' && count($this->_attach_name) > 0)
- return 'html-attach';
-
- elseif ($this->mailtype == 'text' && count($this->_attach_name) > 0)
- return 'plain-attach';
-
- else return 'plain';
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set RFC 822 Date
- *
- * @access public
- * @return string
- */
- function _set_date()
- {
- $timezone = date("Z");
- $operator = (substr($timezone, 0, 1) == '-') ? '-' : '+';
- $timezone = abs($timezone);
- $timezone = ($timezone/3600) * 100 + ($timezone % 3600) /60;
-
- return sprintf("%s %s%04d", date("D, j M Y H:i:s"), $operator, $timezone);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Mime message
- *
- * @access private
- * @return string
- */
- function _get_mime_message()
- {
- return "This is a multi-part message in MIME format.".$this->newline."Your email application may not support this format.";
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Validate Email Address
- *
- * @access public
- * @param string
- * @return bool
- */
- function validate_email($email)
- {
- if ( ! is_array($email))
- {
- $this->_set_error_message('email_must_be_array');
- return FALSE;
- }
-
- foreach ($email as $val)
- {
- if ( ! $this->valid_email($val))
- {
- $this->_set_error_message('email_invalid_address', $val);
- return FALSE;
- }
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Email Validation
- *
- * @access public
- * @param string
- * @return bool
- */
- function valid_email($address)
- {
- if ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $address))
- return FALSE;
- else
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Clean Extended Email Address: Joe Smith <joe@smith.com>
- *
- * @access public
- * @param string
- * @return string
- */
- function clean_email($email)
- {
- if ( ! is_array($email))
- {
- if (preg_match('/\<(.*)\>/', $email, $match))
- return $match['1'];
- else
- return $email;
- }
-
- $clean_email = array();
-
- for ($i=0; $i < count($email); $i++)
- {
- if (preg_match( '/\<(.*)\>/', $email[$i], $match))
- $clean_email[] = $match['1'];
- else
- $clean_email[] = $email[$i];
- }
-
- return $clean_email;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Build alternative plain text message
- *
- * This function provides the raw message for use
- * in plain-text headers of HTML-formatted emails.
- * If the user hasn't specified his own alternative message
- * it creates one by stripping the HTML
- *
- * @access private
- * @return string
- */
- function _get_alt_message()
- {
- if ($this->alt_message != "")
- {
- return $this->word_wrap($this->alt_message, '76');
- }
-
- if (eregi( '\<body(.*)\</body\>', $this->_body, $match))
- {
- $body = $match['1'];
- $body = substr($body, strpos($body, ">") + 1);
- }
- else
- {
- $body = $this->_body;
- }
-
- $body = trim(strip_tags($body));
- $body = preg_replace( '#<!--(.*)--\>#', "", $body);
- $body = str_replace("\t", "", $body);
-
- for ($i = 20; $i >= 3; $i--)
- {
- $n = "";
-
- for ($x = 1; $x <= $i; $x ++)
- $n .= "\n";
-
- $body = str_replace($n, "\n\n", $body);
- }
-
- return $this->word_wrap($body, '76');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Word Wrap
- *
- * @access public
- * @param string
- * @param integer
- * @return string
- */
- function word_wrap($str, $charlim = '')
- {
- // Se the character limit
- if ($charlim == '')
- {
- $charlim = ($this->wrapchars == "") ? "76" : $this->wrapchars;
- }
-
- // Reduce multiple spaces
- $str = preg_replace("| +|", " ", $str);
-
- // Standardize newlines
- $str = preg_replace("/\r\n|\r/", "\n", $str);
-
- // If the current word is surrounded by {unwrap} tags we'll
- // strip the entire chunk and replace it with a marker.
- $unwrap = array();
- if (preg_match_all("|(\{unwrap\}.+?\{/unwrap\})|s", $str, $matches))
- {
- for ($i = 0; $i < count($matches['0']); $i++)
- {
- $unwrap[] = $matches['1'][$i];
- $str = str_replace($matches['1'][$i], "{{unwrapped".$i."}}", $str);
- }
- }
-
- // Use PHP's native function to do the initial wordwrap.
- // We set the cut flag to FALSE so that any individual words that are
- // too long get left alone. In the next step we'll deal with them.
- $str = wordwrap($str, $charlim, "\n", FALSE);
-
- // Split the string into individual lines of text and cycle through them
- $output = "";
- foreach (explode("\n", $str) as $line)
- {
- // Is the line within the allowed character count?
- // If so we'll join it to the output and continue
- if (strlen($line) <= $charlim)
- {
- $output .= $line.$this->newline;
- continue;
- }
-
- $temp = '';
- while((strlen($line)) > $charlim)
- {
- // If the over-length word is a URL we won't wrap it
- if (preg_match("!\[url.+\]|://|wwww.!", $line))
- {
- break;
- }
-
- // Trim the word down
- $temp .= substr($line, 0, $charlim-1);
- $line = substr($line, $charlim-1);
- }
-
- // If $temp contains data it means we had to split up an over-length
- // word into smaller chunks so we'll add it back to our current line
- if ($temp != '')
- {
- $output .= $temp.$this->newline.$line;
- }
- else
- {
- $output .= $line;
- }
-
- $output .= $this->newline;
- }
-
- // Put our markers back
- if (count($unwrap) > 0)
- {
- foreach ($unwrap as $key => $val)
- {
- $output = str_replace("{{unwrapped".$key."}}", $val, $output);
- }
- }
-
- return $output;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Build final headers
- *
- * @access public
- * @param string
- * @return string
- */
- function _build_headers()
- {
- $this->_set_header('X-Sender', $this->clean_email($this->_headers['From']));
- $this->_set_header('X-Mailer', $this->useragent);
- $this->_set_header('X-Priority', $this->_priorities[$this->priority - 1]);
- $this->_set_header('Message-ID', $this->_get_message_id());
- $this->_set_header('Mime-Version', '1.0');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Write Headers as a string
- *
- * @access public
- * @return void
- */
- function _write_headers()
- {
- if ($this->protocol == 'mail')
- {
- $this->_subject = $this->_headers['Subject'];
- unset($this->_headers['Subject']);
- }
-
- reset($this->_headers);
- $this->_header_str = "";
-
- foreach($this->_headers as $key => $val)
- {
- $val = trim($val);
-
- if ($val != "")
- {
- $this->_header_str .= $key.": ".$val.$this->newline;
- }
- }
-
- if ($this->_get_protocol() == 'mail')
- $this->_header_str = substr($this->_header_str, 0, -1);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Build Final Body and attachments
- *
- * @access public
- * @return void
- */
- function _build_message()
- {
- if ($this->wordwrap === TRUE AND $this->mailtype != 'html')
- {
- $this->_body = $this->word_wrap($this->_body);
- }
-
- $this->_set_boundaries();
- $this->_write_headers();
-
- $hdr = ($this->_get_protocol() == 'mail') ? $this->newline : '';
-
- switch ($this->_get_content_type())
- {
- case 'plain' :
-
- $hdr .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
- $hdr .= "Content-Transfer-Encoding: " . $this->_get_encoding();
-
- if ($this->_get_protocol() == 'mail')
- {
- $this->_header_str .= $hdr;
- $this->_finalbody = $this->_body;
-
- return;
- }
-
- $hdr .= $this->newline . $this->newline . $this->_body;
-
- $this->_finalbody = $hdr;
- return;
-
- break;
- case 'html' :
-
- $hdr .= "Content-Type: multipart/alternative; boundary=\"" . $this->_alt_boundary . "\"" . $this->newline;
- $hdr .= $this->_get_mime_message() . $this->newline . $this->newline;
- $hdr .= "--" . $this->_alt_boundary . $this->newline;
-
- $hdr .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
- $hdr .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline;
- $hdr .= $this->_get_alt_message() . $this->newline . $this->newline . "--" . $this->_alt_boundary . $this->newline;
-
- $hdr .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
- $hdr .= "Content-Transfer-Encoding: quoted/printable";
-
- if ($this->_get_protocol() == 'mail')
- {
- $this->_header_str .= $hdr;
- $this->_finalbody = $this->_body . $this->newline . $this->newline . "--" . $this->_alt_boundary . "--";
-
- return;
- }
-
- $hdr .= $this->newline . $this->newline;
- $hdr .= $this->_body . $this->newline . $this->newline . "--" . $this->_alt_boundary . "--";
-
- $this->_finalbody = $hdr;
- return;
-
- break;
- case 'plain-attach' :
-
- $hdr .= "Content-Type: multipart/".$this->multipart."; boundary=\"" . $this->_atc_boundary."\"" . $this->newline;
- $hdr .= $this->_get_mime_message() . $this->newline . $this->newline;
- $hdr .= "--" . $this->_atc_boundary . $this->newline;
-
- $hdr .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
- $hdr .= "Content-Transfer-Encoding: " . $this->_get_encoding();
-
- if ($this->_get_protocol() == 'mail')
- {
- $this->_header_str .= $hdr;
-
- $body = $this->_body . $this->newline . $this->newline;
- }
-
- $hdr .= $this->newline . $this->newline;
- $hdr .= $this->_body . $this->newline . $this->newline;
-
- break;
- case 'html-attach' :
-
- $hdr .= "Content-Type: multipart/".$this->multipart."; boundary=\"" . $this->_atc_boundary."\"" . $this->newline;
- $hdr .= $this->_get_mime_message() . $this->newline . $this->newline;
- $hdr .= "--" . $this->_atc_boundary . $this->newline;
-
- $hdr .= "Content-Type: multipart/alternative; boundary=\"" . $this->_alt_boundary . "\"" . $this->newline .$this->newline;
- $hdr .= "--" . $this->_alt_boundary . $this->newline;
-
- $hdr .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
- $hdr .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline;
- $hdr .= $this->_get_alt_message() . $this->newline . $this->newline . "--" . $this->_alt_boundary . $this->newline;
-
- $hdr .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
- $hdr .= "Content-Transfer-Encoding: quoted/printable";
-
- if ($this->_get_protocol() == 'mail')
- {
- $this->_header_str .= $hdr;
-
- $body = $this->_body . $this->newline . $this->newline;
- $body .= "--" . $this->_alt_boundary . "--" . $this->newline . $this->newline;
- }
-
- $hdr .= $this->newline . $this->newline;
- $hdr .= $this->_body . $this->newline . $this->newline;
- $hdr .= "--" . $this->_alt_boundary . "--" . $this->newline . $this->newline;
-
- break;
- }
-
- $attachment = array();
-
- $z = 0;
-
- for ($i=0; $i < count($this->_attach_name); $i++)
- {
- $filename = $this->_attach_name[$i];
- $basename = basename($filename);
- $ctype = $this->_attach_type[$i];
-
- if ( ! file_exists($filename))
- {
- $this->_set_error_message('email_attachment_missing', $filename);
- return FALSE;
- }
-
- $h = "--".$this->_atc_boundary.$this->newline;
- $h .= "Content-type: ".$ctype."; ";
- $h .= "name=\"".$basename."\"".$this->newline;
- $h .= "Content-Disposition: ".$this->_attach_disp[$i].";".$this->newline;
- $h .= "Content-Transfer-Encoding: base64".$this->newline;
-
- $attachment[$z++] = $h;
- $file = filesize($filename) +1;
-
- if ( ! $fp = fopen($filename, 'r'))
- {
- $this->_set_error_message('email_attachment_unredable', $filename);
- return FALSE;
- }
-
- $attachment[$z++] = chunk_split(base64_encode(fread($fp, $file)));
- fclose($fp);
- }
-
- if ($this->_get_protocol() == 'mail')
- {
- $this->_finalbody = $body . implode($this->newline, $attachment).$this->newline."--".$this->_atc_boundary."--";
-
- return;
- }
-
- $this->_finalbody = $hdr.implode($this->newline, $attachment).$this->newline."--".$this->_atc_boundary."--";
-
- return;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Send Email
- *
- * @access public
- * @return bool
- */
- function send()
- {
- if ($this->_replyto_flag == FALSE)
- {
- $this->reply_to($this->_headers['From']);
- }
-
- if (( ! isset($this->_recipients) AND ! isset($this->_headers['To'])) AND
- ( ! isset($this->_bcc_array) AND ! isset($this->_headers['Bcc'])) AND
- ( ! isset($this->_headers['Cc'])))
- {
- $this->_set_error_message('email_no_recipients');
- return FALSE;
- }
-
- $this->_build_headers();
-
- if ($this->bcc_batch_mode AND count($this->_bcc_array) > 0)
- {
- if (count($this->_bcc_array) > $this->bcc_batch_size)
- return $this->batch_bcc_send();
- }
-
- $this->_build_message();
-
- if ( ! $this->_spool_email())
- return FALSE;
- else
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Batch Bcc Send. Sends groups of BCCs in batches
- *
- * @access public
- * @return bool
- */
- function batch_bcc_send()
- {
- $float = $this->bcc_batch_size -1;
-
- $flag = 0;
- $set = "";
-
- $chunk = array();
-
- for ($i = 0; $i < count($this->_bcc_array); $i++)
- {
- if (isset($this->_bcc_array[$i]))
- $set .= ", ".$this->_bcc_array[$i];
-
- if ($i == $float)
- {
- $chunk[] = substr($set, 1);
- $float = $float + $this->bcc_batch_size;
- $set = "";
- }
-
- if ($i == count($this->_bcc_array)-1)
- $chunk[] = substr($set, 1);
- }
-
- for ($i = 0; $i < count($chunk); $i++)
- {
- unset($this->_headers['Bcc']);
- unset($bcc);
-
- $bcc = $this->_str_to_array($chunk[$i]);
- $bcc = $this->clean_email($bcc);
-
- if ($this->protocol != 'smtp')
- $this->_set_header('Bcc', implode(", ", $bcc));
- else
- $this->_bcc_array = $bcc;
-
- $this->_build_message();
- $this->_spool_email();
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Unwrap special elements
- *
- * @access private
- * @return void
- */
- function _unwrap_specials()
- {
- $this->_finalbody = preg_replace_callback("/\{unwrap\}(.*?)\{\/unwrap\}/si", array($this, '_remove_nl_callback'), $this->_finalbody);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Strip line-breaks via callback
- *
- * @access private
- * @return string
- */
- function _remove_nl_callback($matches)
- {
- return preg_replace("/(\r\n)|(\r)|(\n)/", "", $matches['1']);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Spool mail to the mail server
- *
- * @access private
- * @return bool
- */
- function _spool_email()
- {
- $this->_unwrap_specials();
-
- switch ($this->_get_protocol())
- {
- case 'mail' :
-
- if ( ! $this->_send_with_mail())
- {
- $this->_set_error_message('email_send_failure_phpmail');
- return FALSE;
- }
- break;
- case 'sendmail' :
-
- if ( ! $this->_send_with_sendmail())
- {
- $this->_set_error_message('email_send_failure_sendmail');
- return FALSE;
- }
- break;
- case 'smtp' :
-
- if ( ! $this->_send_with_smtp())
- {
- $this->_set_error_message('email_send_failure_smtp');
- return FALSE;
- }
- break;
-
- }
-
- $this->_set_error_message('email_sent', $this->_get_protocol());
- return true;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Send using mail()
- *
- * @access private
- * @return bool
- */
- function _send_with_mail()
- {
- if ($this->_safe_mode == TRUE)
- {
- if ( ! mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str))
- return FALSE;
- else
- return TRUE;
- }
- else
- {
- if ( ! mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str, "-f".$this->clean_email($this->_headers['From'])))
- return FALSE;
- else
- return TRUE;
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Send using Sendmail
- *
- * @access private
- * @return bool
- */
- function _send_with_sendmail()
- {
- $fp = @popen($this->mailpath . " -oi -f ".$this->clean_email($this->_headers['From'])." -t", 'w');
-
- if ( ! is_resource($fp))
- {
- $this->_set_error_message('email_no_socket');
- return FALSE;
- }
-
- fputs($fp, $this->_header_str);
- fputs($fp, $this->_finalbody);
- pclose($fp) >> 8 & 0xFF;
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Send using SMTP
- *
- * @access private
- * @return bool
- */
- function _send_with_smtp()
- {
- if ($this->smtp_host == '')
- {
- $this->_set_error_message('email_no_hostname');
- return FALSE;
- }
-
- $this->_smtp_connect();
- $this->_smtp_authenticate();
-
- $this->_send_command('from', $this->clean_email($this->_headers['From']));
-
- foreach($this->_recipients as $val)
- $this->_send_command('to', $val);
-
- if (count($this->_cc_array) > 0)
- {
- foreach($this->_cc_array as $val)
- {
- if ($val != "")
- $this->_send_command('to', $val);
- }
- }
-
- if (count($this->_bcc_array) > 0)
- {
- foreach($this->_bcc_array as $val)
- {
- if ($val != "")
- $this->_send_command('to', $val);
- }
- }
-
- $this->_send_command('data');
-
- $this->_send_data($this->_header_str . $this->_finalbody);
-
- $this->_send_data('.');
-
- $reply = $this->_get_smtp_data();
-
- $this->_set_error_message($reply);
-
- if (substr($reply, 0, 3) != '250')
- {
- $this->_set_error_message('email_smtp_error', $reply);
- return FALSE;
- }
-
- $this->_send_command('quit');
- return true;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * SMTP Connect
- *
- * @access public
- * @param string
- * @return string
- */
- function _smtp_connect()
- {
-
- $this->_smtp_connect = fsockopen($this->smtp_host,
- $this->smtp_port,
- $errno,
- $errstr,
- $this->smtp_timeout);
-
- if( ! is_resource($this->_smtp_connect))
- {
- $this->_set_error_message('email_smtp_error', $errno." ".$errstr);
- return FALSE;
- }
-
- $this->_set_error_message($this->_get_smtp_data());
- return $this->_send_command('hello');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Send SMTP command
- *
- * @access private
- * @param string
- * @param string
- * @return string
- */
- function _send_command($cmd, $data = '')
- {
- switch ($cmd)
- {
- case 'hello' :
-
- if ($this->_smtp_auth OR $this->_get_encoding() == '8bit')
- $this->_send_data('EHLO '.$this->_get_hostname());
- else
- $this->_send_data('HELO '.$this->_get_hostname());
-
- $resp = 250;
- break;
- case 'from' :
-
- $this->_send_data('MAIL FROM:<'.$data.'>');
-
- $resp = 250;
- break;
- case 'to' :
-
- $this->_send_data('RCPT TO:<'.$data.'>');
-
- $resp = 250;
- break;
- case 'data' :
-
- $this->_send_data('DATA');
-
- $resp = 354;
- break;
- case 'quit' :
-
- $this->_send_data('QUIT');
-
- $resp = 221;
- break;
- }
-
- $reply = $this->_get_smtp_data();
-
- $this->_debug_msg[] = "<pre>".$cmd.": ".$reply."</pre>";
-
- if (substr($reply, 0, 3) != $resp)
- {
- $this->_set_error_message('email_smtp_error', $reply);
- return FALSE;
- }
-
- if ($cmd == 'quit')
- fclose($this->_smtp_connect);
-
- return true;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * SMTP Authenticate
- *
- * @access private
- * @return bool
- */
- function _smtp_authenticate()
- {
- if ( ! $this->_smtp_auth)
- return true;
-
- if ($this->smtp_user == "" AND $this->smtp_pass == "")
- {
- $this->_set_error_message('email_no_smtp_unpw');
- return FALSE;
- }
-
- $this->_send_data('AUTH LOGIN');
-
- $reply = $this->_get_smtp_data();
-
- if (substr($reply, 0, 3) != '334')
- {
- $this->_set_error_message('email_filed_smtp_login', $reply);
- return FALSE;
- }
-
- $this->_send_data(base64_encode($this->smtp_user));
-
- $reply = $this->_get_smtp_data();
-
- if (substr($reply, 0, 3) != '334')
- {
- $this->_set_error_message('email_smtp_auth_un', $reply);
- return FALSE;
- }
-
- $this->_send_data(base64_encode($this->smtp_pass));
-
- $reply = $this->_get_smtp_data();
-
- if (substr($reply, 0, 3) != '235')
- {
- $this->_set_error_message('email_smtp_auth_pw', $reply);
- return FALSE;
- }
-
- return true;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Send SMTP data
- *
- * @access private
- * @return bool
- */
- function _send_data($data)
- {
- if ( ! fwrite($this->_smtp_connect, $data . $this->newline))
- {
- $this->_set_error_message('email_smtp_data_failure', $data);
- return FALSE;
- }
- else
- return true;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Get SMTP data
- *
- * @access private
- * @return string
- */
- function _get_smtp_data()
- {
- $data = "";
-
- while ($str = fgets($this->_smtp_connect, 512))
- {
- $data .= $str;
-
- if (substr($str, 3, 1) == " ")
- break;
- }
-
- return $data;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Get Hostname
- *
- * @access private
- * @return string
- */
- function _get_hostname()
- {
- return (isset($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : 'localhost.localdomain';
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Get IP
- *
- * @access private
- * @return string
- */
- function _get_ip()
- {
- if ($this->_IP !== FALSE)
- {
- return $this->_IP;
- }
-
- $cip = (isset($_SERVER['HTTP_CLIENT_IP']) AND $_SERVER['HTTP_CLIENT_IP'] != "") ? $_SERVER['HTTP_CLIENT_IP'] : FALSE;
- $rip = (isset($_SERVER['REMOTE_ADDR']) AND $_SERVER['REMOTE_ADDR'] != "") ? $_SERVER['REMOTE_ADDR'] : FALSE;
- $fip = (isset($_SERVER['HTTP_X_FORWARDED_FOR']) AND $_SERVER['HTTP_X_FORWARDED_FOR'] != "") ? $_SERVER['HTTP_X_FORWARDED_FOR'] : FALSE;
-
- if ($cip && $rip) $this->_IP = $cip;
- elseif ($rip) $this->_IP = $rip;
- elseif ($cip) $this->_IP = $cip;
- elseif ($fip) $this->_IP = $fip;
-
- if (strstr($this->_IP, ','))
- {
- $x = explode(',', $this->_IP);
- $this->_IP = end($x);
- }
-
- if ( ! preg_match( "/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/", $this->_IP))
- $this->_IP = '0.0.0.0';
-
- unset($cip);
- unset($rip);
- unset($fip);
-
- return $this->_IP;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Get Debug Message
- *
- * @access public
- * @return string
- */
- function print_debugger()
- {
- $msg = '';
-
- if (count($this->_debug_msg) > 0)
- {
- foreach ($this->_debug_msg as $val)
- {
- $msg .= $val;
- }
- }
-
- $msg .= "<pre>".$this->_header_str."\n".$this->_subject."\n".$this->_finalbody.'</pre>';
- return $msg;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Message
- *
- * @access public
- * @param string
- * @return string
- */
- function _set_error_message($msg, $val = '')
- {
- $CI =& get_instance();
- $CI->lang->load('email');
-
- if (FALSE === ($line = $CI->lang->line($msg)))
- {
- $this->_debug_msg[] = str_replace('%s', $val, $msg)."<br />";
- }
- else
- {
- $this->_debug_msg[] = str_replace('%s', $val, $line)."<br />";
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Mime Types
- *
- * @access private
- * @param string
- * @return string
- */
- function _mime_types($ext = "")
- {
- $mimes = array( 'hqx' => 'application/mac-binhex40',
- 'cpt' => 'application/mac-compactpro',
- 'doc' => 'application/msword',
- 'bin' => 'application/macbinary',
- 'dms' => 'application/octet-stream',
- 'lha' => 'application/octet-stream',
- 'lzh' => 'application/octet-stream',
- 'exe' => 'application/octet-stream',
- 'class' => 'application/octet-stream',
- 'psd' => 'application/octet-stream',
- 'so' => 'application/octet-stream',
- 'sea' => 'application/octet-stream',
- 'dll' => 'application/octet-stream',
- 'oda' => 'application/oda',
- 'pdf' => 'application/pdf',
- 'ai' => 'application/postscript',
- 'eps' => 'application/postscript',
- 'ps' => 'application/postscript',
- 'smi' => 'application/smil',
- 'smil' => 'application/smil',
- 'mif' => 'application/vnd.mif',
- 'xls' => 'application/vnd.ms-excel',
- 'ppt' => 'application/vnd.ms-powerpoint',
- 'wbxml' => 'application/vnd.wap.wbxml',
- 'wmlc' => 'application/vnd.wap.wmlc',
- 'dcr' => 'application/x-director',
- 'dir' => 'application/x-director',
- 'dxr' => 'application/x-director',
- 'dvi' => 'application/x-dvi',
- 'gtar' => 'application/x-gtar',
- 'php' => 'application/x-httpd-php',
- 'php4' => 'application/x-httpd-php',
- 'php3' => 'application/x-httpd-php',
- 'phtml' => 'application/x-httpd-php',
- 'phps' => 'application/x-httpd-php-source',
- 'js' => 'application/x-javascript',
- 'swf' => 'application/x-shockwave-flash',
- 'sit' => 'application/x-stuffit',
- 'tar' => 'application/x-tar',
- 'tgz' => 'application/x-tar',
- 'xhtml' => 'application/xhtml+xml',
- 'xht' => 'application/xhtml+xml',
- 'zip' => 'application/zip',
- 'mid' => 'audio/midi',
- 'midi' => 'audio/midi',
- 'mpga' => 'audio/mpeg',
- 'mp2' => 'audio/mpeg',
- 'mp3' => 'audio/mpeg',
- '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' => 'image/jpeg',
- 'jpg' => 'image/jpeg',
- 'jpe' => 'image/jpeg',
- 'png' => 'image/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' => 'text/plain',
- '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',
- 'word' => 'application/msword',
- 'xl' => 'application/excel',
- 'eml' => 'message/rfc822'
- );
-
- return ( ! isset($mimes[strtolower($ext)])) ? "application/x-unknown-content-type" : $mimes[strtolower($ext)];
- }
-
-}
-// END CI_Email class
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Email Class
+ *
+ * Permits email to be sent using Mail, Sendmail, or SMTP.
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category Libraries
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/libraries/email.html
+ */
+class CI_Email {
+
+ var $useragent = "CodeIgniter";
+ var $mailpath = "/usr/sbin/sendmail"; // Sendmail path
+ var $protocol = "mail"; // mail/sendmail/smtp
+ var $smtp_host = ""; // SMTP Server. Example: mail.earthlink.net
+ var $smtp_user = ""; // SMTP Username
+ var $smtp_pass = ""; // SMTP Password
+ var $smtp_port = "25"; // SMTP Port
+ var $smtp_timeout = 5; // SMTP Timeout in seconds
+ var $wordwrap = TRUE; // true/false Turns word-wrap on/off
+ var $wrapchars = "76"; // Number of characters to wrap at.
+ var $mailtype = "text"; // text/html Defines email formatting
+ var $charset = "utf-8"; // Default char set: iso-8859-1 or us-ascii
+ var $multipart = "mixed"; // "mixed" (in the body) or "related" (separate)
+ var $alt_message = ''; // Alternative message for HTML emails
+ var $validate = FALSE; // true/false. Enables email validation
+ var $priority = "3"; // Default priority (1 - 5)
+ var $newline = "\n"; // Default newline. "\r\n" or "\n" (Use "\r\n" to comply with RFC 822)
+ var $bcc_batch_mode = FALSE; // true/false Turns on/off Bcc batch feature
+ var $bcc_batch_size = 200; // If bcc_batch_mode = true, sets max number of Bccs in each batch
+ var $_subject = "";
+ var $_body = "";
+ var $_finalbody = "";
+ var $_alt_boundary = "";
+ var $_atc_boundary = "";
+ var $_header_str = "";
+ var $_smtp_connect = "";
+ var $_encoding = "8bit";
+ var $_safe_mode = FALSE;
+ var $_IP = FALSE;
+ var $_smtp_auth = FALSE;
+ var $_replyto_flag = FALSE;
+ var $_debug_msg = array();
+ var $_recipients = array();
+ var $_cc_array = array();
+ var $_bcc_array = array();
+ var $_headers = array();
+ var $_attach_name = array();
+ var $_attach_type = array();
+ var $_attach_disp = array();
+ var $_protocols = array('mail', 'sendmail', 'smtp');
+ var $_base_charsets = array('iso-8859-1', 'us-ascii');
+ var $_bit_depths = array('7bit', '8bit');
+ var $_priorities = array('1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)');
+
+
+ /**
+ * Constructor - Sets Email Preferences
+ *
+ * The constructor can be passed an array of config values
+ */
+ function CI_Email($config = array())
+ {
+ if (count($config) > 0)
+ {
+ $this->initialize($config);
+ }
+
+ log_message('debug', "Email Class Initialized");
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Initialize preferences
+ *
+ * @access public
+ * @param array
+ * @return void
+ */
+ function initialize($config = array())
+ {
+ $this->clear();
+ foreach ($config as $key => $val)
+ {
+ if (isset($this->$key))
+ {
+ $method = 'set_'.$key;
+
+ if (method_exists($this, $method))
+ {
+ $this->$method($val);
+ }
+ else
+ {
+ $this->$key = $val;
+ }
+ }
+ }
+ $this->_smtp_auth = ($this->smtp_user == '' AND $this->smtp_pass == '') ? FALSE : TRUE;
+ $this->_safe_mode = (@ini_get("safe_mode") == 0) ? FALSE : TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Initialize the Email Data
+ *
+ * @access public
+ * @return void
+ */
+ function clear($clear_attachments = FALSE)
+ {
+ $this->_subject = "";
+ $this->_body = "";
+ $this->_finalbody = "";
+ $this->_header_str = "";
+ $this->_replyto_flag = FALSE;
+ $this->_recipients = array();
+ $this->_headers = array();
+ $this->_debug_msg = array();
+
+ $this->_set_header('User-Agent', $this->useragent);
+ $this->_set_header('Date', $this->_set_date());
+
+ if ($clear_attachments !== FALSE)
+ {
+ $this->_attach_name = array();
+ $this->_attach_type = array();
+ $this->_attach_disp = array();
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set FROM
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return void
+ */
+ function from($from, $name = '')
+ {
+ if (preg_match( '/\<(.*)\>/', $from, $match))
+ $from = $match['1'];
+
+ if ($this->validate)
+ $this->validate_email($this->_str_to_array($from));
+
+ if ($name != '' && substr($name, 0, 1) != '"')
+ {
+ $name = '"'.$name.'"';
+ }
+
+ $this->_set_header('From', $name.' <'.$from.'>');
+ $this->_set_header('Return-Path', '<'.$from.'>');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Reply-to
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return void
+ */
+ function reply_to($replyto, $name = '')
+ {
+ if (preg_match( '/\<(.*)\>/', $replyto, $match))
+ $replyto = $match['1'];
+
+ if ($this->validate)
+ $this->validate_email($this->_str_to_array($replyto));
+
+ if ($name == '')
+ {
+ $name = $replyto;
+ }
+
+ if (substr($name, 0, 1) != '"')
+ {
+ $name = '"'.$name.'"';
+ }
+
+ $this->_set_header('Reply-To', $name.' <'.$replyto.'>');
+ $this->_replyto_flag = TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Recipients
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function to($to)
+ {
+ $to = $this->_str_to_array($to);
+ $to = $this->clean_email($to);
+
+ if ($this->validate)
+ $this->validate_email($to);
+
+ if ($this->_get_protocol() != 'mail')
+ $this->_set_header('To', implode(", ", $to));
+
+ switch ($this->_get_protocol())
+ {
+ case 'smtp' : $this->_recipients = $to;
+ break;
+ case 'sendmail' : $this->_recipients = implode(", ", $to);
+ break;
+ case 'mail' : $this->_recipients = implode(", ", $to);
+ break;
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set CC
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function cc($cc)
+ {
+ $cc = $this->_str_to_array($cc);
+ $cc = $this->clean_email($cc);
+
+ if ($this->validate)
+ $this->validate_email($cc);
+
+ $this->_set_header('Cc', implode(", ", $cc));
+
+ if ($this->_get_protocol() == "smtp")
+ $this->_cc_array = $cc;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set BCC
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return void
+ */
+ function bcc($bcc, $limit = '')
+ {
+ if ($limit != '' && is_numeric($limit))
+ {
+ $this->bcc_batch_mode = true;
+ $this->bcc_batch_size = $limit;
+ }
+
+ $bcc = $this->_str_to_array($bcc);
+ $bcc = $this->clean_email($bcc);
+
+ if ($this->validate)
+ $this->validate_email($bcc);
+
+ if (($this->_get_protocol() == "smtp") OR ($this->bcc_batch_mode && count($bcc) > $this->bcc_batch_size))
+ $this->_bcc_array = $bcc;
+ else
+ $this->_set_header('Bcc', implode(", ", $bcc));
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Email Subject
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function subject($subject)
+ {
+ $subject = preg_replace("/(\r\n)|(\r)|(\n)/", "", $subject);
+ $subject = preg_replace("/(\t)/", " ", $subject);
+
+ $this->_set_header('Subject', trim($subject));
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Body
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function message($body)
+ {
+ $this->_body = stripslashes(rtrim(str_replace("\r", "", $body)));
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Assign file attachments
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function attach($filename, $disposition = 'attachment')
+ {
+ $this->_attach_name[] = $filename;
+ $this->_attach_type[] = $this->_mime_types(next(explode('.', basename($filename))));
+ $this->_attach_disp[] = $disposition; // Can also be 'inline' Not sure if it matters
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Add a Header Item
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return void
+ */
+ function _set_header($header, $value)
+ {
+ $this->_headers[$header] = $value;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Convert a String to an Array
+ *
+ * @access public
+ * @param string
+ * @return array
+ */
+ function _str_to_array($email)
+ {
+ if ( ! is_array($email))
+ {
+ if (ereg(',$', $email))
+ $email = substr($email, 0, -1);
+
+ if (ereg('^,', $email))
+ $email = substr($email, 1);
+
+ if (ereg(',', $email))
+ {
+ $x = explode(',', $email);
+ $email = array();
+
+ for ($i = 0; $i < count($x); $i ++)
+ $email[] = trim($x[$i]);
+ }
+ else
+ {
+ $email = trim($email);
+ settype($email, "array");
+ }
+ }
+ return $email;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Multipart Value
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function set_alt_message($str = '')
+ {
+ $this->alt_message = ($str == '') ? '' : $str;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Mailtype
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function set_mailtype($type = 'text')
+ {
+ $this->mailtype = ($type == 'html') ? 'html' : 'text';
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Wordwrap
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function set_wordwrap($wordwrap = TRUE)
+ {
+ $this->wordwrap = ($wordwrap === FALSE) ? FALSE : TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Protocol
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function set_protocol($protocol = 'mail')
+ {
+ $this->protocol = ( ! in_array($protocol, $this->_protocols, TRUE)) ? 'mail' : strtolower($protocol);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Priority
+ *
+ * @access public
+ * @param integer
+ * @return void
+ */
+ function set_priority($n = 3)
+ {
+ if ( ! is_numeric($n))
+ {
+ $this->priority = 3;
+ return;
+ }
+
+ if ($n < 1 OR $n > 5)
+ {
+ $this->priority = 3;
+ return;
+ }
+
+ $this->priority = $n;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Newline Character
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function set_newline($newline = "\n")
+ {
+ if ($newline != "\n" OR $newline != "\r\n" OR $newline != "\r")
+ {
+ $this->newline = "\n";
+ return;
+ }
+
+ $this->newline = $newline;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Message Boundary
+ *
+ * @access private
+ * @return void
+ */
+ function _set_boundaries()
+ {
+ $this->_alt_boundary = "B_ALT_".uniqid(''); // multipart/alternative
+ $this->_atc_boundary = "B_ATC_".uniqid(''); // attachment boundary
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get the Message ID
+ *
+ * @access private
+ * @return string
+ */
+ function _get_message_id()
+ {
+ $from = $this->_headers['Return-Path'];
+ $from = str_replace(">", "", $from);
+ $from = str_replace("<", "", $from);
+
+ return "<".uniqid('').strstr($from, '@').">";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get Mail Protocol
+ *
+ * @access private
+ * @param bool
+ * @return string
+ */
+ function _get_protocol($return = true)
+ {
+ $this->protocol = strtolower($this->protocol);
+ $this->protocol = ( ! in_array($this->protocol, $this->_protocols, TRUE)) ? 'mail' : $this->protocol;
+
+ if ($return == true)
+ return $this->protocol;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get Mail Encoding
+ *
+ * @access private
+ * @param bool
+ * @return string
+ */
+ function _get_encoding($return = true)
+ {
+ $this->_encoding = ( ! in_array($this->_encoding, $this->_bit_depths)) ? '7bit' : $this->_encoding;
+
+ if ( ! in_array($this->charset, $this->_base_charsets, TRUE))
+ $this->_encoding = "8bit";
+
+ if ($return == true)
+ return $this->_encoding;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get content type (text/html/attachment)
+ *
+ * @access private
+ * @return string
+ */
+ function _get_content_type()
+ {
+ if ($this->mailtype == 'html' && count($this->_attach_name) == 0)
+ return 'html';
+
+ elseif ($this->mailtype == 'html' && count($this->_attach_name) > 0)
+ return 'html-attach';
+
+ elseif ($this->mailtype == 'text' && count($this->_attach_name) > 0)
+ return 'plain-attach';
+
+ else return 'plain';
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set RFC 822 Date
+ *
+ * @access public
+ * @return string
+ */
+ function _set_date()
+ {
+ $timezone = date("Z");
+ $operator = (substr($timezone, 0, 1) == '-') ? '-' : '+';
+ $timezone = abs($timezone);
+ $timezone = ($timezone/3600) * 100 + ($timezone % 3600) /60;
+
+ return sprintf("%s %s%04d", date("D, j M Y H:i:s"), $operator, $timezone);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Mime message
+ *
+ * @access private
+ * @return string
+ */
+ function _get_mime_message()
+ {
+ return "This is a multi-part message in MIME format.".$this->newline."Your email application may not support this format.";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Validate Email Address
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function validate_email($email)
+ {
+ if ( ! is_array($email))
+ {
+ $this->_set_error_message('email_must_be_array');
+ return FALSE;
+ }
+
+ foreach ($email as $val)
+ {
+ if ( ! $this->valid_email($val))
+ {
+ $this->_set_error_message('email_invalid_address', $val);
+ return FALSE;
+ }
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Email Validation
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function valid_email($address)
+ {
+ if ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $address))
+ return FALSE;
+ else
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Clean Extended Email Address: Joe Smith <joe@smith.com>
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function clean_email($email)
+ {
+ if ( ! is_array($email))
+ {
+ if (preg_match('/\<(.*)\>/', $email, $match))
+ return $match['1'];
+ else
+ return $email;
+ }
+
+ $clean_email = array();
+
+ for ($i=0; $i < count($email); $i++)
+ {
+ if (preg_match( '/\<(.*)\>/', $email[$i], $match))
+ $clean_email[] = $match['1'];
+ else
+ $clean_email[] = $email[$i];
+ }
+
+ return $clean_email;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Build alternative plain text message
+ *
+ * This function provides the raw message for use
+ * in plain-text headers of HTML-formatted emails.
+ * If the user hasn't specified his own alternative message
+ * it creates one by stripping the HTML
+ *
+ * @access private
+ * @return string
+ */
+ function _get_alt_message()
+ {
+ if ($this->alt_message != "")
+ {
+ return $this->word_wrap($this->alt_message, '76');
+ }
+
+ if (eregi( '\<body(.*)\</body\>', $this->_body, $match))
+ {
+ $body = $match['1'];
+ $body = substr($body, strpos($body, ">") + 1);
+ }
+ else
+ {
+ $body = $this->_body;
+ }
+
+ $body = trim(strip_tags($body));
+ $body = preg_replace( '#<!--(.*)--\>#', "", $body);
+ $body = str_replace("\t", "", $body);
+
+ for ($i = 20; $i >= 3; $i--)
+ {
+ $n = "";
+
+ for ($x = 1; $x <= $i; $x ++)
+ $n .= "\n";
+
+ $body = str_replace($n, "\n\n", $body);
+ }
+
+ return $this->word_wrap($body, '76');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Word Wrap
+ *
+ * @access public
+ * @param string
+ * @param integer
+ * @return string
+ */
+ function word_wrap($str, $charlim = '')
+ {
+ // Se the character limit
+ if ($charlim == '')
+ {
+ $charlim = ($this->wrapchars == "") ? "76" : $this->wrapchars;
+ }
+
+ // Reduce multiple spaces
+ $str = preg_replace("| +|", " ", $str);
+
+ // Standardize newlines
+ $str = preg_replace("/\r\n|\r/", "\n", $str);
+
+ // If the current word is surrounded by {unwrap} tags we'll
+ // strip the entire chunk and replace it with a marker.
+ $unwrap = array();
+ if (preg_match_all("|(\{unwrap\}.+?\{/unwrap\})|s", $str, $matches))
+ {
+ for ($i = 0; $i < count($matches['0']); $i++)
+ {
+ $unwrap[] = $matches['1'][$i];
+ $str = str_replace($matches['1'][$i], "{{unwrapped".$i."}}", $str);
+ }
+ }
+
+ // Use PHP's native function to do the initial wordwrap.
+ // We set the cut flag to FALSE so that any individual words that are
+ // too long get left alone. In the next step we'll deal with them.
+ $str = wordwrap($str, $charlim, "\n", FALSE);
+
+ // Split the string into individual lines of text and cycle through them
+ $output = "";
+ foreach (explode("\n", $str) as $line)
+ {
+ // Is the line within the allowed character count?
+ // If so we'll join it to the output and continue
+ if (strlen($line) <= $charlim)
+ {
+ $output .= $line.$this->newline;
+ continue;
+ }
+
+ $temp = '';
+ while((strlen($line)) > $charlim)
+ {
+ // If the over-length word is a URL we won't wrap it
+ if (preg_match("!\[url.+\]|://|wwww.!", $line))
+ {
+ break;
+ }
+
+ // Trim the word down
+ $temp .= substr($line, 0, $charlim-1);
+ $line = substr($line, $charlim-1);
+ }
+
+ // If $temp contains data it means we had to split up an over-length
+ // word into smaller chunks so we'll add it back to our current line
+ if ($temp != '')
+ {
+ $output .= $temp.$this->newline.$line;
+ }
+ else
+ {
+ $output .= $line;
+ }
+
+ $output .= $this->newline;
+ }
+
+ // Put our markers back
+ if (count($unwrap) > 0)
+ {
+ foreach ($unwrap as $key => $val)
+ {
+ $output = str_replace("{{unwrapped".$key."}}", $val, $output);
+ }
+ }
+
+ return $output;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Build final headers
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function _build_headers()
+ {
+ $this->_set_header('X-Sender', $this->clean_email($this->_headers['From']));
+ $this->_set_header('X-Mailer', $this->useragent);
+ $this->_set_header('X-Priority', $this->_priorities[$this->priority - 1]);
+ $this->_set_header('Message-ID', $this->_get_message_id());
+ $this->_set_header('Mime-Version', '1.0');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Write Headers as a string
+ *
+ * @access public
+ * @return void
+ */
+ function _write_headers()
+ {
+ if ($this->protocol == 'mail')
+ {
+ $this->_subject = $this->_headers['Subject'];
+ unset($this->_headers['Subject']);
+ }
+
+ reset($this->_headers);
+ $this->_header_str = "";
+
+ foreach($this->_headers as $key => $val)
+ {
+ $val = trim($val);
+
+ if ($val != "")
+ {
+ $this->_header_str .= $key.": ".$val.$this->newline;
+ }
+ }
+
+ if ($this->_get_protocol() == 'mail')
+ $this->_header_str = substr($this->_header_str, 0, -1);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Build Final Body and attachments
+ *
+ * @access public
+ * @return void
+ */
+ function _build_message()
+ {
+ if ($this->wordwrap === TRUE AND $this->mailtype != 'html')
+ {
+ $this->_body = $this->word_wrap($this->_body);
+ }
+
+ $this->_set_boundaries();
+ $this->_write_headers();
+
+ $hdr = ($this->_get_protocol() == 'mail') ? $this->newline : '';
+
+ switch ($this->_get_content_type())
+ {
+ case 'plain' :
+
+ $hdr .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
+ $hdr .= "Content-Transfer-Encoding: " . $this->_get_encoding();
+
+ if ($this->_get_protocol() == 'mail')
+ {
+ $this->_header_str .= $hdr;
+ $this->_finalbody = $this->_body;
+
+ return;
+ }
+
+ $hdr .= $this->newline . $this->newline . $this->_body;
+
+ $this->_finalbody = $hdr;
+ return;
+
+ break;
+ case 'html' :
+
+ $hdr .= "Content-Type: multipart/alternative; boundary=\"" . $this->_alt_boundary . "\"" . $this->newline;
+ $hdr .= $this->_get_mime_message() . $this->newline . $this->newline;
+ $hdr .= "--" . $this->_alt_boundary . $this->newline;
+
+ $hdr .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
+ $hdr .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline;
+ $hdr .= $this->_get_alt_message() . $this->newline . $this->newline . "--" . $this->_alt_boundary . $this->newline;
+
+ $hdr .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
+ $hdr .= "Content-Transfer-Encoding: quoted/printable";
+
+ if ($this->_get_protocol() == 'mail')
+ {
+ $this->_header_str .= $hdr;
+ $this->_finalbody = $this->_body . $this->newline . $this->newline . "--" . $this->_alt_boundary . "--";
+
+ return;
+ }
+
+ $hdr .= $this->newline . $this->newline;
+ $hdr .= $this->_body . $this->newline . $this->newline . "--" . $this->_alt_boundary . "--";
+
+ $this->_finalbody = $hdr;
+ return;
+
+ break;
+ case 'plain-attach' :
+
+ $hdr .= "Content-Type: multipart/".$this->multipart."; boundary=\"" . $this->_atc_boundary."\"" . $this->newline;
+ $hdr .= $this->_get_mime_message() . $this->newline . $this->newline;
+ $hdr .= "--" . $this->_atc_boundary . $this->newline;
+
+ $hdr .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
+ $hdr .= "Content-Transfer-Encoding: " . $this->_get_encoding();
+
+ if ($this->_get_protocol() == 'mail')
+ {
+ $this->_header_str .= $hdr;
+
+ $body = $this->_body . $this->newline . $this->newline;
+ }
+
+ $hdr .= $this->newline . $this->newline;
+ $hdr .= $this->_body . $this->newline . $this->newline;
+
+ break;
+ case 'html-attach' :
+
+ $hdr .= "Content-Type: multipart/".$this->multipart."; boundary=\"" . $this->_atc_boundary."\"" . $this->newline;
+ $hdr .= $this->_get_mime_message() . $this->newline . $this->newline;
+ $hdr .= "--" . $this->_atc_boundary . $this->newline;
+
+ $hdr .= "Content-Type: multipart/alternative; boundary=\"" . $this->_alt_boundary . "\"" . $this->newline .$this->newline;
+ $hdr .= "--" . $this->_alt_boundary . $this->newline;
+
+ $hdr .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
+ $hdr .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline;
+ $hdr .= $this->_get_alt_message() . $this->newline . $this->newline . "--" . $this->_alt_boundary . $this->newline;
+
+ $hdr .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
+ $hdr .= "Content-Transfer-Encoding: quoted/printable";
+
+ if ($this->_get_protocol() == 'mail')
+ {
+ $this->_header_str .= $hdr;
+
+ $body = $this->_body . $this->newline . $this->newline;
+ $body .= "--" . $this->_alt_boundary . "--" . $this->newline . $this->newline;
+ }
+
+ $hdr .= $this->newline . $this->newline;
+ $hdr .= $this->_body . $this->newline . $this->newline;
+ $hdr .= "--" . $this->_alt_boundary . "--" . $this->newline . $this->newline;
+
+ break;
+ }
+
+ $attachment = array();
+
+ $z = 0;
+
+ for ($i=0; $i < count($this->_attach_name); $i++)
+ {
+ $filename = $this->_attach_name[$i];
+ $basename = basename($filename);
+ $ctype = $this->_attach_type[$i];
+
+ if ( ! file_exists($filename))
+ {
+ $this->_set_error_message('email_attachment_missing', $filename);
+ return FALSE;
+ }
+
+ $h = "--".$this->_atc_boundary.$this->newline;
+ $h .= "Content-type: ".$ctype."; ";
+ $h .= "name=\"".$basename."\"".$this->newline;
+ $h .= "Content-Disposition: ".$this->_attach_disp[$i].";".$this->newline;
+ $h .= "Content-Transfer-Encoding: base64".$this->newline;
+
+ $attachment[$z++] = $h;
+ $file = filesize($filename) +1;
+
+ if ( ! $fp = fopen($filename, 'r'))
+ {
+ $this->_set_error_message('email_attachment_unredable', $filename);
+ return FALSE;
+ }
+
+ $attachment[$z++] = chunk_split(base64_encode(fread($fp, $file)));
+ fclose($fp);
+ }
+
+ if ($this->_get_protocol() == 'mail')
+ {
+ $this->_finalbody = $body . implode($this->newline, $attachment).$this->newline."--".$this->_atc_boundary."--";
+
+ return;
+ }
+
+ $this->_finalbody = $hdr.implode($this->newline, $attachment).$this->newline."--".$this->_atc_boundary."--";
+
+ return;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Send Email
+ *
+ * @access public
+ * @return bool
+ */
+ function send()
+ {
+ if ($this->_replyto_flag == FALSE)
+ {
+ $this->reply_to($this->_headers['From']);
+ }
+
+ if (( ! isset($this->_recipients) AND ! isset($this->_headers['To'])) AND
+ ( ! isset($this->_bcc_array) AND ! isset($this->_headers['Bcc'])) AND
+ ( ! isset($this->_headers['Cc'])))
+ {
+ $this->_set_error_message('email_no_recipients');
+ return FALSE;
+ }
+
+ $this->_build_headers();
+
+ if ($this->bcc_batch_mode AND count($this->_bcc_array) > 0)
+ {
+ if (count($this->_bcc_array) > $this->bcc_batch_size)
+ return $this->batch_bcc_send();
+ }
+
+ $this->_build_message();
+
+ if ( ! $this->_spool_email())
+ return FALSE;
+ else
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Batch Bcc Send. Sends groups of BCCs in batches
+ *
+ * @access public
+ * @return bool
+ */
+ function batch_bcc_send()
+ {
+ $float = $this->bcc_batch_size -1;
+
+ $flag = 0;
+ $set = "";
+
+ $chunk = array();
+
+ for ($i = 0; $i < count($this->_bcc_array); $i++)
+ {
+ if (isset($this->_bcc_array[$i]))
+ $set .= ", ".$this->_bcc_array[$i];
+
+ if ($i == $float)
+ {
+ $chunk[] = substr($set, 1);
+ $float = $float + $this->bcc_batch_size;
+ $set = "";
+ }
+
+ if ($i == count($this->_bcc_array)-1)
+ $chunk[] = substr($set, 1);
+ }
+
+ for ($i = 0; $i < count($chunk); $i++)
+ {
+ unset($this->_headers['Bcc']);
+ unset($bcc);
+
+ $bcc = $this->_str_to_array($chunk[$i]);
+ $bcc = $this->clean_email($bcc);
+
+ if ($this->protocol != 'smtp')
+ $this->_set_header('Bcc', implode(", ", $bcc));
+ else
+ $this->_bcc_array = $bcc;
+
+ $this->_build_message();
+ $this->_spool_email();
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Unwrap special elements
+ *
+ * @access private
+ * @return void
+ */
+ function _unwrap_specials()
+ {
+ $this->_finalbody = preg_replace_callback("/\{unwrap\}(.*?)\{\/unwrap\}/si", array($this, '_remove_nl_callback'), $this->_finalbody);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Strip line-breaks via callback
+ *
+ * @access private
+ * @return string
+ */
+ function _remove_nl_callback($matches)
+ {
+ return preg_replace("/(\r\n)|(\r)|(\n)/", "", $matches['1']);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Spool mail to the mail server
+ *
+ * @access private
+ * @return bool
+ */
+ function _spool_email()
+ {
+ $this->_unwrap_specials();
+
+ switch ($this->_get_protocol())
+ {
+ case 'mail' :
+
+ if ( ! $this->_send_with_mail())
+ {
+ $this->_set_error_message('email_send_failure_phpmail');
+ return FALSE;
+ }
+ break;
+ case 'sendmail' :
+
+ if ( ! $this->_send_with_sendmail())
+ {
+ $this->_set_error_message('email_send_failure_sendmail');
+ return FALSE;
+ }
+ break;
+ case 'smtp' :
+
+ if ( ! $this->_send_with_smtp())
+ {
+ $this->_set_error_message('email_send_failure_smtp');
+ return FALSE;
+ }
+ break;
+
+ }
+
+ $this->_set_error_message('email_sent', $this->_get_protocol());
+ return true;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Send using mail()
+ *
+ * @access private
+ * @return bool
+ */
+ function _send_with_mail()
+ {
+ if ($this->_safe_mode == TRUE)
+ {
+ if ( ! mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str))
+ return FALSE;
+ else
+ return TRUE;
+ }
+ else
+ {
+ if ( ! mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str, "-f".$this->clean_email($this->_headers['From'])))
+ return FALSE;
+ else
+ return TRUE;
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Send using Sendmail
+ *
+ * @access private
+ * @return bool
+ */
+ function _send_with_sendmail()
+ {
+ $fp = @popen($this->mailpath . " -oi -f ".$this->clean_email($this->_headers['From'])." -t", 'w');
+
+ if ( ! is_resource($fp))
+ {
+ $this->_set_error_message('email_no_socket');
+ return FALSE;
+ }
+
+ fputs($fp, $this->_header_str);
+ fputs($fp, $this->_finalbody);
+ pclose($fp) >> 8 & 0xFF;
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Send using SMTP
+ *
+ * @access private
+ * @return bool
+ */
+ function _send_with_smtp()
+ {
+ if ($this->smtp_host == '')
+ {
+ $this->_set_error_message('email_no_hostname');
+ return FALSE;
+ }
+
+ $this->_smtp_connect();
+ $this->_smtp_authenticate();
+
+ $this->_send_command('from', $this->clean_email($this->_headers['From']));
+
+ foreach($this->_recipients as $val)
+ $this->_send_command('to', $val);
+
+ if (count($this->_cc_array) > 0)
+ {
+ foreach($this->_cc_array as $val)
+ {
+ if ($val != "")
+ $this->_send_command('to', $val);
+ }
+ }
+
+ if (count($this->_bcc_array) > 0)
+ {
+ foreach($this->_bcc_array as $val)
+ {
+ if ($val != "")
+ $this->_send_command('to', $val);
+ }
+ }
+
+ $this->_send_command('data');
+
+ $this->_send_data($this->_header_str . $this->_finalbody);
+
+ $this->_send_data('.');
+
+ $reply = $this->_get_smtp_data();
+
+ $this->_set_error_message($reply);
+
+ if (substr($reply, 0, 3) != '250')
+ {
+ $this->_set_error_message('email_smtp_error', $reply);
+ return FALSE;
+ }
+
+ $this->_send_command('quit');
+ return true;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * SMTP Connect
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function _smtp_connect()
+ {
+
+ $this->_smtp_connect = fsockopen($this->smtp_host,
+ $this->smtp_port,
+ $errno,
+ $errstr,
+ $this->smtp_timeout);
+
+ if( ! is_resource($this->_smtp_connect))
+ {
+ $this->_set_error_message('email_smtp_error', $errno." ".$errstr);
+ return FALSE;
+ }
+
+ $this->_set_error_message($this->_get_smtp_data());
+ return $this->_send_command('hello');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Send SMTP command
+ *
+ * @access private
+ * @param string
+ * @param string
+ * @return string
+ */
+ function _send_command($cmd, $data = '')
+ {
+ switch ($cmd)
+ {
+ case 'hello' :
+
+ if ($this->_smtp_auth OR $this->_get_encoding() == '8bit')
+ $this->_send_data('EHLO '.$this->_get_hostname());
+ else
+ $this->_send_data('HELO '.$this->_get_hostname());
+
+ $resp = 250;
+ break;
+ case 'from' :
+
+ $this->_send_data('MAIL FROM:<'.$data.'>');
+
+ $resp = 250;
+ break;
+ case 'to' :
+
+ $this->_send_data('RCPT TO:<'.$data.'>');
+
+ $resp = 250;
+ break;
+ case 'data' :
+
+ $this->_send_data('DATA');
+
+ $resp = 354;
+ break;
+ case 'quit' :
+
+ $this->_send_data('QUIT');
+
+ $resp = 221;
+ break;
+ }
+
+ $reply = $this->_get_smtp_data();
+
+ $this->_debug_msg[] = "<pre>".$cmd.": ".$reply."</pre>";
+
+ if (substr($reply, 0, 3) != $resp)
+ {
+ $this->_set_error_message('email_smtp_error', $reply);
+ return FALSE;
+ }
+
+ if ($cmd == 'quit')
+ fclose($this->_smtp_connect);
+
+ return true;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * SMTP Authenticate
+ *
+ * @access private
+ * @return bool
+ */
+ function _smtp_authenticate()
+ {
+ if ( ! $this->_smtp_auth)
+ return true;
+
+ if ($this->smtp_user == "" AND $this->smtp_pass == "")
+ {
+ $this->_set_error_message('email_no_smtp_unpw');
+ return FALSE;
+ }
+
+ $this->_send_data('AUTH LOGIN');
+
+ $reply = $this->_get_smtp_data();
+
+ if (substr($reply, 0, 3) != '334')
+ {
+ $this->_set_error_message('email_filed_smtp_login', $reply);
+ return FALSE;
+ }
+
+ $this->_send_data(base64_encode($this->smtp_user));
+
+ $reply = $this->_get_smtp_data();
+
+ if (substr($reply, 0, 3) != '334')
+ {
+ $this->_set_error_message('email_smtp_auth_un', $reply);
+ return FALSE;
+ }
+
+ $this->_send_data(base64_encode($this->smtp_pass));
+
+ $reply = $this->_get_smtp_data();
+
+ if (substr($reply, 0, 3) != '235')
+ {
+ $this->_set_error_message('email_smtp_auth_pw', $reply);
+ return FALSE;
+ }
+
+ return true;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Send SMTP data
+ *
+ * @access private
+ * @return bool
+ */
+ function _send_data($data)
+ {
+ if ( ! fwrite($this->_smtp_connect, $data . $this->newline))
+ {
+ $this->_set_error_message('email_smtp_data_failure', $data);
+ return FALSE;
+ }
+ else
+ return true;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get SMTP data
+ *
+ * @access private
+ * @return string
+ */
+ function _get_smtp_data()
+ {
+ $data = "";
+
+ while ($str = fgets($this->_smtp_connect, 512))
+ {
+ $data .= $str;
+
+ if (substr($str, 3, 1) == " ")
+ break;
+ }
+
+ return $data;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get Hostname
+ *
+ * @access private
+ * @return string
+ */
+ function _get_hostname()
+ {
+ return (isset($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : 'localhost.localdomain';
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get IP
+ *
+ * @access private
+ * @return string
+ */
+ function _get_ip()
+ {
+ if ($this->_IP !== FALSE)
+ {
+ return $this->_IP;
+ }
+
+ $cip = (isset($_SERVER['HTTP_CLIENT_IP']) AND $_SERVER['HTTP_CLIENT_IP'] != "") ? $_SERVER['HTTP_CLIENT_IP'] : FALSE;
+ $rip = (isset($_SERVER['REMOTE_ADDR']) AND $_SERVER['REMOTE_ADDR'] != "") ? $_SERVER['REMOTE_ADDR'] : FALSE;
+ $fip = (isset($_SERVER['HTTP_X_FORWARDED_FOR']) AND $_SERVER['HTTP_X_FORWARDED_FOR'] != "") ? $_SERVER['HTTP_X_FORWARDED_FOR'] : FALSE;
+
+ if ($cip && $rip) $this->_IP = $cip;
+ elseif ($rip) $this->_IP = $rip;
+ elseif ($cip) $this->_IP = $cip;
+ elseif ($fip) $this->_IP = $fip;
+
+ if (strstr($this->_IP, ','))
+ {
+ $x = explode(',', $this->_IP);
+ $this->_IP = end($x);
+ }
+
+ if ( ! preg_match( "/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/", $this->_IP))
+ $this->_IP = '0.0.0.0';
+
+ unset($cip);
+ unset($rip);
+ unset($fip);
+
+ return $this->_IP;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get Debug Message
+ *
+ * @access public
+ * @return string
+ */
+ function print_debugger()
+ {
+ $msg = '';
+
+ if (count($this->_debug_msg) > 0)
+ {
+ foreach ($this->_debug_msg as $val)
+ {
+ $msg .= $val;
+ }
+ }
+
+ $msg .= "<pre>".$this->_header_str."\n".$this->_subject."\n".$this->_finalbody.'</pre>';
+ return $msg;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Message
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function _set_error_message($msg, $val = '')
+ {
+ $CI =& get_instance();
+ $CI->lang->load('email');
+
+ if (FALSE === ($line = $CI->lang->line($msg)))
+ {
+ $this->_debug_msg[] = str_replace('%s', $val, $msg)."<br />";
+ }
+ else
+ {
+ $this->_debug_msg[] = str_replace('%s', $val, $line)."<br />";
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Mime Types
+ *
+ * @access private
+ * @param string
+ * @return string
+ */
+ function _mime_types($ext = "")
+ {
+ $mimes = array( 'hqx' => 'application/mac-binhex40',
+ 'cpt' => 'application/mac-compactpro',
+ 'doc' => 'application/msword',
+ 'bin' => 'application/macbinary',
+ 'dms' => 'application/octet-stream',
+ 'lha' => 'application/octet-stream',
+ 'lzh' => 'application/octet-stream',
+ 'exe' => 'application/octet-stream',
+ 'class' => 'application/octet-stream',
+ 'psd' => 'application/octet-stream',
+ 'so' => 'application/octet-stream',
+ 'sea' => 'application/octet-stream',
+ 'dll' => 'application/octet-stream',
+ 'oda' => 'application/oda',
+ 'pdf' => 'application/pdf',
+ 'ai' => 'application/postscript',
+ 'eps' => 'application/postscript',
+ 'ps' => 'application/postscript',
+ 'smi' => 'application/smil',
+ 'smil' => 'application/smil',
+ 'mif' => 'application/vnd.mif',
+ 'xls' => 'application/vnd.ms-excel',
+ 'ppt' => 'application/vnd.ms-powerpoint',
+ 'wbxml' => 'application/vnd.wap.wbxml',
+ 'wmlc' => 'application/vnd.wap.wmlc',
+ 'dcr' => 'application/x-director',
+ 'dir' => 'application/x-director',
+ 'dxr' => 'application/x-director',
+ 'dvi' => 'application/x-dvi',
+ 'gtar' => 'application/x-gtar',
+ 'php' => 'application/x-httpd-php',
+ 'php4' => 'application/x-httpd-php',
+ 'php3' => 'application/x-httpd-php',
+ 'phtml' => 'application/x-httpd-php',
+ 'phps' => 'application/x-httpd-php-source',
+ 'js' => 'application/x-javascript',
+ 'swf' => 'application/x-shockwave-flash',
+ 'sit' => 'application/x-stuffit',
+ 'tar' => 'application/x-tar',
+ 'tgz' => 'application/x-tar',
+ 'xhtml' => 'application/xhtml+xml',
+ 'xht' => 'application/xhtml+xml',
+ 'zip' => 'application/zip',
+ 'mid' => 'audio/midi',
+ 'midi' => 'audio/midi',
+ 'mpga' => 'audio/mpeg',
+ 'mp2' => 'audio/mpeg',
+ 'mp3' => 'audio/mpeg',
+ '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' => 'image/jpeg',
+ 'jpg' => 'image/jpeg',
+ 'jpe' => 'image/jpeg',
+ 'png' => 'image/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' => 'text/plain',
+ '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',
+ 'word' => 'application/msword',
+ 'xl' => 'application/excel',
+ 'eml' => 'message/rfc822'
+ );
+
+ return ( ! isset($mimes[strtolower($ext)])) ? "application/x-unknown-content-type" : $mimes[strtolower($ext)];
+ }
+
+}
+// END CI_Email class
?> \ No newline at end of file
diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php
index 0f860a967..758c0f0a5 100644
--- a/system/libraries/Encrypt.php
+++ b/system/libraries/Encrypt.php
@@ -1,397 +1,397 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Igniter Encryption Class
- *
- * Provides two-way keyed encoding using XOR Hashing and Mcrypt
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Libraries
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/libraries/encryption.html
- */
-class CI_Encrypt {
-
- var $encryption_key = '';
- var $_hash_type = 'sha1';
- var $_mcrypt_exists = FALSE;
- var $_mcrypt_cipher;
- var $_mcrypt_mode;
-
- /**
- * Constructor
- *
- * Simply determines whether the mcrypt library exists.
- *
- */
- function CI_Encrypt()
- {
- $this->_mcrypt_exists = ( ! function_exists('mcrypt_encrypt')) ? FALSE : TRUE;
- log_message('debug', "Encrypt Class Initialized");
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Fetch the encryption key
- *
- * Returns it as MD5 in order to have an exact-length 128 bit key.
- * Mcrypt is sensitive to keys that are not the correct length
- *
- * @access public
- * @param string
- * @return string
- */
- function get_key($key = '')
- {
- if ($key == '')
- {
- if ($this->encryption_key != '')
- {
- return $this->encryption_key;
- }
-
- $CI =& get_instance();
- $key = $CI->config->item('encryption_key');
-
- if ($key === FALSE)
- {
- show_error('In order to use the encryption class requires that you set an encryption key in your config file.');
- }
- }
-
- return md5($key);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set the encryption key
- *
- * @access public
- * @param string
- * @return void
- */
- function set_key($key = '')
- {
- $this->encryption_key = $key;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Encode
- *
- * Encodes the message string using bitwise XOR encoding.
- * The key is combined with a random hash, and then it
- * too gets converted using XOR. The whole thing is then run
- * through mcrypt (if supported) using the randomized key.
- * The end result is a double-encrypted message string
- * that is randomized with each call to this function,
- * even if the supplied message and key are the same.
- *
- * @access public
- * @param string the string to encode
- * @param string the key
- * @return string
- */
- function encode($string, $key = '')
- {
- $key = $this->get_key($key);
- $enc = $this->_xor_encode($string, $key);
-
- if ($this->_mcrypt_exists === TRUE)
- {
- $enc = $this->mcrypt_encode($enc, $key);
- }
- return base64_encode($enc);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Decode
- *
- * Reverses the above process
- *
- * @access public
- * @param string
- * @param string
- * @return string
- */
- function decode($string, $key = '')
- {
- $key = $this->get_key($key);
- $dec = base64_decode($string);
-
- if ($dec === FALSE)
- {
- return FALSE;
- }
-
- if ($this->_mcrypt_exists === TRUE)
- {
- $dec = $this->mcrypt_decode($dec, $key);
- }
-
- return $this->_xor_decode($dec, $key);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * XOR Encode
- *
- * Takes a plain-text string and key as input and generates an
- * encoded bit-string using XOR
- *
- * @access private
- * @param string
- * @param string
- * @return string
- */
- function _xor_encode($string, $key)
- {
- $rand = '';
- while (strlen($rand) < 32)
- {
- $rand .= mt_rand(0, mt_getrandmax());
- }
-
- $rand = $this->hash($rand);
-
- $enc = '';
- for ($i = 0; $i < strlen($string); $i++)
- {
- $enc .= substr($rand, ($i % strlen($rand)), 1).(substr($rand, ($i % strlen($rand)), 1) ^ substr($string, $i, 1));
- }
-
- return $this->_xor_merge($enc, $key);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * XOR Decode
- *
- * Takes an encoded string and key as input and generates the
- * plain-text original message
- *
- * @access private
- * @param string
- * @param string
- * @return string
- */
- function _xor_decode($string, $key)
- {
- $string = $this->_xor_merge($string, $key);
-
- $dec = '';
- for ($i = 0; $i < strlen($string); $i++)
- {
- $dec .= (substr($string, $i++, 1) ^ substr($string, $i, 1));
- }
-
- return $dec;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * XOR key + string Combiner
- *
- * Takes a string and key as input and computes the difference using XOR
- *
- * @access private
- * @param string
- * @param string
- * @return string
- */
- function _xor_merge($string, $key)
- {
- $hash = $this->hash($key);
- $str = '';
- for ($i = 0; $i < strlen($string); $i++)
- {
- $str .= substr($string, $i, 1) ^ substr($hash, ($i % strlen($hash)), 1);
- }
-
- return $str;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Encrypt using Mcrypt
- *
- * @access public
- * @param string
- * @param string
- * @return string
- */
- function mcrypt_encode($data, $key)
- {
- $init_size = mcrypt_get_iv_size($this->_get_cipher(), $this->_get_mode());
- $init_vect = mcrypt_create_iv($init_size, MCRYPT_RAND);
- return mcrypt_encrypt($this->_get_cipher(), $key, $data, $this->_get_mode(), $init_vect);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Decrypt using Mcrypt
- *
- * @access public
- * @param string
- * @param string
- * @return string
- */
- function mcrypt_decode($data, $key)
- {
- $init_size = mcrypt_get_iv_size($this->_get_cipher(), $this->_get_mode());
- $init_vect = mcrypt_create_iv($init_size, MCRYPT_RAND);
- return rtrim(mcrypt_decrypt($this->_get_cipher(), $key, $data, $this->_get_mode(), $init_vect), "\0");
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set the Mcrypt Cipher
- *
- * @access public
- * @param constant
- * @return string
- */
- function set_cipher($cipher)
- {
- $this->_mcrypt_cipher = $cipher;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set the Mcrypt Mode
- *
- * @access public
- * @param constant
- * @return string
- */
- function set_mode($mode)
- {
- $this->_mcrypt_mode = $mode;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Get Mcrypt cipher Value
- *
- * @access private
- * @return string
- */
- function _get_cipher()
- {
- if ($this->_mcrypt_cipher == '')
- {
- $this->_mcrypt_cipher = MCRYPT_RIJNDAEL_256;
- }
-
- return $this->_mcrypt_cipher;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Get Mcrypt MOde Value
- *
- * @access private
- * @return string
- */
- function _get_mode()
- {
- if ($this->_mcrypt_mode == '')
- {
- $this->_mcrypt_mode = MCRYPT_MODE_ECB;
- }
-
- return $this->_mcrypt_mode;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set the Hash type
- *
- * @access public
- * @param string
- * @return string
- */
- function set_hash($type = 'sha1')
- {
- $this->_hash_type = ($type != 'sha1' AND $type != 'md5') ? 'sha1' : $type;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Hash encode a string
- *
- * @access public
- * @param string
- * @return string
- */
- function hash($str)
- {
- return ($this->_hash_type == 'sha1') ? $this->sha1($str) : md5($str);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Generate an SHA1 Hash
- *
- * @access public
- * @param string
- * @return string
- */
- function sha1($str)
- {
- if ( ! function_exists('sha1'))
- {
- if ( ! function_exists('mhash'))
- {
- require_once(BASEPATH.'libraries/Sha1'.EXT);
- $SH = new CI_SHA;
- return $SH->generate($str);
- }
- else
- {
- return bin2hex(mhash(MHASH_SHA1, $str));
- }
- }
- else
- {
- return sha1($str);
- }
- }
-
-}
-
-// END CI_Encrypt class
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Encryption Class
+ *
+ * Provides two-way keyed encoding using XOR Hashing and Mcrypt
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category Libraries
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/libraries/encryption.html
+ */
+class CI_Encrypt {
+
+ var $encryption_key = '';
+ var $_hash_type = 'sha1';
+ var $_mcrypt_exists = FALSE;
+ var $_mcrypt_cipher;
+ var $_mcrypt_mode;
+
+ /**
+ * Constructor
+ *
+ * Simply determines whether the mcrypt library exists.
+ *
+ */
+ function CI_Encrypt()
+ {
+ $this->_mcrypt_exists = ( ! function_exists('mcrypt_encrypt')) ? FALSE : TRUE;
+ log_message('debug', "Encrypt Class Initialized");
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch the encryption key
+ *
+ * Returns it as MD5 in order to have an exact-length 128 bit key.
+ * Mcrypt is sensitive to keys that are not the correct length
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function get_key($key = '')
+ {
+ if ($key == '')
+ {
+ if ($this->encryption_key != '')
+ {
+ return $this->encryption_key;
+ }
+
+ $CI =& get_instance();
+ $key = $CI->config->item('encryption_key');
+
+ if ($key === FALSE)
+ {
+ show_error('In order to use the encryption class requires that you set an encryption key in your config file.');
+ }
+ }
+
+ return md5($key);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set the encryption key
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function set_key($key = '')
+ {
+ $this->encryption_key = $key;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Encode
+ *
+ * Encodes the message string using bitwise XOR encoding.
+ * The key is combined with a random hash, and then it
+ * too gets converted using XOR. The whole thing is then run
+ * through mcrypt (if supported) using the randomized key.
+ * The end result is a double-encrypted message string
+ * that is randomized with each call to this function,
+ * even if the supplied message and key are the same.
+ *
+ * @access public
+ * @param string the string to encode
+ * @param string the key
+ * @return string
+ */
+ function encode($string, $key = '')
+ {
+ $key = $this->get_key($key);
+ $enc = $this->_xor_encode($string, $key);
+
+ if ($this->_mcrypt_exists === TRUE)
+ {
+ $enc = $this->mcrypt_encode($enc, $key);
+ }
+ return base64_encode($enc);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Decode
+ *
+ * Reverses the above process
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return string
+ */
+ function decode($string, $key = '')
+ {
+ $key = $this->get_key($key);
+ $dec = base64_decode($string);
+
+ if ($dec === FALSE)
+ {
+ return FALSE;
+ }
+
+ if ($this->_mcrypt_exists === TRUE)
+ {
+ $dec = $this->mcrypt_decode($dec, $key);
+ }
+
+ return $this->_xor_decode($dec, $key);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * XOR Encode
+ *
+ * Takes a plain-text string and key as input and generates an
+ * encoded bit-string using XOR
+ *
+ * @access private
+ * @param string
+ * @param string
+ * @return string
+ */
+ function _xor_encode($string, $key)
+ {
+ $rand = '';
+ while (strlen($rand) < 32)
+ {
+ $rand .= mt_rand(0, mt_getrandmax());
+ }
+
+ $rand = $this->hash($rand);
+
+ $enc = '';
+ for ($i = 0; $i < strlen($string); $i++)
+ {
+ $enc .= substr($rand, ($i % strlen($rand)), 1).(substr($rand, ($i % strlen($rand)), 1) ^ substr($string, $i, 1));
+ }
+
+ return $this->_xor_merge($enc, $key);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * XOR Decode
+ *
+ * Takes an encoded string and key as input and generates the
+ * plain-text original message
+ *
+ * @access private
+ * @param string
+ * @param string
+ * @return string
+ */
+ function _xor_decode($string, $key)
+ {
+ $string = $this->_xor_merge($string, $key);
+
+ $dec = '';
+ for ($i = 0; $i < strlen($string); $i++)
+ {
+ $dec .= (substr($string, $i++, 1) ^ substr($string, $i, 1));
+ }
+
+ return $dec;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * XOR key + string Combiner
+ *
+ * Takes a string and key as input and computes the difference using XOR
+ *
+ * @access private
+ * @param string
+ * @param string
+ * @return string
+ */
+ function _xor_merge($string, $key)
+ {
+ $hash = $this->hash($key);
+ $str = '';
+ for ($i = 0; $i < strlen($string); $i++)
+ {
+ $str .= substr($string, $i, 1) ^ substr($hash, ($i % strlen($hash)), 1);
+ }
+
+ return $str;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Encrypt using Mcrypt
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return string
+ */
+ function mcrypt_encode($data, $key)
+ {
+ $init_size = mcrypt_get_iv_size($this->_get_cipher(), $this->_get_mode());
+ $init_vect = mcrypt_create_iv($init_size, MCRYPT_RAND);
+ return mcrypt_encrypt($this->_get_cipher(), $key, $data, $this->_get_mode(), $init_vect);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Decrypt using Mcrypt
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return string
+ */
+ function mcrypt_decode($data, $key)
+ {
+ $init_size = mcrypt_get_iv_size($this->_get_cipher(), $this->_get_mode());
+ $init_vect = mcrypt_create_iv($init_size, MCRYPT_RAND);
+ return rtrim(mcrypt_decrypt($this->_get_cipher(), $key, $data, $this->_get_mode(), $init_vect), "\0");
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set the Mcrypt Cipher
+ *
+ * @access public
+ * @param constant
+ * @return string
+ */
+ function set_cipher($cipher)
+ {
+ $this->_mcrypt_cipher = $cipher;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set the Mcrypt Mode
+ *
+ * @access public
+ * @param constant
+ * @return string
+ */
+ function set_mode($mode)
+ {
+ $this->_mcrypt_mode = $mode;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get Mcrypt cipher Value
+ *
+ * @access private
+ * @return string
+ */
+ function _get_cipher()
+ {
+ if ($this->_mcrypt_cipher == '')
+ {
+ $this->_mcrypt_cipher = MCRYPT_RIJNDAEL_256;
+ }
+
+ return $this->_mcrypt_cipher;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get Mcrypt MOde Value
+ *
+ * @access private
+ * @return string
+ */
+ function _get_mode()
+ {
+ if ($this->_mcrypt_mode == '')
+ {
+ $this->_mcrypt_mode = MCRYPT_MODE_ECB;
+ }
+
+ return $this->_mcrypt_mode;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set the Hash type
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function set_hash($type = 'sha1')
+ {
+ $this->_hash_type = ($type != 'sha1' AND $type != 'md5') ? 'sha1' : $type;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Hash encode a string
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function hash($str)
+ {
+ return ($this->_hash_type == 'sha1') ? $this->sha1($str) : md5($str);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Generate an SHA1 Hash
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function sha1($str)
+ {
+ if ( ! function_exists('sha1'))
+ {
+ if ( ! function_exists('mhash'))
+ {
+ require_once(BASEPATH.'libraries/Sha1'.EXT);
+ $SH = new CI_SHA;
+ return $SH->generate($str);
+ }
+ else
+ {
+ return bin2hex(mhash(MHASH_SHA1, $str));
+ }
+ }
+ else
+ {
+ return sha1($str);
+ }
+ }
+
+}
+
+// END CI_Encrypt class
?> \ No newline at end of file
diff --git a/system/libraries/Exceptions.php b/system/libraries/Exceptions.php
index 03588acb3..a0630af08 100644
--- a/system/libraries/Exceptions.php
+++ b/system/libraries/Exceptions.php
@@ -1,12 +1,12 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
- * Code Igniter
+ * CodeIgniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
* @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
* @license http://www.codeignitor.com/user_guide/license.html
* @link http://www.codeigniter.com
* @since Version 1.0
diff --git a/system/libraries/Ftp.php b/system/libraries/Ftp.php
index f213736fb..18f6ff90a 100644
--- a/system/libraries/Ftp.php
+++ b/system/libraries/Ftp.php
@@ -1,616 +1,616 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * FTP Class
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Libraries
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/libraries/ftp.html
- */
-class CI_FTP {
-
- var $hostname = '';
- var $username = '';
- var $password = '';
- var $port = 21;
- var $passive = TRUE;
- var $debug = FALSE;
- var $conn_id = FALSE;
-
-
- /**
- * Constructor - Sets Preferences
- *
- * The constructor can be passed an array of config values
- */
- function CI_FTP($config = array())
- {
- if (count($config) > 0)
- {
- $this->initialize($config);
- }
-
- log_message('debug', "FTP Class Initialized");
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Initialize preferences
- *
- * @access public
- * @param array
- * @return void
- */
- function initialize($config = array())
- {
- foreach ($config as $key => $val)
- {
- if (isset($this->$key))
- {
- $this->$key = $val;
- }
- }
-
- // Prep the hostname
- $this->hostname = preg_replace('|.+?://|', '', $this->hostname);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * FTP Connect
- *
- * @access public
- * @param array the connection values
- * @return bool
- */
- function connect($config = array())
- {
- if (count($config) > 0)
- {
- $this->initialize($config);
- }
-
- if (FALSE === ($this->conn_id = @ftp_connect($this->hostname, $this->port)))
- {
- if ($this->debug == TRUE)
- {
- $this->_error('ftp_unable_to_connect');
- }
- return FALSE;
- }
-
- if ( ! $this->_login())
- {
- if ($this->debug == TRUE)
- {
- $this->_error('ftp_unable_to_login');
- }
- return FALSE;
- }
-
- // Set passive mode if needed
- if ($this->passive == TRUE)
- {
- ftp_pasv($this->conn_id, TRUE);
- }
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * FTP Login
- *
- * @access private
- * @return bool
- */
- function _login()
- {
- return @ftp_login($this->conn_id, $this->username, $this->password);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Validates the connection ID
- *
- * @access private
- * @return bool
- */
- function _is_conn()
- {
- if ( ! is_resource($this->conn_id))
- {
- if ($this->debug == TRUE)
- {
- $this->_error('ftp_no_connection');
- }
- return FALSE;
- }
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
-
- /**
- * Change direcotry
- *
- * The second parameter lets us momentarily turn off debugging so that
- * this function can be used to test for the existance of a folder
- * without throwing an error. There's no FTP equivalent to is_dir()
- * so we do it by trying to change to a particular directory.
- * Internally, this paramter is only used by the "mirror" function below.
- *
- * @access public
- * @param string
- * @param bool
- * @return bool
- */
- function changedir($path = '', $supress_debug = FALSE)
- {
- if ($path == '' OR ! $this->_is_conn())
- {
- return FALSE;
- }
-
- $result = @ftp_chdir($this->conn_id, $path);
-
- if ($result === FALSE)
- {
- if ($this->debug == TRUE AND $supress_debug == FALSE)
- {
- $this->_error('ftp_unable_to_changedir');
- }
- return FALSE;
- }
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Create a directory
- *
- * @access public
- * @param string
- * @return bool
- */
- function mkdir($path = '', $permissions = NULL)
- {
- if ($path == '' OR ! $this->_is_conn())
- {
- return FALSE;
- }
-
- $result = @ftp_mkdir($this->conn_id, $path);
-
- if ($result === FALSE)
- {
- if ($this->debug == TRUE)
- {
- $this->_error('ftp_unable_to_makdir');
- }
- return FALSE;
- }
-
- // Set file permissions if needed
- if ( ! is_null($permissions))
- {
- $this->chmod($path, (int)$permissions);
- }
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Upload a file to the server
- *
- * @access public
- * @param string
- * @param string
- * @param string
- * @return bool
- */
- function upload($locpath, $rempath, $mode = 'auto', $permissions = NULL)
- {
- if ( ! $this->_is_conn())
- {
- return FALSE;
- }
-
- if ( ! file_exists($locpath))
- {
- $this->_error('ftp_no_source_file');
- return FALSE;
- }
-
- // Set the mode if not specified
- if ($mode == 'auto')
- {
- // Get the file extension so we can set the upload type
- $ext = $this->_getext($locpath);
- $mode = $this->_settype($ext);
- }
-
- $mode = ($mode == 'ascii') ? FTP_ASCII : FTP_BINARY;
-
- $result = @ftp_put($this->conn_id, $rempath, $locpath, $mode);
-
- if ($result === FALSE)
- {
- if ($this->debug == TRUE)
- {
- $this->_error('ftp_unable_to_upload');
- }
- return FALSE;
- }
-
- // Set file permissions if needed
- if ( ! is_null($permissions))
- {
- $this->chmod($rempath, (int)$permissions);
- }
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Rename (or move) a file
- *
- * @access public
- * @param string
- * @param string
- * @param bool
- * @return bool
- */
- function rename($old_file, $new_file, $move = FALSE)
- {
- if ( ! $this->_is_conn())
- {
- return FALSE;
- }
-
- $result = @ftp_rename($this->conn_id, $old_file, $new_file);
-
- if ($result === FALSE)
- {
- if ($this->debug == TRUE)
- {
- $msg = ($move = FALSE) ? 'ftp_unable_to_remame' : 'ftp_unable_to_move';
-
- $this->_error($msg);
- }
- return FALSE;
- }
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Move a file
- *
- * @access public
- * @param string
- * @param string
- * @return bool
- */
- function move($old_file, $new_file)
- {
- return $this->rename($old_file, $new_file, TRUE);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Rename (or move) a file
- *
- * @access public
- * @param string
- * @return bool
- */
- function delete_file($filepath)
- {
- if ( ! $this->_is_conn())
- {
- return FALSE;
- }
-
- $result = @ftp_delete($this->conn_id, $filepath);
-
- if ($result === FALSE)
- {
- if ($this->debug == TRUE)
- {
- $this->_error('ftp_unable_to_delete');
- }
- return FALSE;
- }
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Delete a folder and recursively delete everything (including sub-folders)
- * containted within it.
- *
- * @access public
- * @param string
- * @return bool
- */
- function delete_dir($filepath)
- {
- if ( ! $this->_is_conn())
- {
- return FALSE;
- }
-
- // Add a trailing slash to the file path if needed
- $filepath = preg_replace("/(.+?)\/*$/", "\\1/", $filepath);
-
- $list = $this->list_files($filepath);
-
- if ($list !== FALSE AND count($list) > 0)
- {
- foreach ($list as $item)
- {
- // If we can't delete the item it's probaly a folder so
- // we'll recursively call delete_dir()
- if ( ! @ftp_delete($this->conn_id, $filepath.$item))
- {
- $this->delete_dir($filepath.$item);
- }
- }
- }
-
- $result = @ftp_rmdir($this->conn_id, $filepath);
-
- if ($result === FALSE)
- {
- if ($this->debug == TRUE)
- {
- $this->_error('ftp_unable_to_delete');
- }
- return FALSE;
- }
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set file permissions
- *
- * @access public
- * @param string the file path
- * @param string the permissions
- * @return bool
- */
- function chmod($path, $perm)
- {
- if ( ! $this->_is_conn())
- {
- return FALSE;
- }
-
- // Permissions can only be set when running PHP 5
- if ( ! function_exists('ftp_chmod'))
- {
- if ($this->debug == TRUE)
- {
- $this->_error('ftp_unable_to_chmod');
- }
- return FALSE;
- }
-
- $result = @ftp_chmod($this->conn_id, $perm, $path);
-
- if ($result === FALSE)
- {
- if ($this->debug == TRUE)
- {
- $this->_error('ftp_unable_to_chmod');
- }
- return FALSE;
- }
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * FTP List files in the specified directory
- *
- * @access public
- * @return array
- */
- function list_files($path = '.')
- {
- if ( ! $this->_is_conn())
- {
- return FALSE;
- }
-
- return ftp_nlist($this->conn_id, $path);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * Read a directory and recreate it remotely
- *
- * This function recursively reads a folder and everything it contains (including
- * sub-folders) and creates a mirror via FTP based on it. Whatever the directory structure
- * of the original file path will be recreated on the server.
- *
- * @access public
- * @param string path to source with trailing slash
- * @param string path to destination - include the base folder with trailing slash
- * @return bool
- */
- function mirror($locpath, $rempath)
- {
- if ( ! $this->_is_conn())
- {
- return FALSE;
- }
-
- // Open the local file path
- if ($fp = @opendir($locpath))
- {
- // Attempt to open the remote file path.
- if ( ! $this->changedir($rempath, TRUE))
- {
- // If it doesn't exist we'll attempt to create the direcotory
- if ( ! $this->mkdir($rempath) OR ! $this->changedir($rempath))
- {
- return FALSE;
- }
- }
-
- // Recursively read the local directory
- while (FALSE !== ($file = readdir($fp)))
- {
- if (@is_dir($locpath.$file) && substr($file, 0, 1) != '.')
- {
- $this->mirror($locpath.$file."/", $rempath.$file."/");
- }
- elseif (substr($file, 0, 1) != ".")
- {
- // Get the file extension so we can se the upload type
- $ext = $this->_getext($file);
- $mode = $this->_settype($ext);
-
- $this->upload($locpath.$file, $rempath.$file, $mode);
- }
- }
- return TRUE;
- }
-
- return FALSE;
- }
-
-
- // --------------------------------------------------------------------
-
- /**
- * Extract the file extension
- *
- * @access private
- * @param string
- * @return string
- */
- function _getext($filename)
- {
- if (FALSE === strpos($filename, '.'))
- {
- return 'txt';
- }
-
- $x = explode('.', $filename);
- return end($x);
- }
-
-
- // --------------------------------------------------------------------
-
- /**
- * Set the upload type
- *
- * @access private
- * @param string
- * @return string
- */
- function _settype($ext)
- {
- $text_types = array(
- 'txt',
- 'text',
- 'php',
- 'phps',
- 'php4',
- 'js',
- 'css',
- 'htm',
- 'html',
- 'phtml',
- 'shtml',
- 'log',
- 'xml'
- );
-
-
- return (in_array($ext, $text_types)) ? 'ascii' : 'binary';
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * Close the connection
- *
- * @access public
- * @param string path to source
- * @param string path to destination
- * @return bool
- */
- function close()
- {
- if ( ! $this->_is_conn())
- {
- return FALSE;
- }
-
- @ftp_close($this->conn_id);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * Display error message
- *
- * @access private
- * @param string
- * @return bool
- */
- function _error($line)
- {
- $CI =& get_instance();
- $CI->lang->load('ftp');
- show_error($CI->lang->line($line));
- }
-
-
-}
-// END FTP Class
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * FTP Class
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category Libraries
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/libraries/ftp.html
+ */
+class CI_FTP {
+
+ var $hostname = '';
+ var $username = '';
+ var $password = '';
+ var $port = 21;
+ var $passive = TRUE;
+ var $debug = FALSE;
+ var $conn_id = FALSE;
+
+
+ /**
+ * Constructor - Sets Preferences
+ *
+ * The constructor can be passed an array of config values
+ */
+ function CI_FTP($config = array())
+ {
+ if (count($config) > 0)
+ {
+ $this->initialize($config);
+ }
+
+ log_message('debug', "FTP Class Initialized");
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Initialize preferences
+ *
+ * @access public
+ * @param array
+ * @return void
+ */
+ function initialize($config = array())
+ {
+ foreach ($config as $key => $val)
+ {
+ if (isset($this->$key))
+ {
+ $this->$key = $val;
+ }
+ }
+
+ // Prep the hostname
+ $this->hostname = preg_replace('|.+?://|', '', $this->hostname);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * FTP Connect
+ *
+ * @access public
+ * @param array the connection values
+ * @return bool
+ */
+ function connect($config = array())
+ {
+ if (count($config) > 0)
+ {
+ $this->initialize($config);
+ }
+
+ if (FALSE === ($this->conn_id = @ftp_connect($this->hostname, $this->port)))
+ {
+ if ($this->debug == TRUE)
+ {
+ $this->_error('ftp_unable_to_connect');
+ }
+ return FALSE;
+ }
+
+ if ( ! $this->_login())
+ {
+ if ($this->debug == TRUE)
+ {
+ $this->_error('ftp_unable_to_login');
+ }
+ return FALSE;
+ }
+
+ // Set passive mode if needed
+ if ($this->passive == TRUE)
+ {
+ ftp_pasv($this->conn_id, TRUE);
+ }
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * FTP Login
+ *
+ * @access private
+ * @return bool
+ */
+ function _login()
+ {
+ return @ftp_login($this->conn_id, $this->username, $this->password);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Validates the connection ID
+ *
+ * @access private
+ * @return bool
+ */
+ function _is_conn()
+ {
+ if ( ! is_resource($this->conn_id))
+ {
+ if ($this->debug == TRUE)
+ {
+ $this->_error('ftp_no_connection');
+ }
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+
+ /**
+ * Change direcotry
+ *
+ * The second parameter lets us momentarily turn off debugging so that
+ * this function can be used to test for the existance of a folder
+ * without throwing an error. There's no FTP equivalent to is_dir()
+ * so we do it by trying to change to a particular directory.
+ * Internally, this paramter is only used by the "mirror" function below.
+ *
+ * @access public
+ * @param string
+ * @param bool
+ * @return bool
+ */
+ function changedir($path = '', $supress_debug = FALSE)
+ {
+ if ($path == '' OR ! $this->_is_conn())
+ {
+ return FALSE;
+ }
+
+ $result = @ftp_chdir($this->conn_id, $path);
+
+ if ($result === FALSE)
+ {
+ if ($this->debug == TRUE AND $supress_debug == FALSE)
+ {
+ $this->_error('ftp_unable_to_changedir');
+ }
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Create a directory
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function mkdir($path = '', $permissions = NULL)
+ {
+ if ($path == '' OR ! $this->_is_conn())
+ {
+ return FALSE;
+ }
+
+ $result = @ftp_mkdir($this->conn_id, $path);
+
+ if ($result === FALSE)
+ {
+ if ($this->debug == TRUE)
+ {
+ $this->_error('ftp_unable_to_makdir');
+ }
+ return FALSE;
+ }
+
+ // Set file permissions if needed
+ if ( ! is_null($permissions))
+ {
+ $this->chmod($path, (int)$permissions);
+ }
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Upload a file to the server
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @param string
+ * @return bool
+ */
+ function upload($locpath, $rempath, $mode = 'auto', $permissions = NULL)
+ {
+ if ( ! $this->_is_conn())
+ {
+ return FALSE;
+ }
+
+ if ( ! file_exists($locpath))
+ {
+ $this->_error('ftp_no_source_file');
+ return FALSE;
+ }
+
+ // Set the mode if not specified
+ if ($mode == 'auto')
+ {
+ // Get the file extension so we can set the upload type
+ $ext = $this->_getext($locpath);
+ $mode = $this->_settype($ext);
+ }
+
+ $mode = ($mode == 'ascii') ? FTP_ASCII : FTP_BINARY;
+
+ $result = @ftp_put($this->conn_id, $rempath, $locpath, $mode);
+
+ if ($result === FALSE)
+ {
+ if ($this->debug == TRUE)
+ {
+ $this->_error('ftp_unable_to_upload');
+ }
+ return FALSE;
+ }
+
+ // Set file permissions if needed
+ if ( ! is_null($permissions))
+ {
+ $this->chmod($rempath, (int)$permissions);
+ }
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Rename (or move) a file
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @param bool
+ * @return bool
+ */
+ function rename($old_file, $new_file, $move = FALSE)
+ {
+ if ( ! $this->_is_conn())
+ {
+ return FALSE;
+ }
+
+ $result = @ftp_rename($this->conn_id, $old_file, $new_file);
+
+ if ($result === FALSE)
+ {
+ if ($this->debug == TRUE)
+ {
+ $msg = ($move = FALSE) ? 'ftp_unable_to_remame' : 'ftp_unable_to_move';
+
+ $this->_error($msg);
+ }
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Move a file
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return bool
+ */
+ function move($old_file, $new_file)
+ {
+ return $this->rename($old_file, $new_file, TRUE);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Rename (or move) a file
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function delete_file($filepath)
+ {
+ if ( ! $this->_is_conn())
+ {
+ return FALSE;
+ }
+
+ $result = @ftp_delete($this->conn_id, $filepath);
+
+ if ($result === FALSE)
+ {
+ if ($this->debug == TRUE)
+ {
+ $this->_error('ftp_unable_to_delete');
+ }
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Delete a folder and recursively delete everything (including sub-folders)
+ * containted within it.
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function delete_dir($filepath)
+ {
+ if ( ! $this->_is_conn())
+ {
+ return FALSE;
+ }
+
+ // Add a trailing slash to the file path if needed
+ $filepath = preg_replace("/(.+?)\/*$/", "\\1/", $filepath);
+
+ $list = $this->list_files($filepath);
+
+ if ($list !== FALSE AND count($list) > 0)
+ {
+ foreach ($list as $item)
+ {
+ // If we can't delete the item it's probaly a folder so
+ // we'll recursively call delete_dir()
+ if ( ! @ftp_delete($this->conn_id, $filepath.$item))
+ {
+ $this->delete_dir($filepath.$item);
+ }
+ }
+ }
+
+ $result = @ftp_rmdir($this->conn_id, $filepath);
+
+ if ($result === FALSE)
+ {
+ if ($this->debug == TRUE)
+ {
+ $this->_error('ftp_unable_to_delete');
+ }
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set file permissions
+ *
+ * @access public
+ * @param string the file path
+ * @param string the permissions
+ * @return bool
+ */
+ function chmod($path, $perm)
+ {
+ if ( ! $this->_is_conn())
+ {
+ return FALSE;
+ }
+
+ // Permissions can only be set when running PHP 5
+ if ( ! function_exists('ftp_chmod'))
+ {
+ if ($this->debug == TRUE)
+ {
+ $this->_error('ftp_unable_to_chmod');
+ }
+ return FALSE;
+ }
+
+ $result = @ftp_chmod($this->conn_id, $perm, $path);
+
+ if ($result === FALSE)
+ {
+ if ($this->debug == TRUE)
+ {
+ $this->_error('ftp_unable_to_chmod');
+ }
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * FTP List files in the specified directory
+ *
+ * @access public
+ * @return array
+ */
+ function list_files($path = '.')
+ {
+ if ( ! $this->_is_conn())
+ {
+ return FALSE;
+ }
+
+ return ftp_nlist($this->conn_id, $path);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Read a directory and recreate it remotely
+ *
+ * This function recursively reads a folder and everything it contains (including
+ * sub-folders) and creates a mirror via FTP based on it. Whatever the directory structure
+ * of the original file path will be recreated on the server.
+ *
+ * @access public
+ * @param string path to source with trailing slash
+ * @param string path to destination - include the base folder with trailing slash
+ * @return bool
+ */
+ function mirror($locpath, $rempath)
+ {
+ if ( ! $this->_is_conn())
+ {
+ return FALSE;
+ }
+
+ // Open the local file path
+ if ($fp = @opendir($locpath))
+ {
+ // Attempt to open the remote file path.
+ if ( ! $this->changedir($rempath, TRUE))
+ {
+ // If it doesn't exist we'll attempt to create the direcotory
+ if ( ! $this->mkdir($rempath) OR ! $this->changedir($rempath))
+ {
+ return FALSE;
+ }
+ }
+
+ // Recursively read the local directory
+ while (FALSE !== ($file = readdir($fp)))
+ {
+ if (@is_dir($locpath.$file) && substr($file, 0, 1) != '.')
+ {
+ $this->mirror($locpath.$file."/", $rempath.$file."/");
+ }
+ elseif (substr($file, 0, 1) != ".")
+ {
+ // Get the file extension so we can se the upload type
+ $ext = $this->_getext($file);
+ $mode = $this->_settype($ext);
+
+ $this->upload($locpath.$file, $rempath.$file, $mode);
+ }
+ }
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Extract the file extension
+ *
+ * @access private
+ * @param string
+ * @return string
+ */
+ function _getext($filename)
+ {
+ if (FALSE === strpos($filename, '.'))
+ {
+ return 'txt';
+ }
+
+ $x = explode('.', $filename);
+ return end($x);
+ }
+
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set the upload type
+ *
+ * @access private
+ * @param string
+ * @return string
+ */
+ function _settype($ext)
+ {
+ $text_types = array(
+ 'txt',
+ 'text',
+ 'php',
+ 'phps',
+ 'php4',
+ 'js',
+ 'css',
+ 'htm',
+ 'html',
+ 'phtml',
+ 'shtml',
+ 'log',
+ 'xml'
+ );
+
+
+ return (in_array($ext, $text_types)) ? 'ascii' : 'binary';
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Close the connection
+ *
+ * @access public
+ * @param string path to source
+ * @param string path to destination
+ * @return bool
+ */
+ function close()
+ {
+ if ( ! $this->_is_conn())
+ {
+ return FALSE;
+ }
+
+ @ftp_close($this->conn_id);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Display error message
+ *
+ * @access private
+ * @param string
+ * @return bool
+ */
+ function _error($line)
+ {
+ $CI =& get_instance();
+ $CI->lang->load('ftp');
+ show_error($CI->lang->line($line));
+ }
+
+
+}
+// END FTP Class
?> \ No newline at end of file
diff --git a/system/libraries/Hooks.php b/system/libraries/Hooks.php
index 99d2e3e30..bb06fceeb 100644
--- a/system/libraries/Hooks.php
+++ b/system/libraries/Hooks.php
@@ -1,224 +1,224 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Igniter Hooks Class
- *
- * Provides a mechanism to extend the base system without hacking. Most of
- * this class is borrowed from Paul's Extension class in ExpressionEngine.
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Libraries
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/libraries/encryption.html
- */
-class CI_Hooks {
-
- var $enabled = FALSE;
- var $hooks = array();
- var $in_progress = FALSE;
-
- /**
- * Constructor
- *
- */
- function CI_Hooks()
- {
- $this->_initialize();
- log_message('debug', "Hooks Class Initialized");
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Initialize the Hooks Preferences
- *
- * @access private
- * @return void
- */
- function _initialize()
- {
- $CFG =& load_class('Config');
-
- // 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
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Hooks Class
+ *
+ * Provides a mechanism to extend the base system without hacking. Most of
+ * this class is borrowed from Paul's Extension class in ExpressionEngine.
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category Libraries
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/libraries/encryption.html
+ */
+class CI_Hooks {
+
+ var $enabled = FALSE;
+ var $hooks = array();
+ var $in_progress = FALSE;
+
+ /**
+ * Constructor
+ *
+ */
+ function CI_Hooks()
+ {
+ $this->_initialize();
+ log_message('debug', "Hooks Class Initialized");
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Initialize the Hooks Preferences
+ *
+ * @access private
+ * @return void
+ */
+ function _initialize()
+ {
+ $CFG =& load_class('Config');
+
+ // 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
?> \ No newline at end of file
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index 28e1bfbbc..e79dad445 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -1,12 +1,12 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
- * Code Igniter
+ * CodeIgniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
* @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
* @license http://www.codeignitor.com/user_guide/license.html
* @link http://www.codeigniter.com
* @since Version 1.0
diff --git a/system/libraries/Input.php b/system/libraries/Input.php
index 3a35f498a..64c0ed418 100644
--- a/system/libraries/Input.php
+++ b/system/libraries/Input.php
@@ -1,12 +1,12 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
- * Code Igniter
+ * CodeIgniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
* @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
* @license http://www.codeignitor.com/user_guide/license.html
* @link http://www.codeigniter.com
* @since Version 1.0
diff --git a/system/libraries/Language.php b/system/libraries/Language.php
index faf516ea5..26775ec7e 100644
--- a/system/libraries/Language.php
+++ b/system/libraries/Language.php
@@ -1,121 +1,121 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Language Class
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Language
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/libraries/language.html
- */
-class CI_Language {
-
- var $language = array();
- var $is_loaded = array();
-
- /**
- * Constructor
- *
- * @access public
- */
- function CI_Language()
- {
- 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 void
- */
- function load($langfile = '', $idiom = '', $return = FALSE)
- {
- $langfile = str_replace(EXT, '', str_replace('_lang.', '', $langfile)).'_lang'.EXT;
-
- if (in_array($langfile, $this->is_loaded, TRUE))
- {
- return;
- }
-
- if ($idiom == '')
- {
- $CI =& get_instance();
- $deft_lang = $CI->config->item('language');
- $idiom = ($deft_lang == '') ? 'english' : $deft_lang;
- }
-
- // Determine where the language file is and load it
- if (file_exists(APPPATH.'language/'.$idiom.'/'.$langfile))
- {
- include(APPPATH.'language/'.$idiom.'/'.$langfile);
- }
- else
- {
- if (file_exists(BASEPATH.'language/'.$idiom.'/'.$langfile))
- {
- include(BASEPATH.'language/'.$idiom.'/'.$langfile);
- }
- else
- {
- show_error('Unable to load the requested language file: language/'.$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 the language line
- * @return string
- */
- function line($line = '')
- {
- return ($line == '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line];
- }
-
-}
-// END Language Class
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Language Class
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category Language
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/libraries/language.html
+ */
+class CI_Language {
+
+ var $language = array();
+ var $is_loaded = array();
+
+ /**
+ * Constructor
+ *
+ * @access public
+ */
+ function CI_Language()
+ {
+ 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 void
+ */
+ function load($langfile = '', $idiom = '', $return = FALSE)
+ {
+ $langfile = str_replace(EXT, '', str_replace('_lang.', '', $langfile)).'_lang'.EXT;
+
+ if (in_array($langfile, $this->is_loaded, TRUE))
+ {
+ return;
+ }
+
+ if ($idiom == '')
+ {
+ $CI =& get_instance();
+ $deft_lang = $CI->config->item('language');
+ $idiom = ($deft_lang == '') ? 'english' : $deft_lang;
+ }
+
+ // Determine where the language file is and load it
+ if (file_exists(APPPATH.'language/'.$idiom.'/'.$langfile))
+ {
+ include(APPPATH.'language/'.$idiom.'/'.$langfile);
+ }
+ else
+ {
+ if (file_exists(BASEPATH.'language/'.$idiom.'/'.$langfile))
+ {
+ include(BASEPATH.'language/'.$idiom.'/'.$langfile);
+ }
+ else
+ {
+ show_error('Unable to load the requested language file: language/'.$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 the language line
+ * @return string
+ */
+ function line($line = '')
+ {
+ return ($line == '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line];
+ }
+
+}
+// END Language Class
?> \ No newline at end of file
diff --git a/system/libraries/Loader.php b/system/libraries/Loader.php
index e634c3885..ff5ffbfe4 100644
--- a/system/libraries/Loader.php
+++ b/system/libraries/Loader.php
@@ -1,12 +1,12 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
- * Code Igniter
+ * CodeIgniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
* @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
* @license http://www.codeignitor.com/user_guide/license.html
* @link http://www.codeigniter.com
* @since Version 1.0
diff --git a/system/libraries/Log.php b/system/libraries/Log.php
index b21096c50..b82fe96bd 100644
--- a/system/libraries/Log.php
+++ b/system/libraries/Log.php
@@ -1,118 +1,118 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Logging Class
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Logging
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/general/errors.html
- */
-class CI_Log {
-
- var $log_path;
- var $_threshold = 1;
- var $_date_fmt = 'Y-m-d H:i:s';
- var $_enabled = TRUE;
- var $_levels = array('ERROR' => '1', 'DEBUG' => '2', 'INFO' => '3', 'ALL' => '4');
-
- /**
- * Constructor
- *
- * @access public
- * @param string the log file path
- * @param string the error threshold
- * @param string the date formatting codes
- */
- function CI_Log()
- {
- $config =& get_config();
-
- $this->log_path = ($config['log_path'] != '') ? $config['log_path'] : BASEPATH.'logs/';
-
- if ( ! is_dir($this->log_path) OR ! is_writable($this->log_path))
- {
- $this->_enabled = FALSE;
- }
-
- if (is_numeric($config['log_threshold']))
- {
- $this->_threshold = $config['log_threshold'];
- }
-
- if ($config['log_date_format'] != '')
- {
- $this->_date_fmt = $config['log_date_format'];
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Write Log File
- *
- * Generally this function will be called using the global log_message() function
- *
- * @access public
- * @param string the error level
- * @param string the error message
- * @param bool whether the error is a native PHP error
- * @return bool
- */
- function write_log($level = 'error', $msg, $php_error = FALSE)
- {
- if ($this->_enabled === FALSE)
- {
- return FALSE;
- }
-
- $level = strtoupper($level);
-
- if ( ! isset($this->_levels[$level]) OR ($this->_levels[$level] > $this->_threshold))
- {
- return FALSE;
- }
-
- $filepath = $this->log_path.'log-'.date('Y-m-d').EXT;
- $message = '';
-
- if ( ! file_exists($filepath))
- {
- $message .= "<"."?php if (!defined('BASEPATH')) exit('No direct script access allowed'); ?".">\n\n";
- }
-
- if ( ! $fp = @fopen($filepath, "a"))
- {
- return FALSE;
- }
-
- $message .= $level.' '.(($level == 'INFO') ? ' -' : '-').' '.date($this->_date_fmt). ' --> '.$msg."\n";
-
- flock($fp, LOCK_EX);
- fwrite($fp, $message);
- flock($fp, LOCK_UN);
- fclose($fp);
-
- @chmod($filepath, 0666);
- return TRUE;
- }
-
-}
-// END Log Class
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Logging Class
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category Logging
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/general/errors.html
+ */
+class CI_Log {
+
+ var $log_path;
+ var $_threshold = 1;
+ var $_date_fmt = 'Y-m-d H:i:s';
+ var $_enabled = TRUE;
+ var $_levels = array('ERROR' => '1', 'DEBUG' => '2', 'INFO' => '3', 'ALL' => '4');
+
+ /**
+ * Constructor
+ *
+ * @access public
+ * @param string the log file path
+ * @param string the error threshold
+ * @param string the date formatting codes
+ */
+ function CI_Log()
+ {
+ $config =& get_config();
+
+ $this->log_path = ($config['log_path'] != '') ? $config['log_path'] : BASEPATH.'logs/';
+
+ if ( ! is_dir($this->log_path) OR ! is_writable($this->log_path))
+ {
+ $this->_enabled = FALSE;
+ }
+
+ if (is_numeric($config['log_threshold']))
+ {
+ $this->_threshold = $config['log_threshold'];
+ }
+
+ if ($config['log_date_format'] != '')
+ {
+ $this->_date_fmt = $config['log_date_format'];
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Write Log File
+ *
+ * Generally this function will be called using the global log_message() function
+ *
+ * @access public
+ * @param string the error level
+ * @param string the error message
+ * @param bool whether the error is a native PHP error
+ * @return bool
+ */
+ function write_log($level = 'error', $msg, $php_error = FALSE)
+ {
+ if ($this->_enabled === FALSE)
+ {
+ return FALSE;
+ }
+
+ $level = strtoupper($level);
+
+ if ( ! isset($this->_levels[$level]) OR ($this->_levels[$level] > $this->_threshold))
+ {
+ return FALSE;
+ }
+
+ $filepath = $this->log_path.'log-'.date('Y-m-d').EXT;
+ $message = '';
+
+ if ( ! file_exists($filepath))
+ {
+ $message .= "<"."?php if (!defined('BASEPATH')) exit('No direct script access allowed'); ?".">\n\n";
+ }
+
+ if ( ! $fp = @fopen($filepath, "a"))
+ {
+ return FALSE;
+ }
+
+ $message .= $level.' '.(($level == 'INFO') ? ' -' : '-').' '.date($this->_date_fmt). ' --> '.$msg."\n";
+
+ flock($fp, LOCK_EX);
+ fwrite($fp, $message);
+ flock($fp, LOCK_UN);
+ fclose($fp);
+
+ @chmod($filepath, 0666);
+ return TRUE;
+ }
+
+}
+// END Log Class
?> \ No newline at end of file
diff --git a/system/libraries/Model.php b/system/libraries/Model.php
index 6f4f7e7ef..3b4c2e144 100644
--- a/system/libraries/Model.php
+++ b/system/libraries/Model.php
@@ -1,82 +1,82 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Code Igniter Model Class
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Libraries
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/libraries/config.html
- */
-class Model {
-
- var $_parent_name = '';
-
- /**
- * Constructor
- *
- * @access public
- */
- function Model()
- {
- // If the magic __get() or __set() methods are used in a Model references can't be used.
- $this->_assign_libraries( (method_exists($this, '__get') OR method_exists($this, '__set')) ? FALSE : TRUE );
-
- // We don't want to assign the model object to itself when using the
- // assign_libraries function below so we'll grab the name of the model parent
- $this->_parent_name = ucfirst(get_class($this));
-
- log_message('debug', "Model Class Initialized");
- }
-
- /**
- * Assign Libraries
- *
- * Creates local references to all currently instantiated objects
- * so that any syntax that can be legally used in a controller
- * can be used within models.
- *
- * @access private
- */
- function _assign_libraries($use_reference = TRUE)
- {
- $CI =& get_instance();
- foreach (array_keys(get_object_vars($CI)) as $key)
- {
- if ( ! isset($this->$key) AND $key != $this->_parent_name)
- {
- // In some cases using references can cause
- // problems so we'll conditionally use them
- if ($use_reference == TRUE)
- {
- // Needed to prevent reference errors with some configurations
- $this->$key = '';
- $this->$key =& $CI->$key;
- }
- else
- {
- $this->$key = $CI->$key;
- }
- }
- }
- }
-
-}
-// END Model Class
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Model Class
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category Libraries
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/libraries/config.html
+ */
+class Model {
+
+ var $_parent_name = '';
+
+ /**
+ * Constructor
+ *
+ * @access public
+ */
+ function Model()
+ {
+ // If the magic __get() or __set() methods are used in a Model references can't be used.
+ $this->_assign_libraries( (method_exists($this, '__get') OR method_exists($this, '__set')) ? FALSE : TRUE );
+
+ // We don't want to assign the model object to itself when using the
+ // assign_libraries function below so we'll grab the name of the model parent
+ $this->_parent_name = ucfirst(get_class($this));
+
+ log_message('debug', "Model Class Initialized");
+ }
+
+ /**
+ * Assign Libraries
+ *
+ * Creates local references to all currently instantiated objects
+ * so that any syntax that can be legally used in a controller
+ * can be used within models.
+ *
+ * @access private
+ */
+ function _assign_libraries($use_reference = TRUE)
+ {
+ $CI =& get_instance();
+ foreach (array_keys(get_object_vars($CI)) as $key)
+ {
+ if ( ! isset($this->$key) AND $key != $this->_parent_name)
+ {
+ // In some cases using references can cause
+ // problems so we'll conditionally use them
+ if ($use_reference == TRUE)
+ {
+ // Needed to prevent reference errors with some configurations
+ $this->$key = '';
+ $this->$key =& $CI->$key;
+ }
+ else
+ {
+ $this->$key = $CI->$key;
+ }
+ }
+ }
+ }
+
+}
+// END Model Class
?> \ No newline at end of file
diff --git a/system/libraries/Output.php b/system/libraries/Output.php
index e53627408..743228e53 100644
--- a/system/libraries/Output.php
+++ b/system/libraries/Output.php
@@ -1,364 +1,364 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Output Class
- *
- * Responsible for sending final output to browser
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Output
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/libraries/output.html
- */
-class CI_Output {
-
- var $final_output;
- var $cache_expiration = 0;
- var $headers = array();
- var $enable_profiler = FALSE;
-
-
- function CI_Output()
- {
- 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;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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)
- {
- $this->headers[] = $header;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Enable/disable Profiler
- *
- * @access public
- * @param bool
- * @return void
- */
- function enable_profiler($val = TRUE)
- {
- $this->enable_profiler = (is_bool($val)) ? $val : TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Cache
- *
- * @access public
- * @param integer
- * @return void
- */
- function cache($time)
- {
- $this->cache_expiration = ( ! is_numeric($time)) ? 0 : $time;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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;
-
- // --------------------------------------------------------------------
-
- // Set the output data
- if ($output == '')
- {
- $output =& $this->final_output;
- }
-
- // --------------------------------------------------------------------
-
- // Do we need to write a cache file?
- if ($this->cache_expiration > 0)
- {
- $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');
- $output = str_replace('{elapsed_time}', $elapsed, $output);
-
- $memory = ( ! function_exists('memory_get_usage')) ? '0' : round(memory_get_usage()/1024/1024, 2).'MB';
- $output = str_replace('{memory_usage}', $memory, $output);
-
- // --------------------------------------------------------------------
-
- // Is compression requested?
- if ($CFG->item('compress_output') === TRUE)
- {
- 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);
- }
- }
-
- // --------------------------------------------------------------------
-
- // Does the get_instance() function exist?
- // If not we know we are dealing with a cache file so we'll
- // simply echo out the data and exit.
- if ( ! function_exists('get_instance'))
- {
- echo $output;
- log_message('debug', "Final output sent to browser");
- log_message('debug', "Total execution time: ".$elapsed);
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- // Grab the super object. We'll need it in a moment...
- $CI =& get_instance();
-
- // 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 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 == '') ? BASEPATH.'cache/' : $path;
-
- if ( ! is_dir($cache_path) OR ! is_writable($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, 'wb'))
- {
- log_message('error', "Unable to write ache file: ".$cache_path);
- return;
- }
-
- $expire = time() + ($this->cache_expiration * 60);
-
- flock($fp, LOCK_EX);
- fwrite($fp, $expire.'TS--->'.$output);
- flock($fp, LOCK_UN);
- fclose($fp);
- @chmod($cache_path, 0777);
-
- log_message('debug', "Cache file written: ".$cache_path);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Update/serve a cached file
- *
- * @access public
- * @return void
- */
- function _display_cache(&$CFG, &$RTR)
- {
- $CFG =& load_class('Config');
- $RTR =& load_class('Router');
-
- $cache_path = ($CFG->item('cache_path') == '') ? BASEPATH.'cache/' : $CFG->item('cache_path');
-
- if ( ! is_dir($cache_path) OR ! is_writable($cache_path))
- {
- return FALSE;
- }
-
- // Build the file path. The file name is an MD5 hash of the full URI
- $uri = $CFG->item('base_url').
- $CFG->item('index_page').
- $RTR->uri_string;
-
- $filepath = $cache_path.md5($uri);
-
- if ( ! @file_exists($filepath))
- {
- return FALSE;
- }
-
- if ( ! $fp = @fopen($filepath, 'rb'))
- {
- 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'])))
- {
- @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
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Output Class
+ *
+ * Responsible for sending final output to browser
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category Output
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/libraries/output.html
+ */
+class CI_Output {
+
+ var $final_output;
+ var $cache_expiration = 0;
+ var $headers = array();
+ var $enable_profiler = FALSE;
+
+
+ function CI_Output()
+ {
+ 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;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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)
+ {
+ $this->headers[] = $header;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Enable/disable Profiler
+ *
+ * @access public
+ * @param bool
+ * @return void
+ */
+ function enable_profiler($val = TRUE)
+ {
+ $this->enable_profiler = (is_bool($val)) ? $val : TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Cache
+ *
+ * @access public
+ * @param integer
+ * @return void
+ */
+ function cache($time)
+ {
+ $this->cache_expiration = ( ! is_numeric($time)) ? 0 : $time;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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;
+
+ // --------------------------------------------------------------------
+
+ // Set the output data
+ if ($output == '')
+ {
+ $output =& $this->final_output;
+ }
+
+ // --------------------------------------------------------------------
+
+ // Do we need to write a cache file?
+ if ($this->cache_expiration > 0)
+ {
+ $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');
+ $output = str_replace('{elapsed_time}', $elapsed, $output);
+
+ $memory = ( ! function_exists('memory_get_usage')) ? '0' : round(memory_get_usage()/1024/1024, 2).'MB';
+ $output = str_replace('{memory_usage}', $memory, $output);
+
+ // --------------------------------------------------------------------
+
+ // Is compression requested?
+ if ($CFG->item('compress_output') === TRUE)
+ {
+ 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);
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ // Does the get_instance() function exist?
+ // If not we know we are dealing with a cache file so we'll
+ // simply echo out the data and exit.
+ if ( ! function_exists('get_instance'))
+ {
+ echo $output;
+ log_message('debug', "Final output sent to browser");
+ log_message('debug', "Total execution time: ".$elapsed);
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ // Grab the super object. We'll need it in a moment...
+ $CI =& get_instance();
+
+ // 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 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 == '') ? BASEPATH.'cache/' : $path;
+
+ if ( ! is_dir($cache_path) OR ! is_writable($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, 'wb'))
+ {
+ log_message('error', "Unable to write ache file: ".$cache_path);
+ return;
+ }
+
+ $expire = time() + ($this->cache_expiration * 60);
+
+ flock($fp, LOCK_EX);
+ fwrite($fp, $expire.'TS--->'.$output);
+ flock($fp, LOCK_UN);
+ fclose($fp);
+ @chmod($cache_path, 0777);
+
+ log_message('debug', "Cache file written: ".$cache_path);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Update/serve a cached file
+ *
+ * @access public
+ * @return void
+ */
+ function _display_cache(&$CFG, &$RTR)
+ {
+ $CFG =& load_class('Config');
+ $RTR =& load_class('Router');
+
+ $cache_path = ($CFG->item('cache_path') == '') ? BASEPATH.'cache/' : $CFG->item('cache_path');
+
+ if ( ! is_dir($cache_path) OR ! is_writable($cache_path))
+ {
+ return FALSE;
+ }
+
+ // Build the file path. The file name is an MD5 hash of the full URI
+ $uri = $CFG->item('base_url').
+ $CFG->item('index_page').
+ $RTR->uri_string;
+
+ $filepath = $cache_path.md5($uri);
+
+ if ( ! @file_exists($filepath))
+ {
+ return FALSE;
+ }
+
+ if ( ! $fp = @fopen($filepath, 'rb'))
+ {
+ 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'])))
+ {
+ @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
?> \ No newline at end of file
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index 07ad6a683..27104c95c 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -1,211 +1,211 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Pagination Class
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Pagination
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/libraries/pagination.html
- */
-class CI_Pagination {
-
- var $base_url = ''; // The page we are linking to
- var $total_rows = ''; // Total number of items (database results)
- var $per_page = 10; // Max number of items you want shown per page
- var $num_links = 2; // Number of "digit" links to show before/after the currently viewed page
- var $cur_page = 0; // The current page being viewed
- var $first_link = '&lsaquo; First';
- var $next_link = '&gt;';
- var $prev_link = '&lt;';
- var $last_link = 'Last &rsaquo;';
- var $uri_segment = 3;
- var $full_tag_open = '';
- var $full_tag_close = '';
- var $first_tag_open = '';
- var $first_tag_close = '&nbsp;';
- var $last_tag_open = '&nbsp;';
- var $last_tag_close = '';
- var $cur_tag_open = '&nbsp;<b>';
- var $cur_tag_close = '</b>';
- var $next_tag_open = '&nbsp;';
- var $next_tag_close = '&nbsp;';
- var $prev_tag_open = '&nbsp;';
- var $prev_tag_close = '';
- var $num_tag_open = '&nbsp;';
- var $num_tag_close = '';
-
- /**
- * Constructor
- *
- * @access public
- * @param array initialization parameters
- */
- function CI_Pagination($params = array())
- {
- if (count($params) > 0)
- {
- $this->initialize($params);
- }
-
- log_message('debug', "Pagination Class Initialized");
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Initialize Preferences
- *
- * @access public
- * @param array initialization parameters
- * @return void
- */
- function initialize($params = array())
- {
- if (count($params) > 0)
- {
- foreach ($params as $key => $val)
- {
- if (isset($this->$key))
- {
- $this->$key = $val;
- }
- }
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Generate the pagination links
- *
- * @access public
- * @return string
- */
- function create_links()
- {
- // If our item count or per-page total is zero there is no need to continue.
- if ($this->total_rows == 0 OR $this->per_page == 0)
- {
- return '';
- }
-
- // Calculate the total number of pages
- $num_pages = ceil($this->total_rows / $this->per_page);
-
- // Is there only one page? Hm... nothing more to do here then.
- if ($num_pages == 1)
- {
- return '';
- }
-
- // Determine the current page number.
- $CI =& get_instance();
- if ($CI->uri->segment($this->uri_segment) != 0)
- {
- $this->cur_page = $CI->uri->segment($this->uri_segment);
-
- // Prep the current page - no funny business!
- $this->cur_page = preg_replace("/[a-z\-]/", "", $this->cur_page);
- }
-
- if ( ! is_numeric($this->cur_page))
- {
- $this->cur_page = 0;
- }
-
- // Is the page number beyond the result range?
- // If so we show the last page
- if ($this->cur_page > $this->total_rows)
- {
- $this->cur_page = ($num_pages - 1) * $this->per_page;
- }
-
- $uri_page_number = $this->cur_page;
- $this->cur_page = floor(($this->cur_page/$this->per_page) + 1);
-
- // Calculate the start and end numbers. These determine
- // which number to start and end the digit links with
- $start = (($this->cur_page - $this->num_links) > 0) ? $this->cur_page - ($this->num_links - 1) : 1;
- $end = (($this->cur_page + $this->num_links) < $num_pages) ? $this->cur_page + $this->num_links : $num_pages;
-
- // Add a trailing slash to the base URL if needed
- $this->base_url = preg_replace("/(.+?)\/*$/", "\\1/", $this->base_url);
-
- // And here we go...
- $output = '';
-
- // Render the "First" link
- if ($this->cur_page > $this->num_links)
- {
- $output .= $this->first_tag_open.'<a href="'.$this->base_url.'">'.$this->first_link.'</a>'.$this->first_tag_close;
- }
-
- // Render the "previous" link
- if (($this->cur_page - $this->num_links) >= 0)
- {
- $i = $uri_page_number - $this->per_page;
- if ($i == 0) $i = '';
- $output .= $this->prev_tag_open.'<a href="'.$this->base_url.$i.'">'.$this->prev_link.'</a>'.$this->prev_tag_close;
- }
-
- // Write the digit links
- for ($loop = $start -1; $loop <= $end; $loop++)
- {
- $i = ($loop * $this->per_page) - $this->per_page;
-
- if ($i >= 0)
- {
- if ($this->cur_page == $loop)
- {
- $output .= $this->cur_tag_open.$loop.$this->cur_tag_close; // Current page
- }
- else
- {
- $n = ($i == 0) ? '' : $i;
- $output .= $this->num_tag_open.'<a href="'.$this->base_url.$n.'">'.$loop.'</a>'.$this->num_tag_close;
- }
- }
- }
-
- // Render the "next" link
- if ($this->cur_page < $num_pages)
- {
- $output .= $this->next_tag_open.'<a href="'.$this->base_url.($this->cur_page * $this->per_page).'">'.$this->next_link.'</a>'.$this->next_tag_close;
- }
-
- // Render the "Last" link
- if (($this->cur_page + $this->num_links) < $num_pages)
- {
- $i = (($num_pages * $this->per_page) - $this->per_page);
- $output .= $this->last_tag_open.'<a href="'.$this->base_url.$i.'">'.$this->last_link.'</a>'.$this->last_tag_close;
- }
-
- // Kill double slashes. Note: Sometimes we can end up with a double slash
- // in the penultimate link so we'll kill all double slashes.
- $output = preg_replace("#([^:])//+#", "\\1/", $output);
-
- // Add the wrapper HTML if exists
- $output = $this->full_tag_open.$output.$this->full_tag_close;
-
- return $output;
- }
-}
-// END Pagination Class
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Pagination Class
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category Pagination
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/libraries/pagination.html
+ */
+class CI_Pagination {
+
+ var $base_url = ''; // The page we are linking to
+ var $total_rows = ''; // Total number of items (database results)
+ var $per_page = 10; // Max number of items you want shown per page
+ var $num_links = 2; // Number of "digit" links to show before/after the currently viewed page
+ var $cur_page = 0; // The current page being viewed
+ var $first_link = '&lsaquo; First';
+ var $next_link = '&gt;';
+ var $prev_link = '&lt;';
+ var $last_link = 'Last &rsaquo;';
+ var $uri_segment = 3;
+ var $full_tag_open = '';
+ var $full_tag_close = '';
+ var $first_tag_open = '';
+ var $first_tag_close = '&nbsp;';
+ var $last_tag_open = '&nbsp;';
+ var $last_tag_close = '';
+ var $cur_tag_open = '&nbsp;<b>';
+ var $cur_tag_close = '</b>';
+ var $next_tag_open = '&nbsp;';
+ var $next_tag_close = '&nbsp;';
+ var $prev_tag_open = '&nbsp;';
+ var $prev_tag_close = '';
+ var $num_tag_open = '&nbsp;';
+ var $num_tag_close = '';
+
+ /**
+ * Constructor
+ *
+ * @access public
+ * @param array initialization parameters
+ */
+ function CI_Pagination($params = array())
+ {
+ if (count($params) > 0)
+ {
+ $this->initialize($params);
+ }
+
+ log_message('debug', "Pagination Class Initialized");
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Initialize Preferences
+ *
+ * @access public
+ * @param array initialization parameters
+ * @return void
+ */
+ function initialize($params = array())
+ {
+ if (count($params) > 0)
+ {
+ foreach ($params as $key => $val)
+ {
+ if (isset($this->$key))
+ {
+ $this->$key = $val;
+ }
+ }
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Generate the pagination links
+ *
+ * @access public
+ * @return string
+ */
+ function create_links()
+ {
+ // If our item count or per-page total is zero there is no need to continue.
+ if ($this->total_rows == 0 OR $this->per_page == 0)
+ {
+ return '';
+ }
+
+ // Calculate the total number of pages
+ $num_pages = ceil($this->total_rows / $this->per_page);
+
+ // Is there only one page? Hm... nothing more to do here then.
+ if ($num_pages == 1)
+ {
+ return '';
+ }
+
+ // Determine the current page number.
+ $CI =& get_instance();
+ if ($CI->uri->segment($this->uri_segment) != 0)
+ {
+ $this->cur_page = $CI->uri->segment($this->uri_segment);
+
+ // Prep the current page - no funny business!
+ $this->cur_page = preg_replace("/[a-z\-]/", "", $this->cur_page);
+ }
+
+ if ( ! is_numeric($this->cur_page))
+ {
+ $this->cur_page = 0;
+ }
+
+ // Is the page number beyond the result range?
+ // If so we show the last page
+ if ($this->cur_page > $this->total_rows)
+ {
+ $this->cur_page = ($num_pages - 1) * $this->per_page;
+ }
+
+ $uri_page_number = $this->cur_page;
+ $this->cur_page = floor(($this->cur_page/$this->per_page) + 1);
+
+ // Calculate the start and end numbers. These determine
+ // which number to start and end the digit links with
+ $start = (($this->cur_page - $this->num_links) > 0) ? $this->cur_page - ($this->num_links - 1) : 1;
+ $end = (($this->cur_page + $this->num_links) < $num_pages) ? $this->cur_page + $this->num_links : $num_pages;
+
+ // Add a trailing slash to the base URL if needed
+ $this->base_url = preg_replace("/(.+?)\/*$/", "\\1/", $this->base_url);
+
+ // And here we go...
+ $output = '';
+
+ // Render the "First" link
+ if ($this->cur_page > $this->num_links)
+ {
+ $output .= $this->first_tag_open.'<a href="'.$this->base_url.'">'.$this->first_link.'</a>'.$this->first_tag_close;
+ }
+
+ // Render the "previous" link
+ if (($this->cur_page - $this->num_links) >= 0)
+ {
+ $i = $uri_page_number - $this->per_page;
+ if ($i == 0) $i = '';
+ $output .= $this->prev_tag_open.'<a href="'.$this->base_url.$i.'">'.$this->prev_link.'</a>'.$this->prev_tag_close;
+ }
+
+ // Write the digit links
+ for ($loop = $start -1; $loop <= $end; $loop++)
+ {
+ $i = ($loop * $this->per_page) - $this->per_page;
+
+ if ($i >= 0)
+ {
+ if ($this->cur_page == $loop)
+ {
+ $output .= $this->cur_tag_open.$loop.$this->cur_tag_close; // Current page
+ }
+ else
+ {
+ $n = ($i == 0) ? '' : $i;
+ $output .= $this->num_tag_open.'<a href="'.$this->base_url.$n.'">'.$loop.'</a>'.$this->num_tag_close;
+ }
+ }
+ }
+
+ // Render the "next" link
+ if ($this->cur_page < $num_pages)
+ {
+ $output .= $this->next_tag_open.'<a href="'.$this->base_url.($this->cur_page * $this->per_page).'">'.$this->next_link.'</a>'.$this->next_tag_close;
+ }
+
+ // Render the "Last" link
+ if (($this->cur_page + $this->num_links) < $num_pages)
+ {
+ $i = (($num_pages * $this->per_page) - $this->per_page);
+ $output .= $this->last_tag_open.'<a href="'.$this->base_url.$i.'">'.$this->last_link.'</a>'.$this->last_tag_close;
+ }
+
+ // Kill double slashes. Note: Sometimes we can end up with a double slash
+ // in the penultimate link so we'll kill all double slashes.
+ $output = preg_replace("#([^:])//+#", "\\1/", $output);
+
+ // Add the wrapper HTML if exists
+ $output = $this->full_tag_open.$output.$this->full_tag_close;
+
+ return $output;
+ }
+}
+// END Pagination Class
?> \ No newline at end of file
diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php
index 760d5d4d3..613668ac8 100644
--- a/system/libraries/Parser.php
+++ b/system/libraries/Parser.php
@@ -1,171 +1,171 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Parser Class
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Parser
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/libraries/parser.html
- */
-class CI_Parser {
-
- var $l_delim = '{';
- var $r_delim = '}';
- var $object;
-
- /**
- * Parse a template
- *
- * Parses pseudo-variables contained in the specified template,
- * replacing them with the data in the second param
- *
- * @access public
- * @param string
- * @param array
- * @param bool
- * @return string
- */
- function parse($template, $data, $return = FALSE)
- {
- $CI =& get_instance();
- $template = $CI->load->view($template, $data, TRUE);
-
- if ($template == '')
- {
- return FALSE;
- }
-
- foreach ($data as $key => $val)
- {
- if (is_string($val))
- {
- $template = $this->_parse_single($key, $val, $template);
- }
- elseif (is_array($val))
- {
- $template = $this->_parse_pair($key, $val, $template);
- }
- }
-
- if ($return == FALSE)
- {
- $CI->output->final_output = $template;
- }
-
- return $template;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set the left/right variable delimiters
- *
- * @access public
- * @param string
- * @param string
- * @return void
- */
- function set_delimiters($l = '{', $r = '}')
- {
- $this->l_delim = $l;
- $this->r_delim = $r;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Parse a single key/value
- *
- * @access private
- * @param string
- * @param string
- * @param string
- * @return string
- */
- function _parse_single($key, $val, $string)
- {
- return str_replace($this->l_delim.$key.$this->r_delim, $val, $string);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Parse a tag pair
- *
- * Parses tag pairs: {some_tag} string... {/some_tag}
- *
- * @access private
- * @param string
- * @param array
- * @param string
- * @return string
- */
- function _parse_pair($variable, $data, $string)
- {
- if (FALSE === ($match = $this->_match_pair($string, $variable)))
- {
- return $string;
- }
-
- $str = '';
- foreach ($data as $row)
- {
- $temp = $match['1'];
- foreach ($row as $key => $val)
- {
- if ( ! is_array($val))
- {
- $temp = $this->_parse_single($key, $val, $temp);
- }
- else
- {
- $temp = $this->_parse_pair($key, $val, $temp);
- }
- }
-
- $str .= $temp;
- }
-
- return str_replace($match['0'], $str, $string);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Matches a variable pair
- *
- * @access private
- * @param string
- * @param string
- * @return mixed
- */
- function _match_pair($string, $variable)
- {
- if ( ! preg_match("|".$this->l_delim . $variable . $this->r_delim."(.+)".$this->l_delim . '/' . $variable . $this->r_delim."|s", $string, $match))
- {
- return FALSE;
- }
-
- return $match;
- }
-
-}
-// END Parser Class
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Parser Class
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category Parser
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/libraries/parser.html
+ */
+class CI_Parser {
+
+ var $l_delim = '{';
+ var $r_delim = '}';
+ var $object;
+
+ /**
+ * Parse a template
+ *
+ * Parses pseudo-variables contained in the specified template,
+ * replacing them with the data in the second param
+ *
+ * @access public
+ * @param string
+ * @param array
+ * @param bool
+ * @return string
+ */
+ function parse($template, $data, $return = FALSE)
+ {
+ $CI =& get_instance();
+ $template = $CI->load->view($template, $data, TRUE);
+
+ if ($template == '')
+ {
+ return FALSE;
+ }
+
+ foreach ($data as $key => $val)
+ {
+ if (is_string($val))
+ {
+ $template = $this->_parse_single($key, $val, $template);
+ }
+ elseif (is_array($val))
+ {
+ $template = $this->_parse_pair($key, $val, $template);
+ }
+ }
+
+ if ($return == FALSE)
+ {
+ $CI->output->final_output = $template;
+ }
+
+ return $template;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set the left/right variable delimiters
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return void
+ */
+ function set_delimiters($l = '{', $r = '}')
+ {
+ $this->l_delim = $l;
+ $this->r_delim = $r;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Parse a single key/value
+ *
+ * @access private
+ * @param string
+ * @param string
+ * @param string
+ * @return string
+ */
+ function _parse_single($key, $val, $string)
+ {
+ return str_replace($this->l_delim.$key.$this->r_delim, $val, $string);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Parse a tag pair
+ *
+ * Parses tag pairs: {some_tag} string... {/some_tag}
+ *
+ * @access private
+ * @param string
+ * @param array
+ * @param string
+ * @return string
+ */
+ function _parse_pair($variable, $data, $string)
+ {
+ if (FALSE === ($match = $this->_match_pair($string, $variable)))
+ {
+ return $string;
+ }
+
+ $str = '';
+ foreach ($data as $row)
+ {
+ $temp = $match['1'];
+ foreach ($row as $key => $val)
+ {
+ if ( ! is_array($val))
+ {
+ $temp = $this->_parse_single($key, $val, $temp);
+ }
+ else
+ {
+ $temp = $this->_parse_pair($key, $val, $temp);
+ }
+ }
+
+ $str .= $temp;
+ }
+
+ return str_replace($match['0'], $str, $string);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Matches a variable pair
+ *
+ * @access private
+ * @param string
+ * @param string
+ * @return mixed
+ */
+ function _match_pair($string, $variable)
+ {
+ if ( ! preg_match("|".$this->l_delim . $variable . $this->r_delim."(.+)".$this->l_delim . '/' . $variable . $this->r_delim."|s", $string, $match))
+ {
+ return FALSE;
+ }
+
+ return $match;
+ }
+
+}
+// END Parser Class
?> \ No newline at end of file
diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php
index 37b345184..cdc4f6fc9 100644
--- a/system/libraries/Profiler.php
+++ b/system/libraries/Profiler.php
@@ -1,12 +1,12 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
- * Code Igniter
+ * CodeIgniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
* @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
* @license http://www.codeignitor.com/user_guide/license.html
* @link http://www.codeigniter.com
* @since Version 1.0
@@ -16,7 +16,7 @@
// ------------------------------------------------------------------------
/**
- * Code Igniter Profiler Class
+ * CodeIgniter Profiler Class
*
* This class enables you to display benchmark, query, and other data
* in order to help with debugging and optimization.
diff --git a/system/libraries/Router.php b/system/libraries/Router.php
index 8dfc82580..64becf535 100644
--- a/system/libraries/Router.php
+++ b/system/libraries/Router.php
@@ -1,12 +1,12 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
- * Code Igniter
+ * CodeIgniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
* @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
* @license http://www.codeignitor.com/user_guide/license.html
* @link http://www.codeigniter.com
* @since Version 1.0
diff --git a/system/libraries/Session.php b/system/libraries/Session.php
index 89662fe52..8045017ab 100644
--- a/system/libraries/Session.php
+++ b/system/libraries/Session.php
@@ -1,488 +1,488 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Session Class
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Sessions
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/libraries/sessions.html
- */
-class CI_Session {
-
- var $CI;
- var $now;
- var $encryption = TRUE;
- var $use_database = FALSE;
- var $session_table = FALSE;
- var $sess_length = 7200;
- var $sess_cookie = 'ci_session';
- var $userdata = array();
- var $gc_probability = 5;
-
-
- /**
- * Session Constructor
- *
- * The constructor runs the session routines automatically
- * whenever the class is instantiated.
- */
- function CI_Session()
- {
- $this->CI =& get_instance();
-
- log_message('debug', "Session Class Initialized");
- $this->sess_run();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Run the session routines
- *
- * @access public
- * @return void
- */
- function sess_run()
- {
- /*
- * Set the "now" time
- *
- * It can either set to GMT or time(). The pref
- * is set in the config file. If the developer
- * is doing any sort of time localization they
- * might want to set the session time to GMT so
- * they can offset the "last_activity" and
- * "last_visit" times based on each user's locale.
- *
- */
- if (strtolower($this->CI->config->item('time_reference')) == 'gmt')
- {
- $now = time();
- $this->now = mktime(gmdate("H", $now), gmdate("i", $now), gmdate("s", $now), gmdate("m", $now), gmdate("d", $now), gmdate("Y", $now));
-
- if (strlen($this->now) < 10)
- {
- $this->now = time();
- log_message('error', 'The session class could not set a proper GMT timestamp so the local time() value was used.');
- }
- }
- else
- {
- $this->now = time();
- }
-
- /*
- * Set the session length
- *
- * If the session expiration is set to zero in
- * the config file we'll set the expiration
- * two years from now.
- *
- */
- $expiration = $this->CI->config->item('sess_expiration');
-
- if (is_numeric($expiration))
- {
- if ($expiration > 0)
- {
- $this->sess_length = $this->CI->config->item('sess_expiration');
- }
- else
- {
- $this->sess_length = (60*60*24*365*2);
- }
- }
-
- // Do we need encryption?
- $this->encryption = $this->CI->config->item('sess_encrypt_cookie');
-
- if ($this->encryption == TRUE)
- {
- $this->CI->load->library('encrypt');
- }
-
- // Are we using a database?
- if ($this->CI->config->item('sess_use_database') === TRUE AND $this->CI->config->item('sess_table_name') != '')
- {
- $this->use_database = TRUE;
- $this->session_table = $this->CI->config->item('sess_table_name');
- $this->CI->load->database();
- }
-
- // Set the cookie name
- if ($this->CI->config->item('sess_cookie_name') != FALSE)
- {
- $this->sess_cookie = $this->CI->config->item('cookie_prefix').$this->CI->config->item('sess_cookie_name');
- }
-
- /*
- * Fetch the current session
- *
- * If a session doesn't exist we'll create
- * a new one. If it does, we'll update it.
- *
- */
- if ( ! $this->sess_read())
- {
- $this->sess_create();
- }
- else
- {
- // We only update the session every five minutes
- if (($this->userdata['last_activity'] + 300) < $this->now)
- {
- $this->sess_update();
- }
- }
-
- // Delete expired sessions if necessary
- if ($this->use_database === TRUE)
- {
- $this->sess_gc();
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Fetch the current session data if it exists
- *
- * @access public
- * @return void
- */
- function sess_read()
- {
- // Fetch the cookie
- $session = $this->CI->input->cookie($this->sess_cookie);
-
- if ($session === FALSE)
- {
- log_message('debug', 'A session cookie was not found.');
- return FALSE;
- }
-
- // Decrypt and unserialize the data
- if ($this->encryption == TRUE)
- {
- $session = $this->CI->encrypt->decode($session);
- }
-
- $session = @unserialize($this->strip_slashes($session));
-
- if ( ! is_array($session) OR ! isset($session['last_activity']))
- {
- log_message('error', 'The session cookie data did not contain a valid array. This could be a possible hacking attempt.');
- return FALSE;
- }
-
- // Is the session current?
- if (($session['last_activity'] + $this->sess_length) < $this->now)
- {
- $this->sess_destroy();
- return FALSE;
- }
-
- // Does the IP Match?
- if ($this->CI->config->item('sess_match_ip') == TRUE AND $session['ip_address'] != $this->CI->input->ip_address())
- {
- $this->sess_destroy();
- return FALSE;
- }
-
- // Does the User Agent Match?
- if ($this->CI->config->item('sess_match_useragent') == TRUE AND $session['user_agent'] != substr($this->CI->input->user_agent(), 0, 50))
- {
- $this->sess_destroy();
- return FALSE;
- }
-
- // Is there a corresponding session in the DB?
- if ($this->use_database === TRUE)
- {
- $this->CI->db->where('session_id', $session['session_id']);
-
- if ($this->CI->config->item('sess_match_ip') == TRUE)
- {
- $this->CI->db->where('ip_address', $session['ip_address']);
- }
-
- if ($this->CI->config->item('sess_match_useragent') == TRUE)
- {
- $this->CI->db->where('user_agent', $session['user_agent']);
- }
-
- $query = $this->CI->db->get($this->session_table);
-
- if ($query->num_rows() == 0)
- {
- $this->sess_destroy();
- return FALSE;
- }
- else
- {
- $row = $query->row();
- if (($row->last_activity + $this->sess_length) < $this->now)
- {
- $this->CI->db->where('session_id', $session['session_id']);
- $this->CI->db->delete($this->session_table);
- $this->sess_destroy();
- return FALSE;
- }
- }
- }
-
- // Session is valid!
- $this->userdata = $session;
- unset($session);
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Write the session cookie
- *
- * @access public
- * @return void
- */
- function sess_write()
- {
- $cookie_data = serialize($this->userdata);
-
- if ($this->encryption == TRUE)
- {
- $cookie_data = $this->CI->encrypt->encode($cookie_data);
- }
-
- setcookie(
- $this->sess_cookie,
- $cookie_data,
- $this->sess_length + time(),
- $this->CI->config->item('cookie_path'),
- $this->CI->config->item('cookie_domain'),
- 0
- );
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Create a new session
- *
- * @access public
- * @return void
- */
- function sess_create()
- {
- $sessid = '';
- while (strlen($sessid) < 32)
- {
- $sessid .= mt_rand(0, mt_getrandmax());
- }
-
- $this->userdata = array(
- 'session_id' => md5(uniqid($sessid, TRUE)),
- 'ip_address' => $this->CI->input->ip_address(),
- 'user_agent' => substr($this->CI->input->user_agent(), 0, 50),
- 'last_activity' => $this->now
- );
-
-
- // Save the session in the DB if needed
- if ($this->use_database === TRUE)
- {
- $this->CI->db->query($this->CI->db->insert_string($this->session_table, $this->userdata));
- }
-
- // Write the cookie
- $this->userdata['last_visit'] = 0;
- $this->sess_write();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Update an existing session
- *
- * @access public
- * @return void
- */
- function sess_update()
- {
- if (($this->userdata['last_activity'] + $this->sess_length) < $this->now)
- {
- $this->userdata['last_visit'] = $this->userdata['last_activity'];
- }
-
- $this->userdata['last_activity'] = $this->now;
-
- // Update the session in the DB if needed
- if ($this->use_database === TRUE)
- {
- $this->CI->db->query($this->CI->db->update_string($this->session_table, array('last_activity' => $this->now), array('session_id' => $this->userdata['session_id'])));
- }
-
- // Write the cookie
- $this->sess_write();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Destroy the current session
- *
- * @access public
- * @return void
- */
- function sess_destroy()
- {
- setcookie(
- $this->sess_cookie,
- addslashes(serialize(array())),
- ($this->now - 31500000),
- $this->CI->config->item('cookie_path'),
- $this->CI->config->item('cookie_domain'),
- 0
- );
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Garbage collection
- *
- * This deletes expired session rows from database
- * if the probability percentage is met
- *
- * @access public
- * @return void
- */
- function sess_gc()
- {
- srand(time());
- if ((rand() % 100) < $this->gc_probability)
- {
- $expire = $this->now - $this->sess_length;
-
- $this->CI->db->where("last_activity < {$expire}");
- $this->CI->db->delete($this->session_table);
-
- log_message('debug', 'Session garbage collection performed.');
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Fetch a specific item form the session array
- *
- * @access public
- * @param string
- * @return string
- */
- function userdata($item)
- {
- return ( ! isset($this->userdata[$item])) ? FALSE : $this->userdata[$item];
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Add or change data in the "userdata" array
- *
- * @access public
- * @param mixed
- * @param string
- * @return void
- */
- function set_userdata($newdata = array(), $newval = '')
- {
- if (is_string($newdata))
- {
- $newdata = array($newdata => $newval);
- }
-
- if (count($newdata) > 0)
- {
- foreach ($newdata as $key => $val)
- {
- $this->userdata[$key] = $val;
- }
- }
-
- $this->sess_write();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Delete a session variable from the "userdata" array
- *
- * @access array
- * @return void
- */
- function unset_userdata($newdata = array())
- {
- if (is_string($newdata))
- {
- $newdata = array($newdata => '');
- }
-
- if (count($newdata) > 0)
- {
- foreach ($newdata as $key => $val)
- {
- unset($this->userdata[$key]);
- }
- }
-
- $this->sess_write();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Strip slashes
- *
- * @access public
- * @param mixed
- * @return mixed
- */
- function strip_slashes($vals)
- {
- if (is_array($vals))
- {
- foreach ($vals as $key=>$val)
- {
- $vals[$key] = $this->strip_slashes($val);
- }
- }
- else
- {
- $vals = stripslashes($vals);
- }
-
- return $vals;
- }
-
-}
-// END Session Class
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Session Class
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category Sessions
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/libraries/sessions.html
+ */
+class CI_Session {
+
+ var $CI;
+ var $now;
+ var $encryption = TRUE;
+ var $use_database = FALSE;
+ var $session_table = FALSE;
+ var $sess_length = 7200;
+ var $sess_cookie = 'ci_session';
+ var $userdata = array();
+ var $gc_probability = 5;
+
+
+ /**
+ * Session Constructor
+ *
+ * The constructor runs the session routines automatically
+ * whenever the class is instantiated.
+ */
+ function CI_Session()
+ {
+ $this->CI =& get_instance();
+
+ log_message('debug', "Session Class Initialized");
+ $this->sess_run();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Run the session routines
+ *
+ * @access public
+ * @return void
+ */
+ function sess_run()
+ {
+ /*
+ * Set the "now" time
+ *
+ * It can either set to GMT or time(). The pref
+ * is set in the config file. If the developer
+ * is doing any sort of time localization they
+ * might want to set the session time to GMT so
+ * they can offset the "last_activity" and
+ * "last_visit" times based on each user's locale.
+ *
+ */
+ if (strtolower($this->CI->config->item('time_reference')) == 'gmt')
+ {
+ $now = time();
+ $this->now = mktime(gmdate("H", $now), gmdate("i", $now), gmdate("s", $now), gmdate("m", $now), gmdate("d", $now), gmdate("Y", $now));
+
+ if (strlen($this->now) < 10)
+ {
+ $this->now = time();
+ log_message('error', 'The session class could not set a proper GMT timestamp so the local time() value was used.');
+ }
+ }
+ else
+ {
+ $this->now = time();
+ }
+
+ /*
+ * Set the session length
+ *
+ * If the session expiration is set to zero in
+ * the config file we'll set the expiration
+ * two years from now.
+ *
+ */
+ $expiration = $this->CI->config->item('sess_expiration');
+
+ if (is_numeric($expiration))
+ {
+ if ($expiration > 0)
+ {
+ $this->sess_length = $this->CI->config->item('sess_expiration');
+ }
+ else
+ {
+ $this->sess_length = (60*60*24*365*2);
+ }
+ }
+
+ // Do we need encryption?
+ $this->encryption = $this->CI->config->item('sess_encrypt_cookie');
+
+ if ($this->encryption == TRUE)
+ {
+ $this->CI->load->library('encrypt');
+ }
+
+ // Are we using a database?
+ if ($this->CI->config->item('sess_use_database') === TRUE AND $this->CI->config->item('sess_table_name') != '')
+ {
+ $this->use_database = TRUE;
+ $this->session_table = $this->CI->config->item('sess_table_name');
+ $this->CI->load->database();
+ }
+
+ // Set the cookie name
+ if ($this->CI->config->item('sess_cookie_name') != FALSE)
+ {
+ $this->sess_cookie = $this->CI->config->item('cookie_prefix').$this->CI->config->item('sess_cookie_name');
+ }
+
+ /*
+ * Fetch the current session
+ *
+ * If a session doesn't exist we'll create
+ * a new one. If it does, we'll update it.
+ *
+ */
+ if ( ! $this->sess_read())
+ {
+ $this->sess_create();
+ }
+ else
+ {
+ // We only update the session every five minutes
+ if (($this->userdata['last_activity'] + 300) < $this->now)
+ {
+ $this->sess_update();
+ }
+ }
+
+ // Delete expired sessions if necessary
+ if ($this->use_database === TRUE)
+ {
+ $this->sess_gc();
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch the current session data if it exists
+ *
+ * @access public
+ * @return void
+ */
+ function sess_read()
+ {
+ // Fetch the cookie
+ $session = $this->CI->input->cookie($this->sess_cookie);
+
+ if ($session === FALSE)
+ {
+ log_message('debug', 'A session cookie was not found.');
+ return FALSE;
+ }
+
+ // Decrypt and unserialize the data
+ if ($this->encryption == TRUE)
+ {
+ $session = $this->CI->encrypt->decode($session);
+ }
+
+ $session = @unserialize($this->strip_slashes($session));
+
+ if ( ! is_array($session) OR ! isset($session['last_activity']))
+ {
+ log_message('error', 'The session cookie data did not contain a valid array. This could be a possible hacking attempt.');
+ return FALSE;
+ }
+
+ // Is the session current?
+ if (($session['last_activity'] + $this->sess_length) < $this->now)
+ {
+ $this->sess_destroy();
+ return FALSE;
+ }
+
+ // Does the IP Match?
+ if ($this->CI->config->item('sess_match_ip') == TRUE AND $session['ip_address'] != $this->CI->input->ip_address())
+ {
+ $this->sess_destroy();
+ return FALSE;
+ }
+
+ // Does the User Agent Match?
+ if ($this->CI->config->item('sess_match_useragent') == TRUE AND $session['user_agent'] != substr($this->CI->input->user_agent(), 0, 50))
+ {
+ $this->sess_destroy();
+ return FALSE;
+ }
+
+ // Is there a corresponding session in the DB?
+ if ($this->use_database === TRUE)
+ {
+ $this->CI->db->where('session_id', $session['session_id']);
+
+ if ($this->CI->config->item('sess_match_ip') == TRUE)
+ {
+ $this->CI->db->where('ip_address', $session['ip_address']);
+ }
+
+ if ($this->CI->config->item('sess_match_useragent') == TRUE)
+ {
+ $this->CI->db->where('user_agent', $session['user_agent']);
+ }
+
+ $query = $this->CI->db->get($this->session_table);
+
+ if ($query->num_rows() == 0)
+ {
+ $this->sess_destroy();
+ return FALSE;
+ }
+ else
+ {
+ $row = $query->row();
+ if (($row->last_activity + $this->sess_length) < $this->now)
+ {
+ $this->CI->db->where('session_id', $session['session_id']);
+ $this->CI->db->delete($this->session_table);
+ $this->sess_destroy();
+ return FALSE;
+ }
+ }
+ }
+
+ // Session is valid!
+ $this->userdata = $session;
+ unset($session);
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Write the session cookie
+ *
+ * @access public
+ * @return void
+ */
+ function sess_write()
+ {
+ $cookie_data = serialize($this->userdata);
+
+ if ($this->encryption == TRUE)
+ {
+ $cookie_data = $this->CI->encrypt->encode($cookie_data);
+ }
+
+ setcookie(
+ $this->sess_cookie,
+ $cookie_data,
+ $this->sess_length + time(),
+ $this->CI->config->item('cookie_path'),
+ $this->CI->config->item('cookie_domain'),
+ 0
+ );
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Create a new session
+ *
+ * @access public
+ * @return void
+ */
+ function sess_create()
+ {
+ $sessid = '';
+ while (strlen($sessid) < 32)
+ {
+ $sessid .= mt_rand(0, mt_getrandmax());
+ }
+
+ $this->userdata = array(
+ 'session_id' => md5(uniqid($sessid, TRUE)),
+ 'ip_address' => $this->CI->input->ip_address(),
+ 'user_agent' => substr($this->CI->input->user_agent(), 0, 50),
+ 'last_activity' => $this->now
+ );
+
+
+ // Save the session in the DB if needed
+ if ($this->use_database === TRUE)
+ {
+ $this->CI->db->query($this->CI->db->insert_string($this->session_table, $this->userdata));
+ }
+
+ // Write the cookie
+ $this->userdata['last_visit'] = 0;
+ $this->sess_write();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Update an existing session
+ *
+ * @access public
+ * @return void
+ */
+ function sess_update()
+ {
+ if (($this->userdata['last_activity'] + $this->sess_length) < $this->now)
+ {
+ $this->userdata['last_visit'] = $this->userdata['last_activity'];
+ }
+
+ $this->userdata['last_activity'] = $this->now;
+
+ // Update the session in the DB if needed
+ if ($this->use_database === TRUE)
+ {
+ $this->CI->db->query($this->CI->db->update_string($this->session_table, array('last_activity' => $this->now), array('session_id' => $this->userdata['session_id'])));
+ }
+
+ // Write the cookie
+ $this->sess_write();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Destroy the current session
+ *
+ * @access public
+ * @return void
+ */
+ function sess_destroy()
+ {
+ setcookie(
+ $this->sess_cookie,
+ addslashes(serialize(array())),
+ ($this->now - 31500000),
+ $this->CI->config->item('cookie_path'),
+ $this->CI->config->item('cookie_domain'),
+ 0
+ );
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Garbage collection
+ *
+ * This deletes expired session rows from database
+ * if the probability percentage is met
+ *
+ * @access public
+ * @return void
+ */
+ function sess_gc()
+ {
+ srand(time());
+ if ((rand() % 100) < $this->gc_probability)
+ {
+ $expire = $this->now - $this->sess_length;
+
+ $this->CI->db->where("last_activity < {$expire}");
+ $this->CI->db->delete($this->session_table);
+
+ log_message('debug', 'Session garbage collection performed.');
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch a specific item form the session array
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function userdata($item)
+ {
+ return ( ! isset($this->userdata[$item])) ? FALSE : $this->userdata[$item];
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Add or change data in the "userdata" array
+ *
+ * @access public
+ * @param mixed
+ * @param string
+ * @return void
+ */
+ function set_userdata($newdata = array(), $newval = '')
+ {
+ if (is_string($newdata))
+ {
+ $newdata = array($newdata => $newval);
+ }
+
+ if (count($newdata) > 0)
+ {
+ foreach ($newdata as $key => $val)
+ {
+ $this->userdata[$key] = $val;
+ }
+ }
+
+ $this->sess_write();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Delete a session variable from the "userdata" array
+ *
+ * @access array
+ * @return void
+ */
+ function unset_userdata($newdata = array())
+ {
+ if (is_string($newdata))
+ {
+ $newdata = array($newdata => '');
+ }
+
+ if (count($newdata) > 0)
+ {
+ foreach ($newdata as $key => $val)
+ {
+ unset($this->userdata[$key]);
+ }
+ }
+
+ $this->sess_write();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Strip slashes
+ *
+ * @access public
+ * @param mixed
+ * @return mixed
+ */
+ function strip_slashes($vals)
+ {
+ if (is_array($vals))
+ {
+ foreach ($vals as $key=>$val)
+ {
+ $vals[$key] = $this->strip_slashes($val);
+ }
+ }
+ else
+ {
+ $vals = stripslashes($vals);
+ }
+
+ return $vals;
+ }
+
+}
+// END Session Class
?> \ No newline at end of file
diff --git a/system/libraries/Sha1.php b/system/libraries/Sha1.php
index 4dde04038..451428deb 100644
--- a/system/libraries/Sha1.php
+++ b/system/libraries/Sha1.php
@@ -1,249 +1,249 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * SHA1 Encoding Class
- *
- * Purpose: Provides 160 bit hashing using The Secure Hash Algorithm
- * developed at the National Institute of Standards and Technology. The 40
- * character SHA1 message hash is computationally infeasible to crack.
- *
- * This class is a fallback for servers that are not running PHP greater than
- * 4.3, or do not have the MHASH library.
- *
- * This class is based on two scripts:
- *
- * Marcus Campbell's PHP implementation (GNU license)
- * http://www.tecknik.net/sha-1/
- *
- * ...which is based on Paul Johnston's JavaScript version
- * (BSD license). http://pajhome.org.uk/
- *
- * I encapsulated the functions and wrote one additional method to fix
- * a hex conversion bug. - Rick Ellis
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Encryption
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/general/encryption.html
- */
-class CI_SHA {
-
- function CI_SHA()
- {
- log_message('debug', "SHA1 Class Initialized");
- }
-
- /**
- * Generate the Hash
- *
- * @access public
- * @param string
- * @return string
- */
- function generate($str)
- {
- $n = ((strlen($str) + 8) >> 6) + 1;
-
- for ($i = 0; $i < $n * 16; $i++)
- {
- $x[$i] = 0;
- }
-
- for ($i = 0; $i < strlen($str); $i++)
- {
- $x[$i >> 2] |= ord(substr($str, $i, 1)) << (24 - ($i % 4) * 8);
- }
-
- $x[$i >> 2] |= 0x80 << (24 - ($i % 4) * 8);
-
- $x[$n * 16 - 1] = strlen($str) * 8;
-
- $a = 1732584193;
- $b = -271733879;
- $c = -1732584194;
- $d = 271733878;
- $e = -1009589776;
-
- for ($i = 0; $i < sizeof($x); $i += 16)
- {
- $olda = $a;
- $oldb = $b;
- $oldc = $c;
- $oldd = $d;
- $olde = $e;
-
- for($j = 0; $j < 80; $j++)
- {
- if ($j < 16)
- {
- $w[$j] = $x[$i + $j];
- }
- else
- {
- $w[$j] = $this->_rol($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1);
- }
-
- $t = $this->_safe_add($this->_safe_add($this->_rol($a, 5), $this->_ft($j, $b, $c, $d)), $this->_safe_add($this->_safe_add($e, $w[$j]), $this->_kt($j)));
-
- $e = $d;
- $d = $c;
- $c = $this->_rol($b, 30);
- $b = $a;
- $a = $t;
- }
-
- $a = $this->_safe_add($a, $olda);
- $b = $this->_safe_add($b, $oldb);
- $c = $this->_safe_add($c, $oldc);
- $d = $this->_safe_add($d, $oldd);
- $e = $this->_safe_add($e, $olde);
- }
-
- return $this->_hex($a).$this->_hex($b).$this->_hex($c).$this->_hex($d).$this->_hex($e);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Convert a decimal to hex
- *
- * @access private
- * @param string
- * @return string
- */
- function _hex($str)
- {
- $str = dechex($str);
-
- if (strlen($str) == 7)
- {
- $str = '0'.$str;
- }
-
- return $str;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Return result based on iteration
- *
- * @access private
- * @return string
- */
- function _ft($t, $b, $c, $d)
- {
- if ($t < 20)
- return ($b & $c) | ((~$b) & $d);
- if ($t < 40)
- return $b ^ $c ^ $d;
- if ($t < 60)
- return ($b & $c) | ($b & $d) | ($c & $d);
-
- return $b ^ $c ^ $d;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Determine the additive constant
- *
- * @access private
- * @return string
- */
- function _kt($t)
- {
- if ($t < 20)
- {
- return 1518500249;
- }
- else if ($t < 40)
- {
- return 1859775393;
- }
- else if ($t < 60)
- {
- return -1894007588;
- }
- else
- {
- return -899497514;
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Add integers, wrapping at 2^32
- *
- * @access private
- * @return string
- */
- function _safe_add($x, $y)
- {
- $lsw = ($x & 0xFFFF) + ($y & 0xFFFF);
- $msw = ($x >> 16) + ($y >> 16) + ($lsw >> 16);
-
- return ($msw << 16) | ($lsw & 0xFFFF);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Bitwise rotate a 32-bit number
- *
- * @access private
- * @return integer
- */
- function _rol($num, $cnt)
- {
- return ($num << $cnt) | $this->_zero_fill($num, 32 - $cnt);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Pad string with zero
- *
- * @access private
- * @return string
- */
- function _zero_fill($a, $b)
- {
- $bin = decbin($a);
-
- if (strlen($bin) < $b)
- {
- $bin = 0;
- }
- else
- {
- $bin = substr($bin, 0, strlen($bin) - $b);
- }
-
- for ($i=0; $i < $b; $i++)
- {
- $bin = "0".$bin;
- }
-
- return bindec($bin);
- }
-}
-// END CI_SHA
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * SHA1 Encoding Class
+ *
+ * Purpose: Provides 160 bit hashing using The Secure Hash Algorithm
+ * developed at the National Institute of Standards and Technology. The 40
+ * character SHA1 message hash is computationally infeasible to crack.
+ *
+ * This class is a fallback for servers that are not running PHP greater than
+ * 4.3, or do not have the MHASH library.
+ *
+ * This class is based on two scripts:
+ *
+ * Marcus Campbell's PHP implementation (GNU license)
+ * http://www.tecknik.net/sha-1/
+ *
+ * ...which is based on Paul Johnston's JavaScript version
+ * (BSD license). http://pajhome.org.uk/
+ *
+ * I encapsulated the functions and wrote one additional method to fix
+ * a hex conversion bug. - Rick Ellis
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category Encryption
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/general/encryption.html
+ */
+class CI_SHA {
+
+ function CI_SHA()
+ {
+ log_message('debug', "SHA1 Class Initialized");
+ }
+
+ /**
+ * Generate the Hash
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function generate($str)
+ {
+ $n = ((strlen($str) + 8) >> 6) + 1;
+
+ for ($i = 0; $i < $n * 16; $i++)
+ {
+ $x[$i] = 0;
+ }
+
+ for ($i = 0; $i < strlen($str); $i++)
+ {
+ $x[$i >> 2] |= ord(substr($str, $i, 1)) << (24 - ($i % 4) * 8);
+ }
+
+ $x[$i >> 2] |= 0x80 << (24 - ($i % 4) * 8);
+
+ $x[$n * 16 - 1] = strlen($str) * 8;
+
+ $a = 1732584193;
+ $b = -271733879;
+ $c = -1732584194;
+ $d = 271733878;
+ $e = -1009589776;
+
+ for ($i = 0; $i < sizeof($x); $i += 16)
+ {
+ $olda = $a;
+ $oldb = $b;
+ $oldc = $c;
+ $oldd = $d;
+ $olde = $e;
+
+ for($j = 0; $j < 80; $j++)
+ {
+ if ($j < 16)
+ {
+ $w[$j] = $x[$i + $j];
+ }
+ else
+ {
+ $w[$j] = $this->_rol($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1);
+ }
+
+ $t = $this->_safe_add($this->_safe_add($this->_rol($a, 5), $this->_ft($j, $b, $c, $d)), $this->_safe_add($this->_safe_add($e, $w[$j]), $this->_kt($j)));
+
+ $e = $d;
+ $d = $c;
+ $c = $this->_rol($b, 30);
+ $b = $a;
+ $a = $t;
+ }
+
+ $a = $this->_safe_add($a, $olda);
+ $b = $this->_safe_add($b, $oldb);
+ $c = $this->_safe_add($c, $oldc);
+ $d = $this->_safe_add($d, $oldd);
+ $e = $this->_safe_add($e, $olde);
+ }
+
+ return $this->_hex($a).$this->_hex($b).$this->_hex($c).$this->_hex($d).$this->_hex($e);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Convert a decimal to hex
+ *
+ * @access private
+ * @param string
+ * @return string
+ */
+ function _hex($str)
+ {
+ $str = dechex($str);
+
+ if (strlen($str) == 7)
+ {
+ $str = '0'.$str;
+ }
+
+ return $str;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Return result based on iteration
+ *
+ * @access private
+ * @return string
+ */
+ function _ft($t, $b, $c, $d)
+ {
+ if ($t < 20)
+ return ($b & $c) | ((~$b) & $d);
+ if ($t < 40)
+ return $b ^ $c ^ $d;
+ if ($t < 60)
+ return ($b & $c) | ($b & $d) | ($c & $d);
+
+ return $b ^ $c ^ $d;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Determine the additive constant
+ *
+ * @access private
+ * @return string
+ */
+ function _kt($t)
+ {
+ if ($t < 20)
+ {
+ return 1518500249;
+ }
+ else if ($t < 40)
+ {
+ return 1859775393;
+ }
+ else if ($t < 60)
+ {
+ return -1894007588;
+ }
+ else
+ {
+ return -899497514;
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Add integers, wrapping at 2^32
+ *
+ * @access private
+ * @return string
+ */
+ function _safe_add($x, $y)
+ {
+ $lsw = ($x & 0xFFFF) + ($y & 0xFFFF);
+ $msw = ($x >> 16) + ($y >> 16) + ($lsw >> 16);
+
+ return ($msw << 16) | ($lsw & 0xFFFF);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Bitwise rotate a 32-bit number
+ *
+ * @access private
+ * @return integer
+ */
+ function _rol($num, $cnt)
+ {
+ return ($num << $cnt) | $this->_zero_fill($num, 32 - $cnt);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Pad string with zero
+ *
+ * @access private
+ * @return string
+ */
+ function _zero_fill($a, $b)
+ {
+ $bin = decbin($a);
+
+ if (strlen($bin) < $b)
+ {
+ $bin = 0;
+ }
+ else
+ {
+ $bin = substr($bin, 0, strlen($bin) - $b);
+ }
+
+ for ($i=0; $i < $b; $i++)
+ {
+ $bin = "0".$bin;
+ }
+
+ return bindec($bin);
+ }
+}
+// END CI_SHA
?> \ No newline at end of file
diff --git a/system/libraries/Table.php b/system/libraries/Table.php
index 32223708e..44acce657 100644
--- a/system/libraries/Table.php
+++ b/system/libraries/Table.php
@@ -1,12 +1,12 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
- * Code Igniter
+ * CodeIgniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
* @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
* @license http://www.codeignitor.com/user_guide/license.html
* @link http://www.codeigniter.com
* @since Version 1.3.1
diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php
index 6d5e206ff..7c13a5034 100644
--- a/system/libraries/Trackback.php
+++ b/system/libraries/Trackback.php
@@ -1,548 +1,548 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Trackback Class
- *
- * Trackback Sending/Receiving Class
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Trackbacks
- * @author Paul Burdick
- * @link http://www.codeigniter.com/user_guide/libraries/trackback.html
- */
-class CI_Trackback {
-
- var $time_format = 'local';
- var $charset = 'UTF-8';
- var $data = array('url' => '', 'title' => '', 'excerpt' => '', 'blog_name' => '', 'charset' => '');
- var $convert_ascii = TRUE;
- var $response = '';
- var $error_msg = array();
-
- /**
- * Constructor
- *
- * @access public
- */
- function CI_Trackback()
- {
- log_message('debug', "Trackback Class Initialized");
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Send Trackback
- *
- * @access public
- * @param array
- * @return bool
- */
- function send($tb_data)
- {
- if ( ! is_array($tb_data))
- {
- $this->set_error('The send() method must be passed an array');
- return FALSE;
- }
-
- // Pre-process the Trackback Data
- foreach (array('url', 'title', 'excerpt', 'blog_name', 'ping_url') as $item)
- {
- if ( ! isset($tb_data[$item]))
- {
- $this->set_error('Required item missing: '.$item);
- return FALSE;
- }
-
- switch ($item)
- {
- case 'ping_url' : $$item = $this->extract_urls($tb_data[$item]);
- break;
- case 'excerpt' : $$item = $this->limit_characters($this->convert_xml(strip_tags(stripslashes($tb_data[$item]))));
- break;
- case 'url' : $$item = str_replace('&#45;', '-', $this->convert_xml(strip_tags(stripslashes($tb_data[$item]))));
- break;
- default : $$item = $this->convert_xml(strip_tags(stripslashes($tb_data[$item])));
- break;
- }
-
- // Convert High ASCII Characters
- if ($this->convert_ascii == TRUE)
- {
- if ($item == 'excerpt')
- {
- $$item = $this->convert_ascii($$item);
- }
- elseif ($item == 'title')
- {
- $$item = $this->convert_ascii($$item);
- }
- elseif($item == 'blog_name')
- {
- $$item = $this->convert_ascii($$item);
- }
- }
- }
-
- // Build the Trackback data string
- $charset = ( ! isset($tb_data['charset'])) ? $this->charset : $tb_data['charset'];
-
- $data = "url=".rawurlencode($url)."&title=".rawurlencode($title)."&blog_name=".rawurlencode($blog_name)."&excerpt=".rawurlencode($excerpt)."&charset=".rawurlencode($charset);
-
- // Send Trackback(s)
- $return = TRUE;
- if (count($ping_url) > 0)
- {
- foreach ($ping_url as $url)
- {
- if ($this->process($url, $data) == FALSE)
- {
- $return = FALSE;
- }
- }
- }
-
- return $return;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Receive Trackback Data
- *
- * This function simply validates the incoming TB data.
- * It returns false on failure and true on success.
- * If the data is valid it is set to the $this->data array
- * so that it can be inserted into a database.
- *
- * @access public
- * @return bool
- */
- function receive()
- {
- foreach (array('url', 'title', 'blog_name', 'excerpt') as $val)
- {
- if ( ! isset($_POST[$val]) OR $_POST[$val] == '')
- {
- $this->set_error('The following required POST variable is missing: '.$val);
- return FALSE;
- }
-
- $this->data['charset'] = ( ! isset($_POST['charset'])) ? 'auto' : strtoupper(trim($_POST['charset']));
-
- if ($val != 'url' && function_exists('mb_convert_encoding'))
- {
- $_POST[$val] = mb_convert_encoding($_POST[$val], $this->charset, $this->data['charset']);
- }
-
- $_POST[$val] = ($val != 'url') ? $this->convert_xml(strip_tags($_POST[$val])) : strip_tags($_POST[$val]);
-
- if ($val == 'excerpt')
- {
- $_POST['excerpt'] = $this->limit_characters($_POST['excerpt']);
- }
-
- $this->data[$val] = $_POST[$val];
- }
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Send Trackback Error Message
- *
- * Allows custom errors to be set. By default it
- * sends the "incomplete information" error, as that's
- * the most common one.
- *
- * @access public
- * @param string
- * @return void
- */
- function send_error($message = 'Incomplete Information')
- {
- echo "<?xml version=\"1.0\" encoding=\"utf-8\"?".">\n<response>\n<error>1</error>\n<message>".$message."</message>\n</response>";
- exit;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Send Trackback Success Message
- *
- * This should be called when a trackback has been
- * successfully received and inserted.
- *
- * @access public
- * @return void
- */
- function send_success()
- {
- echo "<?xml version=\"1.0\" encoding=\"utf-8\"?".">\n<response>\n<error>0</error>\n</response>";
- exit;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Fetch a particular item
- *
- * @access public
- * @param string
- * @return string
- */
- function data($item)
- {
- return ( ! isset($this->data[$item])) ? '' : $this->data[$item];
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Process Trackback
- *
- * Opens a socket connection and passes the data to
- * the server. Returns true on success, false on failure
- *
- * @access public
- * @param string
- * @param string
- * @return bool
- */
- function process($url, $data)
- {
- $target = parse_url($url);
-
- // Open the socket
- if ( ! $fp = @fsockopen($target['host'], 80))
- {
- $this->set_error('Invalid Connection: '.$url);
- return FALSE;
- }
-
- // Build the path
- $ppath = ( ! isset($target['path'])) ? $url : $target['path'];
-
- $path = (isset($target['query']) && $target['query'] != "") ? $ppath.'?'.$target['query'] : $ppath;
-
- // Add the Trackback ID to the data string
- if ($id = $this->get_id($url))
- {
- $data = "tb_id=".$id."&".$data;
- }
-
- // Transfer the data
- fputs ($fp, "POST " . $path . " HTTP/1.0\r\n" );
- fputs ($fp, "Host: " . $target['host'] . "\r\n" );
- fputs ($fp, "Content-type: application/x-www-form-urlencoded\r\n" );
- fputs ($fp, "Content-length: " . strlen($data) . "\r\n" );
- fputs ($fp, "Connection: close\r\n\r\n" );
- fputs ($fp, $data);
-
- // Was it successful?
- $this->response = "";
-
- while(!feof($fp))
- {
- $this->response .= fgets($fp, 128);
- }
- @fclose($fp);
-
- if ( ! eregi("<error>0</error>", $this->response))
- {
- $message = 'An unknown error was encountered';
-
- if (preg_match("/<message>(.*?)<\/message>/is", $this->response, $match))
- {
- $message = trim($match['1']);
- }
-
- $this->set_error($message);
- return FALSE;
- }
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Extract Trackback URLs
- *
- * This function lets multiple trackbacks be sent.
- * It takes a string of URLs (separated by comma or
- * space) and puts each URL into an array
- *
- * @access public
- * @param string
- * @return string
- */
- function extract_urls($urls)
- {
- // Remove the pesky white space and replace with a comma.
- $urls = preg_replace("/\s*(\S+)\s*/", "\\1,", $urls);
-
- // If they use commas get rid of the doubles.
- $urls = str_replace(",,", ",", $urls);
-
- // Remove any comma that might be at the end
- if (substr($urls, -1) == ",")
- {
- $urls = substr($urls, 0, -1);
- }
-
- // Break into an array via commas
- $urls = preg_split('/[,]/', $urls);
-
- // Removes duplicates
- $urls = array_unique($urls);
-
- array_walk($urls, array($this, 'validate_url'));
-
- return $urls;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Validate URL
- *
- * Simply adds "http://" if missing
- *
- * @access public
- * @param string
- * @return string
- */
- function validate_url($url)
- {
- $url = trim($url);
-
- if (substr($url, 0, 4) != "http")
- {
- $url = "http://".$url;
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Find the Trackback URL's ID
- *
- * @access public
- * @param string
- * @return string
- */
- function get_id($url)
- {
- $tb_id = "";
-
- if (strstr($url, '?'))
- {
- $tb_array = explode('/', $url);
- $tb_end = $tb_array[count($tb_array)-1];
-
- if ( ! is_numeric($tb_end))
- {
- $tb_end = $tb_array[count($tb_array)-2];
- }
-
- $tb_array = explode('=', $tb_end);
- $tb_id = $tb_array[count($tb_array)-1];
- }
- else
- {
- if (ereg("/$", $url))
- {
- $url = substr($url, 0, -1);
- }
-
- $tb_array = explode('/', $url);
- $tb_id = $tb_array[count($tb_array)-1];
-
- if ( ! is_numeric($tb_id))
- {
- $tb_id = $tb_array[count($tb_array)-2];
- }
- }
-
- if ( ! preg_match ("/^([0-9]+)$/", $tb_id))
- {
- return false;
- }
- else
- {
- return $tb_id;
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Convert Reserved XML characters to Entities
- *
- * @access public
- * @param string
- * @return string
- */
- function convert_xml($str)
- {
- $temp = '__TEMP_AMPERSANDS__';
-
- $str = preg_replace("/&#(\d+);/", "$temp\\1;", $str);
- $str = preg_replace("/&(\w+);/", "$temp\\1;", $str);
-
- $str = str_replace(array("&","<",">","\"", "'", "-"),
- array("&amp;", "&lt;", "&gt;", "&quot;", "&#39;", "&#45;"),
- $str);
-
- $str = preg_replace("/$temp(\d+);/","&#\\1;",$str);
- $str = preg_replace("/$temp(\w+);/","&\\1;", $str);
-
- return $str;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Character limiter
- *
- * Limits the string based on the character count. Will preserve complete words.
- *
- * @access public
- * @param string
- * @param integer
- * @param string
- * @return string
- */
- function limit_characters($str, $n = 500, $end_char = '&#8230;')
- {
- if (strlen($str) < $n)
- {
- return $str;
- }
-
- $str = preg_replace("/\s+/", ' ', preg_replace("/(\r\n|\r|\n)/", " ", $str));
-
- if (strlen($str) <= $n)
- {
- return $str;
- }
-
- $out = "";
- foreach (explode(' ', trim($str)) as $val)
- {
- $out .= $val.' ';
- if (strlen($out) >= $n)
- {
- return trim($out).$end_char;
- }
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * High ASCII to Entities
- *
- * Converts Hight ascii text and MS Word special chars
- * to character entities
- *
- * @access public
- * @param string
- * @return string
- */
- function convert_ascii($str)
- {
- $count = 1;
- $out = '';
- $temp = array();
-
- for ($i = 0, $s = strlen($str); $i < $s; $i++)
- {
- $ordinal = ord($str[$i]);
-
- if ($ordinal < 128)
- {
- $out .= $str[$i];
- }
- else
- {
- if (count($temp) == 0)
- {
- $count = ($ordinal < 224) ? 2 : 3;
- }
-
- $temp[] = $ordinal;
-
- if (count($temp) == $count)
- {
- $number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64);
-
- $out .= '&#'.$number.';';
- $count = 1;
- $temp = array();
- }
- }
- }
-
- return $out;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set error message
- *
- * @access public
- * @param string
- * @return void
- */
- function set_error($msg)
- {
- log_message('error', $msg);
- $this->error_msg[] = $msg;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Show error messages
- *
- * @access public
- * @param string
- * @param string
- * @return string
- */
- function display_errors($open = '<p>', $close = '</p>')
- {
- $str = '';
- foreach ($this->error_msg as $val)
- {
- $str .= $open.$val.$close;
- }
-
- return $str;
- }
-
-}
-// END Trackback Class
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Trackback Class
+ *
+ * Trackback Sending/Receiving Class
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category Trackbacks
+ * @author Paul Burdick
+ * @link http://www.codeigniter.com/user_guide/libraries/trackback.html
+ */
+class CI_Trackback {
+
+ var $time_format = 'local';
+ var $charset = 'UTF-8';
+ var $data = array('url' => '', 'title' => '', 'excerpt' => '', 'blog_name' => '', 'charset' => '');
+ var $convert_ascii = TRUE;
+ var $response = '';
+ var $error_msg = array();
+
+ /**
+ * Constructor
+ *
+ * @access public
+ */
+ function CI_Trackback()
+ {
+ log_message('debug', "Trackback Class Initialized");
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Send Trackback
+ *
+ * @access public
+ * @param array
+ * @return bool
+ */
+ function send($tb_data)
+ {
+ if ( ! is_array($tb_data))
+ {
+ $this->set_error('The send() method must be passed an array');
+ return FALSE;
+ }
+
+ // Pre-process the Trackback Data
+ foreach (array('url', 'title', 'excerpt', 'blog_name', 'ping_url') as $item)
+ {
+ if ( ! isset($tb_data[$item]))
+ {
+ $this->set_error('Required item missing: '.$item);
+ return FALSE;
+ }
+
+ switch ($item)
+ {
+ case 'ping_url' : $$item = $this->extract_urls($tb_data[$item]);
+ break;
+ case 'excerpt' : $$item = $this->limit_characters($this->convert_xml(strip_tags(stripslashes($tb_data[$item]))));
+ break;
+ case 'url' : $$item = str_replace('&#45;', '-', $this->convert_xml(strip_tags(stripslashes($tb_data[$item]))));
+ break;
+ default : $$item = $this->convert_xml(strip_tags(stripslashes($tb_data[$item])));
+ break;
+ }
+
+ // Convert High ASCII Characters
+ if ($this->convert_ascii == TRUE)
+ {
+ if ($item == 'excerpt')
+ {
+ $$item = $this->convert_ascii($$item);
+ }
+ elseif ($item == 'title')
+ {
+ $$item = $this->convert_ascii($$item);
+ }
+ elseif($item == 'blog_name')
+ {
+ $$item = $this->convert_ascii($$item);
+ }
+ }
+ }
+
+ // Build the Trackback data string
+ $charset = ( ! isset($tb_data['charset'])) ? $this->charset : $tb_data['charset'];
+
+ $data = "url=".rawurlencode($url)."&title=".rawurlencode($title)."&blog_name=".rawurlencode($blog_name)."&excerpt=".rawurlencode($excerpt)."&charset=".rawurlencode($charset);
+
+ // Send Trackback(s)
+ $return = TRUE;
+ if (count($ping_url) > 0)
+ {
+ foreach ($ping_url as $url)
+ {
+ if ($this->process($url, $data) == FALSE)
+ {
+ $return = FALSE;
+ }
+ }
+ }
+
+ return $return;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Receive Trackback Data
+ *
+ * This function simply validates the incoming TB data.
+ * It returns false on failure and true on success.
+ * If the data is valid it is set to the $this->data array
+ * so that it can be inserted into a database.
+ *
+ * @access public
+ * @return bool
+ */
+ function receive()
+ {
+ foreach (array('url', 'title', 'blog_name', 'excerpt') as $val)
+ {
+ if ( ! isset($_POST[$val]) OR $_POST[$val] == '')
+ {
+ $this->set_error('The following required POST variable is missing: '.$val);
+ return FALSE;
+ }
+
+ $this->data['charset'] = ( ! isset($_POST['charset'])) ? 'auto' : strtoupper(trim($_POST['charset']));
+
+ if ($val != 'url' && function_exists('mb_convert_encoding'))
+ {
+ $_POST[$val] = mb_convert_encoding($_POST[$val], $this->charset, $this->data['charset']);
+ }
+
+ $_POST[$val] = ($val != 'url') ? $this->convert_xml(strip_tags($_POST[$val])) : strip_tags($_POST[$val]);
+
+ if ($val == 'excerpt')
+ {
+ $_POST['excerpt'] = $this->limit_characters($_POST['excerpt']);
+ }
+
+ $this->data[$val] = $_POST[$val];
+ }
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Send Trackback Error Message
+ *
+ * Allows custom errors to be set. By default it
+ * sends the "incomplete information" error, as that's
+ * the most common one.
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function send_error($message = 'Incomplete Information')
+ {
+ echo "<?xml version=\"1.0\" encoding=\"utf-8\"?".">\n<response>\n<error>1</error>\n<message>".$message."</message>\n</response>";
+ exit;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Send Trackback Success Message
+ *
+ * This should be called when a trackback has been
+ * successfully received and inserted.
+ *
+ * @access public
+ * @return void
+ */
+ function send_success()
+ {
+ echo "<?xml version=\"1.0\" encoding=\"utf-8\"?".">\n<response>\n<error>0</error>\n</response>";
+ exit;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch a particular item
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function data($item)
+ {
+ return ( ! isset($this->data[$item])) ? '' : $this->data[$item];
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Process Trackback
+ *
+ * Opens a socket connection and passes the data to
+ * the server. Returns true on success, false on failure
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return bool
+ */
+ function process($url, $data)
+ {
+ $target = parse_url($url);
+
+ // Open the socket
+ if ( ! $fp = @fsockopen($target['host'], 80))
+ {
+ $this->set_error('Invalid Connection: '.$url);
+ return FALSE;
+ }
+
+ // Build the path
+ $ppath = ( ! isset($target['path'])) ? $url : $target['path'];
+
+ $path = (isset($target['query']) && $target['query'] != "") ? $ppath.'?'.$target['query'] : $ppath;
+
+ // Add the Trackback ID to the data string
+ if ($id = $this->get_id($url))
+ {
+ $data = "tb_id=".$id."&".$data;
+ }
+
+ // Transfer the data
+ fputs ($fp, "POST " . $path . " HTTP/1.0\r\n" );
+ fputs ($fp, "Host: " . $target['host'] . "\r\n" );
+ fputs ($fp, "Content-type: application/x-www-form-urlencoded\r\n" );
+ fputs ($fp, "Content-length: " . strlen($data) . "\r\n" );
+ fputs ($fp, "Connection: close\r\n\r\n" );
+ fputs ($fp, $data);
+
+ // Was it successful?
+ $this->response = "";
+
+ while(!feof($fp))
+ {
+ $this->response .= fgets($fp, 128);
+ }
+ @fclose($fp);
+
+ if ( ! eregi("<error>0</error>", $this->response))
+ {
+ $message = 'An unknown error was encountered';
+
+ if (preg_match("/<message>(.*?)<\/message>/is", $this->response, $match))
+ {
+ $message = trim($match['1']);
+ }
+
+ $this->set_error($message);
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Extract Trackback URLs
+ *
+ * This function lets multiple trackbacks be sent.
+ * It takes a string of URLs (separated by comma or
+ * space) and puts each URL into an array
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function extract_urls($urls)
+ {
+ // Remove the pesky white space and replace with a comma.
+ $urls = preg_replace("/\s*(\S+)\s*/", "\\1,", $urls);
+
+ // If they use commas get rid of the doubles.
+ $urls = str_replace(",,", ",", $urls);
+
+ // Remove any comma that might be at the end
+ if (substr($urls, -1) == ",")
+ {
+ $urls = substr($urls, 0, -1);
+ }
+
+ // Break into an array via commas
+ $urls = preg_split('/[,]/', $urls);
+
+ // Removes duplicates
+ $urls = array_unique($urls);
+
+ array_walk($urls, array($this, 'validate_url'));
+
+ return $urls;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Validate URL
+ *
+ * Simply adds "http://" if missing
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function validate_url($url)
+ {
+ $url = trim($url);
+
+ if (substr($url, 0, 4) != "http")
+ {
+ $url = "http://".$url;
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Find the Trackback URL's ID
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function get_id($url)
+ {
+ $tb_id = "";
+
+ if (strstr($url, '?'))
+ {
+ $tb_array = explode('/', $url);
+ $tb_end = $tb_array[count($tb_array)-1];
+
+ if ( ! is_numeric($tb_end))
+ {
+ $tb_end = $tb_array[count($tb_array)-2];
+ }
+
+ $tb_array = explode('=', $tb_end);
+ $tb_id = $tb_array[count($tb_array)-1];
+ }
+ else
+ {
+ if (ereg("/$", $url))
+ {
+ $url = substr($url, 0, -1);
+ }
+
+ $tb_array = explode('/', $url);
+ $tb_id = $tb_array[count($tb_array)-1];
+
+ if ( ! is_numeric($tb_id))
+ {
+ $tb_id = $tb_array[count($tb_array)-2];
+ }
+ }
+
+ if ( ! preg_match ("/^([0-9]+)$/", $tb_id))
+ {
+ return false;
+ }
+ else
+ {
+ return $tb_id;
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Convert Reserved XML characters to Entities
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function convert_xml($str)
+ {
+ $temp = '__TEMP_AMPERSANDS__';
+
+ $str = preg_replace("/&#(\d+);/", "$temp\\1;", $str);
+ $str = preg_replace("/&(\w+);/", "$temp\\1;", $str);
+
+ $str = str_replace(array("&","<",">","\"", "'", "-"),
+ array("&amp;", "&lt;", "&gt;", "&quot;", "&#39;", "&#45;"),
+ $str);
+
+ $str = preg_replace("/$temp(\d+);/","&#\\1;",$str);
+ $str = preg_replace("/$temp(\w+);/","&\\1;", $str);
+
+ return $str;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Character limiter
+ *
+ * Limits the string based on the character count. Will preserve complete words.
+ *
+ * @access public
+ * @param string
+ * @param integer
+ * @param string
+ * @return string
+ */
+ function limit_characters($str, $n = 500, $end_char = '&#8230;')
+ {
+ if (strlen($str) < $n)
+ {
+ return $str;
+ }
+
+ $str = preg_replace("/\s+/", ' ', preg_replace("/(\r\n|\r|\n)/", " ", $str));
+
+ if (strlen($str) <= $n)
+ {
+ return $str;
+ }
+
+ $out = "";
+ foreach (explode(' ', trim($str)) as $val)
+ {
+ $out .= $val.' ';
+ if (strlen($out) >= $n)
+ {
+ return trim($out).$end_char;
+ }
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * High ASCII to Entities
+ *
+ * Converts Hight ascii text and MS Word special chars
+ * to character entities
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function convert_ascii($str)
+ {
+ $count = 1;
+ $out = '';
+ $temp = array();
+
+ for ($i = 0, $s = strlen($str); $i < $s; $i++)
+ {
+ $ordinal = ord($str[$i]);
+
+ if ($ordinal < 128)
+ {
+ $out .= $str[$i];
+ }
+ else
+ {
+ if (count($temp) == 0)
+ {
+ $count = ($ordinal < 224) ? 2 : 3;
+ }
+
+ $temp[] = $ordinal;
+
+ if (count($temp) == $count)
+ {
+ $number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64);
+
+ $out .= '&#'.$number.';';
+ $count = 1;
+ $temp = array();
+ }
+ }
+ }
+
+ return $out;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set error message
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function set_error($msg)
+ {
+ log_message('error', $msg);
+ $this->error_msg[] = $msg;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Show error messages
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return string
+ */
+ function display_errors($open = '<p>', $close = '</p>')
+ {
+ $str = '';
+ foreach ($this->error_msg as $val)
+ {
+ $str .= $open.$val.$close;
+ }
+
+ return $str;
+ }
+
+}
+// END Trackback Class
?> \ No newline at end of file
diff --git a/system/libraries/URI.php b/system/libraries/URI.php
index 10654a69c..5cedd8e0f 100644
--- a/system/libraries/URI.php
+++ b/system/libraries/URI.php
@@ -1,367 +1,367 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * URI Class
- *
- * Parses URIs and determines routing
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category URI
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/libraries/uri.html
- */
-class CI_URI {
-
- var $router;
- var $keyval = 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 CI_URI()
- {
- $this->router =& load_class('Router');
- log_message('debug', "URI Class Initialized");
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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->router->segments[$n])) ? $no_result : $this->router->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->router->rsegments[$n])) ? $no_result : $this->router->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:
- *
- * www.your-site.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')
- {
- if ($where == 'trailing')
- {
- $trailing = '/';
- $leading = '';
- }
- elseif ($where == 'leading')
- {
- $leading = '/';
- $trailing = '';
- }
- else
- {
- $leading = '/';
- $trailing = '/';
- }
- return $leading.$this->$which($n).$trailing;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Segment Array
- *
- * @access public
- * @return array
- */
- function segment_array()
- {
- return $this->router->segments;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Routed Segment Array
- *
- * @access public
- * @return array
- */
- function rsegment_array()
- {
- return $this->router->rsegments;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Total number of segments
- *
- * @access public
- * @return integer
- */
- function total_segments()
- {
- return count($this->router->segments);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Total number of routed segments
- *
- * @access public
- * @return integer
- */
- function total_rsegments()
- {
- return count($this->router->rsegments);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Fetch the entire URI string
- *
- * @access public
- * @return string
- */
- function uri_string()
- {
- return $this->router->uri_string;
- }
-
-
- // --------------------------------------------------------------------
-
- /**
- * Fetch the entire Re-routed URI string
- *
- * @access public
- * @return string
- */
- function ruri_string()
- {
- return '/'.implode('/', $this->rsegment_array()).'/';
- }
-
-}
-// END URI Class
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * URI Class
+ *
+ * Parses URIs and determines routing
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category URI
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/libraries/uri.html
+ */
+class CI_URI {
+
+ var $router;
+ var $keyval = 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 CI_URI()
+ {
+ $this->router =& load_class('Router');
+ log_message('debug', "URI Class Initialized");
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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->router->segments[$n])) ? $no_result : $this->router->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->router->rsegments[$n])) ? $no_result : $this->router->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:
+ *
+ * www.your-site.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')
+ {
+ if ($where == 'trailing')
+ {
+ $trailing = '/';
+ $leading = '';
+ }
+ elseif ($where == 'leading')
+ {
+ $leading = '/';
+ $trailing = '';
+ }
+ else
+ {
+ $leading = '/';
+ $trailing = '/';
+ }
+ return $leading.$this->$which($n).$trailing;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Segment Array
+ *
+ * @access public
+ * @return array
+ */
+ function segment_array()
+ {
+ return $this->router->segments;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Routed Segment Array
+ *
+ * @access public
+ * @return array
+ */
+ function rsegment_array()
+ {
+ return $this->router->rsegments;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Total number of segments
+ *
+ * @access public
+ * @return integer
+ */
+ function total_segments()
+ {
+ return count($this->router->segments);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Total number of routed segments
+ *
+ * @access public
+ * @return integer
+ */
+ function total_rsegments()
+ {
+ return count($this->router->rsegments);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch the entire URI string
+ *
+ * @access public
+ * @return string
+ */
+ function uri_string()
+ {
+ return $this->router->uri_string;
+ }
+
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch the entire Re-routed URI string
+ *
+ * @access public
+ * @return string
+ */
+ function ruri_string()
+ {
+ return '/'.implode('/', $this->rsegment_array()).'/';
+ }
+
+}
+// END URI Class
?> \ No newline at end of file
diff --git a/system/libraries/Unit_test.php b/system/libraries/Unit_test.php
index f68f69e71..74ed1275f 100644
--- a/system/libraries/Unit_test.php
+++ b/system/libraries/Unit_test.php
@@ -1,331 +1,331 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.3.1
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Unit Testing Class
- *
- * Simple testing class
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category UnitTesting
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/libraries/uri.html
- */
-class CI_Unit_test {
-
- var $active = TRUE;
- var $results = array();
- var $strict = FALSE;
- var $_template = NULL;
- var $_template_rows = NULL;
-
- function CI_Unit_test()
- {
- log_message('debug', "Unit Testing Class Initialized");
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Run the tests
- *
- * Runs the supplied tests
- *
- * @access public
- * @param mixed
- * @param mixed
- * @param string
- * @return string
- */
- function run($test, $expected = TRUE, $test_name = 'undefined')
- {
- if ($this->active == FALSE)
- return FALSE;
-
- if (in_array($expected, array('is_string', 'is_bool', 'is_true', 'is_false', 'is_int', 'is_numeric', 'is_float', 'is_double', 'is_array', 'is_null'), TRUE))
- {
- $expected = str_replace('is_float', 'is_double', $expected);
- $result = ($expected($test)) ? TRUE : FALSE;
- $extype = str_replace(array('true', 'false'), 'bool', str_replace('is_', '', $expected));
- }
- else
- {
- if ($this->strict == TRUE)
- $result = ($test === $expected) ? TRUE : FALSE;
- else
- $result = ($test == $expected) ? TRUE : FALSE;
-
- $extype = gettype($expected);
- }
-
- $back = $this->_backtrace();
-
- $report[] = array (
- 'test_name' => $test_name,
- 'test_datatype' => gettype($test),
- 'res_datatype' => $extype,
- 'result' => ($result === TRUE) ? 'passed' : 'failed',
- 'file' => $back['file'],
- 'line' => $back['line']
- );
-
- $this->results[] = $report;
-
- return($this->report($this->result($report)));
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Generate a report
- *
- * Displays a table with the test data
- *
- * @access public
- * @return string
- */
- function report($result = array())
- {
- if (count($result) == 0)
- {
- $result = $this->result();
- }
-
- $this->_parse_template();
-
- $r = '';
- foreach ($result as $res)
- {
- $table = '';
-
- foreach ($res as $key => $val)
- {
- $temp = $this->_template_rows;
- $temp = str_replace('{item}', $key, $temp);
- $temp = str_replace('{result}', $val, $temp);
- $table .= $temp;
- }
-
- $r .= str_replace('{rows}', $table, $this->_template);
- }
-
- return $r;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Use strict comparison
- *
- * Causes the evaluation to use === rather then ==
- *
- * @access public
- * @param bool
- * @return null
- */
- function use_strict($state = TRUE)
- {
- $this->strict = ($state == FALSE) ? FALSE : TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Make Unit testing active
- *
- * Enables/disables unit testing
- *
- * @access public
- * @param bool
- * @return null
- */
- function active($state = TRUE)
- {
- $this->active = ($state == FALSE) ? FALSE : TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Result Array
- *
- * Returns the raw result data
- *
- * @access public
- * @return array
- */
- function result($results = array())
- {
- $CI =& get_instance();
- $CI->load->language('unit_test');
-
- if (count($results) == 0)
- {
- $results = $this->results;
- }
-
- $retval = array();
- foreach ($results as $result)
- {
- $temp = array();
- foreach ($result as $key => $val)
- {
- if (is_array($val))
- {
- foreach ($val as $k => $v)
- {
- if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$v))))
- {
- $v = $line;
- }
- $temp[$CI->lang->line('ut_'.$k)] = $v;
- }
- }
- else
- {
- if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$val))))
- {
- $val = $line;
- }
- $temp[$CI->lang->line('ut_'.$key)] = $val;
- }
- }
-
- $retval[] = $temp;
- }
-
- return $retval;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set the template
- *
- * This lets us set the template to be used to display results
- *
- * @access public
- * @param string
- * @return void
- */
- function set_template($template)
- {
- $this->_template = $template;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Generate a backtrace
- *
- * This lets us show file names and line numbers
- *
- * @access private
- * @return array
- */
- function _backtrace()
- {
- if (function_exists('debug_backtrace'))
- {
- $back = debug_backtrace();
-
- $file = ( ! isset($back['1']['file'])) ? '' : $back['1']['file'];
- $line = ( ! isset($back['1']['line'])) ? '' : $back['1']['line'];
-
- return array('file' => $file, 'line' => $line);
- }
- return array('file' => 'Unknown', 'line' => 'Unknown');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Get Default Template
- *
- * @access private
- * @return string
- */
- function _default_template()
- {
- $this->_template = '
- <div style="margin:15px;background-color:#ccc;">
- <table border="0" cellpadding="4" cellspacing="1" style="width:100%;">
- {rows}
- </table></div>';
-
- $this->_template_rows = '
- <tr>
- <td style="background-color:#fff;width:140px;font-size:12px;font-weight:bold;">{item}</td>
- <td style="background-color:#fff;font-size:12px;">{result}</td>
- </tr>
- ';
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Parse Template
- *
- * Harvests the data within the template {pseudo-variables}
- *
- * @access private
- * @return void
- */
- function _parse_template()
- {
- if ( ! is_null($this->_template_rows))
- {
- return;
- }
-
- if (is_null($this->_template))
- {
- $this->_default_template();
- return;
- }
-
- if ( ! preg_match("/\{rows\}(.*?)\{\/rows\}/si", $this->_template, $match))
- {
- $this->_default_template();
- return;
- }
-
- $this->_template_rows = $match['1'];
- $this->_template = str_replace($match['0'], '{rows}', $this->_template);
- }
-
-}
-// END Unit_test Class
-
-/**
- * Helper functions to test boolean true/false
- *
- *
- * @access private
- * @return bool
- */
-function is_true($test)
-{
- return (is_bool($test) AND $test === TRUE) ? TRUE : FALSE;
-}
-function is_false($test)
-{
- return (is_bool($test) AND $test === FALSE) ? TRUE : FALSE;
-}
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.3.1
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Unit Testing Class
+ *
+ * Simple testing class
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category UnitTesting
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/libraries/uri.html
+ */
+class CI_Unit_test {
+
+ var $active = TRUE;
+ var $results = array();
+ var $strict = FALSE;
+ var $_template = NULL;
+ var $_template_rows = NULL;
+
+ function CI_Unit_test()
+ {
+ log_message('debug', "Unit Testing Class Initialized");
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Run the tests
+ *
+ * Runs the supplied tests
+ *
+ * @access public
+ * @param mixed
+ * @param mixed
+ * @param string
+ * @return string
+ */
+ function run($test, $expected = TRUE, $test_name = 'undefined')
+ {
+ if ($this->active == FALSE)
+ return FALSE;
+
+ if (in_array($expected, array('is_string', 'is_bool', 'is_true', 'is_false', 'is_int', 'is_numeric', 'is_float', 'is_double', 'is_array', 'is_null'), TRUE))
+ {
+ $expected = str_replace('is_float', 'is_double', $expected);
+ $result = ($expected($test)) ? TRUE : FALSE;
+ $extype = str_replace(array('true', 'false'), 'bool', str_replace('is_', '', $expected));
+ }
+ else
+ {
+ if ($this->strict == TRUE)
+ $result = ($test === $expected) ? TRUE : FALSE;
+ else
+ $result = ($test == $expected) ? TRUE : FALSE;
+
+ $extype = gettype($expected);
+ }
+
+ $back = $this->_backtrace();
+
+ $report[] = array (
+ 'test_name' => $test_name,
+ 'test_datatype' => gettype($test),
+ 'res_datatype' => $extype,
+ 'result' => ($result === TRUE) ? 'passed' : 'failed',
+ 'file' => $back['file'],
+ 'line' => $back['line']
+ );
+
+ $this->results[] = $report;
+
+ return($this->report($this->result($report)));
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Generate a report
+ *
+ * Displays a table with the test data
+ *
+ * @access public
+ * @return string
+ */
+ function report($result = array())
+ {
+ if (count($result) == 0)
+ {
+ $result = $this->result();
+ }
+
+ $this->_parse_template();
+
+ $r = '';
+ foreach ($result as $res)
+ {
+ $table = '';
+
+ foreach ($res as $key => $val)
+ {
+ $temp = $this->_template_rows;
+ $temp = str_replace('{item}', $key, $temp);
+ $temp = str_replace('{result}', $val, $temp);
+ $table .= $temp;
+ }
+
+ $r .= str_replace('{rows}', $table, $this->_template);
+ }
+
+ return $r;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Use strict comparison
+ *
+ * Causes the evaluation to use === rather then ==
+ *
+ * @access public
+ * @param bool
+ * @return null
+ */
+ function use_strict($state = TRUE)
+ {
+ $this->strict = ($state == FALSE) ? FALSE : TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Make Unit testing active
+ *
+ * Enables/disables unit testing
+ *
+ * @access public
+ * @param bool
+ * @return null
+ */
+ function active($state = TRUE)
+ {
+ $this->active = ($state == FALSE) ? FALSE : TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Result Array
+ *
+ * Returns the raw result data
+ *
+ * @access public
+ * @return array
+ */
+ function result($results = array())
+ {
+ $CI =& get_instance();
+ $CI->load->language('unit_test');
+
+ if (count($results) == 0)
+ {
+ $results = $this->results;
+ }
+
+ $retval = array();
+ foreach ($results as $result)
+ {
+ $temp = array();
+ foreach ($result as $key => $val)
+ {
+ if (is_array($val))
+ {
+ foreach ($val as $k => $v)
+ {
+ if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$v))))
+ {
+ $v = $line;
+ }
+ $temp[$CI->lang->line('ut_'.$k)] = $v;
+ }
+ }
+ else
+ {
+ if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$val))))
+ {
+ $val = $line;
+ }
+ $temp[$CI->lang->line('ut_'.$key)] = $val;
+ }
+ }
+
+ $retval[] = $temp;
+ }
+
+ return $retval;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set the template
+ *
+ * This lets us set the template to be used to display results
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function set_template($template)
+ {
+ $this->_template = $template;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Generate a backtrace
+ *
+ * This lets us show file names and line numbers
+ *
+ * @access private
+ * @return array
+ */
+ function _backtrace()
+ {
+ if (function_exists('debug_backtrace'))
+ {
+ $back = debug_backtrace();
+
+ $file = ( ! isset($back['1']['file'])) ? '' : $back['1']['file'];
+ $line = ( ! isset($back['1']['line'])) ? '' : $back['1']['line'];
+
+ return array('file' => $file, 'line' => $line);
+ }
+ return array('file' => 'Unknown', 'line' => 'Unknown');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get Default Template
+ *
+ * @access private
+ * @return string
+ */
+ function _default_template()
+ {
+ $this->_template = '
+ <div style="margin:15px;background-color:#ccc;">
+ <table border="0" cellpadding="4" cellspacing="1" style="width:100%;">
+ {rows}
+ </table></div>';
+
+ $this->_template_rows = '
+ <tr>
+ <td style="background-color:#fff;width:140px;font-size:12px;font-weight:bold;">{item}</td>
+ <td style="background-color:#fff;font-size:12px;">{result}</td>
+ </tr>
+ ';
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Parse Template
+ *
+ * Harvests the data within the template {pseudo-variables}
+ *
+ * @access private
+ * @return void
+ */
+ function _parse_template()
+ {
+ if ( ! is_null($this->_template_rows))
+ {
+ return;
+ }
+
+ if (is_null($this->_template))
+ {
+ $this->_default_template();
+ return;
+ }
+
+ if ( ! preg_match("/\{rows\}(.*?)\{\/rows\}/si", $this->_template, $match))
+ {
+ $this->_default_template();
+ return;
+ }
+
+ $this->_template_rows = $match['1'];
+ $this->_template = str_replace($match['0'], '{rows}', $this->_template);
+ }
+
+}
+// END Unit_test Class
+
+/**
+ * Helper functions to test boolean true/false
+ *
+ *
+ * @access private
+ * @return bool
+ */
+function is_true($test)
+{
+ return (is_bool($test) AND $test === TRUE) ? TRUE : FALSE;
+}
+function is_false($test)
+{
+ return (is_bool($test) AND $test === FALSE) ? TRUE : FALSE;
+}
+
?> \ No newline at end of file
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index ff0fb1cb9..564e29937 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -1,809 +1,809 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * File Uploading Class
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Uploads
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/libraries/file_uploading.html
- */
-class CI_Upload {
-
- var $max_size = 0;
- var $max_width = 0;
- var $max_height = 0;
- var $allowed_types = "";
- var $file_temp = "";
- var $file_name = "";
- var $orig_name = "";
- var $file_type = "";
- var $file_size = "";
- var $file_ext = "";
- var $upload_path = "";
- var $overwrite = FALSE;
- var $encrypt_name = FALSE;
- var $is_image = FALSE;
- var $image_width = '';
- var $image_height = '';
- var $image_type = '';
- var $image_size_str = '';
- var $error_msg = array();
- var $mimes = array();
- var $remove_spaces = TRUE;
- var $xss_clean = FALSE;
- var $temp_prefix = "temp_file_";
-
- /**
- * Constructor
- *
- * @access public
- */
- function CI_Upload($props = array())
- {
- if (count($props) > 0)
- {
- $this->initialize($props);
- }
-
- log_message('debug', "Upload Class Initialized");
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Initialize preferences
- *
- * @access public
- * @param array
- * @return void
- */
- function initialize($config = array())
- {
- $defaults = array(
- 'max_size' => 0,
- 'max_width' => 0,
- 'max_height' => 0,
- 'allowed_types' => "",
- 'file_temp' => "",
- 'file_name' => "",
- 'orig_name' => "",
- 'file_type' => "",
- 'file_size' => "",
- 'file_ext' => "",
- 'upload_path' => "",
- 'overwrite' => FALSE,
- 'encrypt_name' => FALSE,
- 'is_image' => FALSE,
- 'image_width' => '',
- 'image_height' => '',
- 'image_type' => '',
- 'image_size_str' => '',
- 'error_msg' => array(),
- 'mimes' => array(),
- 'remove_spaces' => TRUE,
- 'xss_clean' => FALSE,
- 'temp_prefix' => "temp_file_"
- );
-
-
- foreach ($defaults as $key => $val)
- {
- if (isset($config[$key]))
- {
- $method = 'set_'.$key;
- if (method_exists($this, $method))
- {
- $this->$method($config[$key]);
- }
- else
- {
- $this->$key = $config[$key];
- }
- }
- else
- {
- $this->$key = $val;
- }
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Perform the file upload
- *
- * @access public
- * @return bool
- */
- function do_upload($field = 'userfile')
- {
- // Is $_FILES[$field] set? If not, no reason to continue.
- if ( ! isset($_FILES[$field]))
- {
- $this->set_error('upload_userfile_not_set');
- return FALSE;
- }
-
- // Is the upload path valid?
- if ( ! $this->validate_upload_path())
- {
- return FALSE;
- }
-
- // Was the file able to be uploaded? If not, determine the reason why.
- if ( ! is_uploaded_file($_FILES[$field]['tmp_name']))
- {
- $error = ( ! isset($_FILES[$field]['error'])) ? 4 : $_FILES[$field]['error'];
-
- switch($error)
- {
- case 1 : $this->set_error('upload_file_exceeds_limit');
- break;
- case 3 : $this->set_error('upload_file_partial');
- break;
- case 4 : $this->set_error('upload_no_file_selected');
- break;
- default : $this->set_error('upload_no_file_selected');
- break;
- }
-
- return FALSE;
- }
-
- // Set the uploaded data as class variables
- $this->file_temp = $_FILES[$field]['tmp_name'];
- $this->file_name = $_FILES[$field]['name'];
- $this->file_size = $_FILES[$field]['size'];
- $this->file_type = preg_replace("/^(.+?);.*$/", "\\1", $_FILES[$field]['type']);
- $this->file_type = strtolower($this->file_type);
- $this->file_ext = $this->get_extension($_FILES[$field]['name']);
-
- // Convert the file size to kilobytes
- if ($this->file_size > 0)
- {
- $this->file_size = round($this->file_size/1024, 2);
- }
-
- // Is the file type allowed to be uploaded?
- if ( ! $this->is_allowed_filetype())
- {
- $this->set_error('upload_invalid_filetype');
- return FALSE;
- }
-
- // Is the file size within the allowed maximum?
- if ( ! $this->is_allowed_filesize())
- {
- $this->set_error('upload_invalid_filesize');
- return FALSE;
- }
-
- // Are the image dimensions within the allowed size?
- // Note: This can fail if the server has an open_basdir restriction.
- if ( ! $this->is_allowed_dimensions())
- {
- $this->set_error('upload_invalid_dimensions');
- return FALSE;
- }
-
- // Sanitize the file name for security
- $this->file_name = $this->clean_file_name($this->file_name);
-
- // Remove white spaces in the name
- if ($this->remove_spaces == TRUE)
- {
- $this->file_name = preg_replace("/\s+/", "_", $this->file_name);
- }
-
- /*
- * Validate the file name
- * This function appends an number onto the end of
- * the file if one with the same name already exists.
- * If it returns false there was a problem.
- */
- $this->orig_name = $this->file_name;
-
- if ($this->overwrite == FALSE)
- {
- $this->file_name = $this->set_filename($this->upload_path, $this->file_name);
-
- if ($this->file_name === FALSE)
- {
- return FALSE;
- }
- }
-
- /*
- * Move the file to the final destination
- * To deal with different server configurations
- * we'll attempt to use copy() first. If that fails
- * we'll use move_uploaded_file(). One of the two should
- * reliably work in most environments
- */
- if ( ! @copy($this->file_temp, $this->upload_path.$this->file_name))
- {
- if ( ! @move_uploaded_file($this->file_temp, $this->upload_path.$this->file_name))
- {
- $this->set_error('upload_destination_error');
- return FALSE;
- }
- }
-
- /*
- * Run the file through the XSS hacking filter
- * This helps prevent malicious code from being
- * embedded within a file. Scripts can easily
- * be disguised as images or other file types.
- */
- if ($this->xss_clean == TRUE)
- {
- $this->do_xss_clean();
- }
-
- /*
- * Set the finalized image dimensions
- * This sets the image width/height (assuming the
- * file was an image). We use this information
- * in the "data" function.
- */
- $this->set_image_properties($this->upload_path.$this->file_name);
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Finalized Data Array
- *
- * Returns an associative array containing all of the information
- * related to the upload, allowing the developer easy access in one array.
- *
- * @access public
- * @return array
- */
- function data()
- {
- return array (
- 'file_name' => $this->file_name,
- 'file_type' => $this->file_type,
- 'file_path' => $this->upload_path,
- 'full_path' => $this->upload_path.$this->file_name,
- 'raw_name' => str_replace($this->file_ext, '', $this->file_name),
- 'orig_name' => $this->orig_name,
- 'file_ext' => $this->file_ext,
- 'file_size' => $this->file_size,
- 'is_image' => $this->is_image(),
- 'image_width' => $this->image_width,
- 'image_height' => $this->image_height,
- 'image_type' => $this->image_type,
- 'image_size_str' => $this->image_size_str,
- );
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Upload Path
- *
- * @access public
- * @param string
- * @return void
- */
- function set_upload_path($path)
- {
- $this->upload_path = $path;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set the file name
- *
- * This function takes a filename/path as input and looks for the
- * existence of a file with the same name. If found, it will append a
- * number to the end of the filename to avoid overwriting a pre-existing file.
- *
- * @access public
- * @param string
- * @param string
- * @return string
- */
- function set_filename($path, $filename)
- {
- if ($this->encrypt_name == TRUE)
- {
- mt_srand();
- $filename = md5(uniqid(mt_rand())).$this->file_ext;
- }
-
- if ( ! file_exists($path.$filename))
- {
- return $filename;
- }
-
- $filename = str_replace($this->file_ext, '', $filename);
-
- $new_filename = '';
- for ($i = 1; $i < 100; $i++)
- {
- if ( ! file_exists($path.$filename.$i.$this->file_ext))
- {
- $new_filename = $filename.$i.$this->file_ext;
- break;
- }
- }
-
- if ($new_filename == '')
- {
- $this->set_error('upload_bad_filename');
- return FALSE;
- }
- else
- {
- return $new_filename;
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Maximum File Size
- *
- * @access public
- * @param integer
- * @return void
- */
- function set_max_filesize($n)
- {
- $this->max_size = ( ! eregi("^[[:digit:]]+$", $n)) ? 0 : $n;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Maximum Image Width
- *
- * @access public
- * @param integer
- * @return void
- */
- function set_max_width($n)
- {
- $this->max_width = ( ! eregi("^[[:digit:]]+$", $n)) ? 0 : $n;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Maximum Image Height
- *
- * @access public
- * @param integer
- * @return void
- */
- function set_max_height($n)
- {
- $this->max_height = ( ! eregi("^[[:digit:]]+$", $n)) ? 0 : $n;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Allowed File Types
- *
- * @access public
- * @param string
- * @return void
- */
- function set_allowed_types($types)
- {
- $this->allowed_types = explode('|', $types);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Image Properties
- *
- * Uses GD to determine the width/height/type of image
- *
- * @access public
- * @param string
- * @return void
- */
- function set_image_properties($path = '')
- {
- if ( ! $this->is_image())
- {
- return;
- }
-
- if (function_exists('getimagesize'))
- {
- if (FALSE !== ($D = @getimagesize($path)))
- {
- $types = array(1 => 'gif', 2 => 'jpeg', 3 => 'png');
-
- $this->image_width = $D['0'];
- $this->image_height = $D['1'];
- $this->image_type = ( ! isset($types[$D['2']])) ? 'unknown' : $types[$D['2']];
- $this->image_size_str = $D['3']; // string containing height and width
- }
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set XSS Clean
- *
- * Enables the XSS flag so that the file that was uploaded
- * will be run through the XSS filter.
- *
- * @access public
- * @param bool
- * @return void
- */
- function set_xss_clean($flag = FALSE)
- {
- $this->xss_clean = ($flag == TRUE) ? TRUE : FALSE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Validate the image
- *
- * @access public
- * @return bool
- */
- function is_image()
- {
- $img_mimes = array(
- 'image/gif',
- 'image/jpg',
- 'image/jpe',
- 'image/jpeg',
- 'image/pjpeg',
- 'image/png',
- 'image/x-png'
- );
-
-
- return (in_array($this->file_type, $img_mimes, TRUE)) ? TRUE : FALSE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Verify that the filetype is allowed
- *
- * @access public
- * @return bool
- */
- function is_allowed_filetype()
- {
- if (count($this->allowed_types) == 0)
- {
- $this->set_error('upload_no_file_types');
- return FALSE;
- }
-
- foreach ($this->allowed_types as $val)
- {
- $mime = $this->mimes_types(strtolower($val));
-
- if (is_array($mime))
- {
- if (in_array($this->file_type, $mime, TRUE))
- {
- return TRUE;
- }
- }
- else
- {
- if ($mime == $this->file_type)
- {
- return TRUE;
- }
- }
- }
-
- return FALSE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Verify that the file is within the allowed size
- *
- * @access public
- * @return bool
- */
- function is_allowed_filesize()
- {
- if ($this->max_size != 0 AND $this->file_size > $this->max_size)
- {
- return FALSE;
- }
- else
- {
- return TRUE;
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Verify that the image is within the allowed width/height
- *
- * @access public
- * @return bool
- */
- function is_allowed_dimensions()
- {
- if ( ! $this->is_image())
- {
- return TRUE;
- }
-
- if (function_exists('getimagesize'))
- {
- $D = @getimagesize($this->file_temp);
-
- if ($this->max_width > 0 AND $D['0'] > $this->max_width)
- {
- return FALSE;
- }
-
- if ($this->max_height > 0 AND $D['1'] > $this->max_height)
- {
- return FALSE;
- }
-
- return TRUE;
- }
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Validate Upload Path
- *
- * Verifies that it is a valid upload path with proper permissions.
- *
- *
- * @access public
- * @return bool
- */
- function validate_upload_path()
- {
- if ($this->upload_path == '')
- {
- $this->set_error('upload_no_filepath');
- return FALSE;
- }
-
- if (function_exists('realpath') AND @realpath($this->upload_path) !== FALSE)
- {
- $this->upload_path = str_replace("\\", "/", realpath($this->upload_path));
- }
-
- if ( ! @is_dir($this->upload_path))
- {
- $this->set_error('upload_no_filepath');
- return FALSE;
- }
-
- if ( ! is_writable($this->upload_path))
- {
- $this->set_error('upload_not_writable');
- return FALSE;
- }
-
- $this->upload_path = preg_replace("/(.+?)\/*$/", "\\1/", $this->upload_path);
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Extract the file extension
- *
- * @access public
- * @param string
- * @return string
- */
- function get_extension($filename)
- {
- $x = explode('.', $filename);
- return '.'.end($x);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Clean the file name for security
- *
- * @access public
- * @param string
- * @return string
- */
- function clean_file_name($filename)
- {
- $bad = array(
- "<!--",
- "-->",
- "'",
- "<",
- ">",
- '"',
- '&',
- '$',
- '=',
- ';',
- '?',
- '/',
- "%20",
- "%22",
- "%3c", // <
- "%253c", // <
- "%3e", // >
- "%0e", // >
- "%28", // (
- "%29", // )
- "%2528", // (
- "%26", // &
- "%24", // $
- "%3f", // ?
- "%3b", // ;
- "%3d" // =
- );
-
- foreach ($bad as $val)
- {
- $filename = str_replace($val, '', $filename);
- }
-
- return $filename;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Runs the file through the XSS clean function
- *
- * This prevents people from embedding malicious code in their files.
- * I'm not sure that it won't negatively affect certain files in unexpected ways,
- * but so far I haven't found that it causes trouble.
- *
- * @access public
- * @return void
- */
- function do_xss_clean()
- {
- $file = $this->upload_path.$this->file_name;
-
- if (filesize($file) == 0)
- {
- return FALSE;
- }
-
- if ( ! $fp = @fopen($file, 'rb'))
- {
- return FALSE;
- }
-
- flock($fp, LOCK_EX);
-
- $data = fread($fp, filesize($file));
-
- $CI =& get_instance();
- $data = $CI->input->xss_clean($data);
-
- fwrite($fp, $data);
- flock($fp, LOCK_UN);
- fclose($fp);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set an error message
- *
- * @access public
- * @param string
- * @return void
- */
- function set_error($msg)
- {
- $CI =& get_instance();
- $CI->lang->load('upload');
-
- if (is_array($msg))
- {
- foreach ($msg as $val)
- {
- $msg = ($CI->lang->line($val) == FALSE) ? $val : $CI->lang->line($val);
- $this->error_msg[] = $msg;
- log_message('error', $msg);
- }
- }
- else
- {
- $msg = ($CI->lang->line($msg) == FALSE) ? $msg : $CI->lang->line($msg);
- $this->error_msg[] = $msg;
- log_message('error', $msg);
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Display the error message
- *
- * @access public
- * @param string
- * @param string
- * @return string
- */
- function display_errors($open = '<p>', $close = '</p>')
- {
- $str = '';
- foreach ($this->error_msg as $val)
- {
- $str .= $open.$val.$close;
- }
-
- return $str;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * List of Mime Types
- *
- * This is a list of mime types. We use it to validate
- * the "allowed types" set by the developer
- *
- * @access public
- * @param string
- * @return string
- */
- function mimes_types($mime)
- {
- if (count($this->mimes) == 0)
- {
- if (@include(APPPATH.'config/mimes'.EXT))
- {
- $this->mimes = $mimes;
- unset($mimes);
- }
- }
-
- return ( ! isset($this->mimes[$mime])) ? FALSE : $this->mimes[$mime];
- }
-
-}
-// END Upload Class
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * File Uploading Class
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category Uploads
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/libraries/file_uploading.html
+ */
+class CI_Upload {
+
+ var $max_size = 0;
+ var $max_width = 0;
+ var $max_height = 0;
+ var $allowed_types = "";
+ var $file_temp = "";
+ var $file_name = "";
+ var $orig_name = "";
+ var $file_type = "";
+ var $file_size = "";
+ var $file_ext = "";
+ var $upload_path = "";
+ var $overwrite = FALSE;
+ var $encrypt_name = FALSE;
+ var $is_image = FALSE;
+ var $image_width = '';
+ var $image_height = '';
+ var $image_type = '';
+ var $image_size_str = '';
+ var $error_msg = array();
+ var $mimes = array();
+ var $remove_spaces = TRUE;
+ var $xss_clean = FALSE;
+ var $temp_prefix = "temp_file_";
+
+ /**
+ * Constructor
+ *
+ * @access public
+ */
+ function CI_Upload($props = array())
+ {
+ if (count($props) > 0)
+ {
+ $this->initialize($props);
+ }
+
+ log_message('debug', "Upload Class Initialized");
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Initialize preferences
+ *
+ * @access public
+ * @param array
+ * @return void
+ */
+ function initialize($config = array())
+ {
+ $defaults = array(
+ 'max_size' => 0,
+ 'max_width' => 0,
+ 'max_height' => 0,
+ 'allowed_types' => "",
+ 'file_temp' => "",
+ 'file_name' => "",
+ 'orig_name' => "",
+ 'file_type' => "",
+ 'file_size' => "",
+ 'file_ext' => "",
+ 'upload_path' => "",
+ 'overwrite' => FALSE,
+ 'encrypt_name' => FALSE,
+ 'is_image' => FALSE,
+ 'image_width' => '',
+ 'image_height' => '',
+ 'image_type' => '',
+ 'image_size_str' => '',
+ 'error_msg' => array(),
+ 'mimes' => array(),
+ 'remove_spaces' => TRUE,
+ 'xss_clean' => FALSE,
+ 'temp_prefix' => "temp_file_"
+ );
+
+
+ foreach ($defaults as $key => $val)
+ {
+ if (isset($config[$key]))
+ {
+ $method = 'set_'.$key;
+ if (method_exists($this, $method))
+ {
+ $this->$method($config[$key]);
+ }
+ else
+ {
+ $this->$key = $config[$key];
+ }
+ }
+ else
+ {
+ $this->$key = $val;
+ }
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Perform the file upload
+ *
+ * @access public
+ * @return bool
+ */
+ function do_upload($field = 'userfile')
+ {
+ // Is $_FILES[$field] set? If not, no reason to continue.
+ if ( ! isset($_FILES[$field]))
+ {
+ $this->set_error('upload_userfile_not_set');
+ return FALSE;
+ }
+
+ // Is the upload path valid?
+ if ( ! $this->validate_upload_path())
+ {
+ return FALSE;
+ }
+
+ // Was the file able to be uploaded? If not, determine the reason why.
+ if ( ! is_uploaded_file($_FILES[$field]['tmp_name']))
+ {
+ $error = ( ! isset($_FILES[$field]['error'])) ? 4 : $_FILES[$field]['error'];
+
+ switch($error)
+ {
+ case 1 : $this->set_error('upload_file_exceeds_limit');
+ break;
+ case 3 : $this->set_error('upload_file_partial');
+ break;
+ case 4 : $this->set_error('upload_no_file_selected');
+ break;
+ default : $this->set_error('upload_no_file_selected');
+ break;
+ }
+
+ return FALSE;
+ }
+
+ // Set the uploaded data as class variables
+ $this->file_temp = $_FILES[$field]['tmp_name'];
+ $this->file_name = $_FILES[$field]['name'];
+ $this->file_size = $_FILES[$field]['size'];
+ $this->file_type = preg_replace("/^(.+?);.*$/", "\\1", $_FILES[$field]['type']);
+ $this->file_type = strtolower($this->file_type);
+ $this->file_ext = $this->get_extension($_FILES[$field]['name']);
+
+ // Convert the file size to kilobytes
+ if ($this->file_size > 0)
+ {
+ $this->file_size = round($this->file_size/1024, 2);
+ }
+
+ // Is the file type allowed to be uploaded?
+ if ( ! $this->is_allowed_filetype())
+ {
+ $this->set_error('upload_invalid_filetype');
+ return FALSE;
+ }
+
+ // Is the file size within the allowed maximum?
+ if ( ! $this->is_allowed_filesize())
+ {
+ $this->set_error('upload_invalid_filesize');
+ return FALSE;
+ }
+
+ // Are the image dimensions within the allowed size?
+ // Note: This can fail if the server has an open_basdir restriction.
+ if ( ! $this->is_allowed_dimensions())
+ {
+ $this->set_error('upload_invalid_dimensions');
+ return FALSE;
+ }
+
+ // Sanitize the file name for security
+ $this->file_name = $this->clean_file_name($this->file_name);
+
+ // Remove white spaces in the name
+ if ($this->remove_spaces == TRUE)
+ {
+ $this->file_name = preg_replace("/\s+/", "_", $this->file_name);
+ }
+
+ /*
+ * Validate the file name
+ * This function appends an number onto the end of
+ * the file if one with the same name already exists.
+ * If it returns false there was a problem.
+ */
+ $this->orig_name = $this->file_name;
+
+ if ($this->overwrite == FALSE)
+ {
+ $this->file_name = $this->set_filename($this->upload_path, $this->file_name);
+
+ if ($this->file_name === FALSE)
+ {
+ return FALSE;
+ }
+ }
+
+ /*
+ * Move the file to the final destination
+ * To deal with different server configurations
+ * we'll attempt to use copy() first. If that fails
+ * we'll use move_uploaded_file(). One of the two should
+ * reliably work in most environments
+ */
+ if ( ! @copy($this->file_temp, $this->upload_path.$this->file_name))
+ {
+ if ( ! @move_uploaded_file($this->file_temp, $this->upload_path.$this->file_name))
+ {
+ $this->set_error('upload_destination_error');
+ return FALSE;
+ }
+ }
+
+ /*
+ * Run the file through the XSS hacking filter
+ * This helps prevent malicious code from being
+ * embedded within a file. Scripts can easily
+ * be disguised as images or other file types.
+ */
+ if ($this->xss_clean == TRUE)
+ {
+ $this->do_xss_clean();
+ }
+
+ /*
+ * Set the finalized image dimensions
+ * This sets the image width/height (assuming the
+ * file was an image). We use this information
+ * in the "data" function.
+ */
+ $this->set_image_properties($this->upload_path.$this->file_name);
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Finalized Data Array
+ *
+ * Returns an associative array containing all of the information
+ * related to the upload, allowing the developer easy access in one array.
+ *
+ * @access public
+ * @return array
+ */
+ function data()
+ {
+ return array (
+ 'file_name' => $this->file_name,
+ 'file_type' => $this->file_type,
+ 'file_path' => $this->upload_path,
+ 'full_path' => $this->upload_path.$this->file_name,
+ 'raw_name' => str_replace($this->file_ext, '', $this->file_name),
+ 'orig_name' => $this->orig_name,
+ 'file_ext' => $this->file_ext,
+ 'file_size' => $this->file_size,
+ 'is_image' => $this->is_image(),
+ 'image_width' => $this->image_width,
+ 'image_height' => $this->image_height,
+ 'image_type' => $this->image_type,
+ 'image_size_str' => $this->image_size_str,
+ );
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Upload Path
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function set_upload_path($path)
+ {
+ $this->upload_path = $path;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set the file name
+ *
+ * This function takes a filename/path as input and looks for the
+ * existence of a file with the same name. If found, it will append a
+ * number to the end of the filename to avoid overwriting a pre-existing file.
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return string
+ */
+ function set_filename($path, $filename)
+ {
+ if ($this->encrypt_name == TRUE)
+ {
+ mt_srand();
+ $filename = md5(uniqid(mt_rand())).$this->file_ext;
+ }
+
+ if ( ! file_exists($path.$filename))
+ {
+ return $filename;
+ }
+
+ $filename = str_replace($this->file_ext, '', $filename);
+
+ $new_filename = '';
+ for ($i = 1; $i < 100; $i++)
+ {
+ if ( ! file_exists($path.$filename.$i.$this->file_ext))
+ {
+ $new_filename = $filename.$i.$this->file_ext;
+ break;
+ }
+ }
+
+ if ($new_filename == '')
+ {
+ $this->set_error('upload_bad_filename');
+ return FALSE;
+ }
+ else
+ {
+ return $new_filename;
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Maximum File Size
+ *
+ * @access public
+ * @param integer
+ * @return void
+ */
+ function set_max_filesize($n)
+ {
+ $this->max_size = ( ! eregi("^[[:digit:]]+$", $n)) ? 0 : $n;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Maximum Image Width
+ *
+ * @access public
+ * @param integer
+ * @return void
+ */
+ function set_max_width($n)
+ {
+ $this->max_width = ( ! eregi("^[[:digit:]]+$", $n)) ? 0 : $n;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Maximum Image Height
+ *
+ * @access public
+ * @param integer
+ * @return void
+ */
+ function set_max_height($n)
+ {
+ $this->max_height = ( ! eregi("^[[:digit:]]+$", $n)) ? 0 : $n;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Allowed File Types
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function set_allowed_types($types)
+ {
+ $this->allowed_types = explode('|', $types);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Image Properties
+ *
+ * Uses GD to determine the width/height/type of image
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function set_image_properties($path = '')
+ {
+ if ( ! $this->is_image())
+ {
+ return;
+ }
+
+ if (function_exists('getimagesize'))
+ {
+ if (FALSE !== ($D = @getimagesize($path)))
+ {
+ $types = array(1 => 'gif', 2 => 'jpeg', 3 => 'png');
+
+ $this->image_width = $D['0'];
+ $this->image_height = $D['1'];
+ $this->image_type = ( ! isset($types[$D['2']])) ? 'unknown' : $types[$D['2']];
+ $this->image_size_str = $D['3']; // string containing height and width
+ }
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set XSS Clean
+ *
+ * Enables the XSS flag so that the file that was uploaded
+ * will be run through the XSS filter.
+ *
+ * @access public
+ * @param bool
+ * @return void
+ */
+ function set_xss_clean($flag = FALSE)
+ {
+ $this->xss_clean = ($flag == TRUE) ? TRUE : FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Validate the image
+ *
+ * @access public
+ * @return bool
+ */
+ function is_image()
+ {
+ $img_mimes = array(
+ 'image/gif',
+ 'image/jpg',
+ 'image/jpe',
+ 'image/jpeg',
+ 'image/pjpeg',
+ 'image/png',
+ 'image/x-png'
+ );
+
+
+ return (in_array($this->file_type, $img_mimes, TRUE)) ? TRUE : FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Verify that the filetype is allowed
+ *
+ * @access public
+ * @return bool
+ */
+ function is_allowed_filetype()
+ {
+ if (count($this->allowed_types) == 0)
+ {
+ $this->set_error('upload_no_file_types');
+ return FALSE;
+ }
+
+ foreach ($this->allowed_types as $val)
+ {
+ $mime = $this->mimes_types(strtolower($val));
+
+ if (is_array($mime))
+ {
+ if (in_array($this->file_type, $mime, TRUE))
+ {
+ return TRUE;
+ }
+ }
+ else
+ {
+ if ($mime == $this->file_type)
+ {
+ return TRUE;
+ }
+ }
+ }
+
+ return FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Verify that the file is within the allowed size
+ *
+ * @access public
+ * @return bool
+ */
+ function is_allowed_filesize()
+ {
+ if ($this->max_size != 0 AND $this->file_size > $this->max_size)
+ {
+ return FALSE;
+ }
+ else
+ {
+ return TRUE;
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Verify that the image is within the allowed width/height
+ *
+ * @access public
+ * @return bool
+ */
+ function is_allowed_dimensions()
+ {
+ if ( ! $this->is_image())
+ {
+ return TRUE;
+ }
+
+ if (function_exists('getimagesize'))
+ {
+ $D = @getimagesize($this->file_temp);
+
+ if ($this->max_width > 0 AND $D['0'] > $this->max_width)
+ {
+ return FALSE;
+ }
+
+ if ($this->max_height > 0 AND $D['1'] > $this->max_height)
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Validate Upload Path
+ *
+ * Verifies that it is a valid upload path with proper permissions.
+ *
+ *
+ * @access public
+ * @return bool
+ */
+ function validate_upload_path()
+ {
+ if ($this->upload_path == '')
+ {
+ $this->set_error('upload_no_filepath');
+ return FALSE;
+ }
+
+ if (function_exists('realpath') AND @realpath($this->upload_path) !== FALSE)
+ {
+ $this->upload_path = str_replace("\\", "/", realpath($this->upload_path));
+ }
+
+ if ( ! @is_dir($this->upload_path))
+ {
+ $this->set_error('upload_no_filepath');
+ return FALSE;
+ }
+
+ if ( ! is_writable($this->upload_path))
+ {
+ $this->set_error('upload_not_writable');
+ return FALSE;
+ }
+
+ $this->upload_path = preg_replace("/(.+?)\/*$/", "\\1/", $this->upload_path);
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Extract the file extension
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function get_extension($filename)
+ {
+ $x = explode('.', $filename);
+ return '.'.end($x);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Clean the file name for security
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function clean_file_name($filename)
+ {
+ $bad = array(
+ "<!--",
+ "-->",
+ "'",
+ "<",
+ ">",
+ '"',
+ '&',
+ '$',
+ '=',
+ ';',
+ '?',
+ '/',
+ "%20",
+ "%22",
+ "%3c", // <
+ "%253c", // <
+ "%3e", // >
+ "%0e", // >
+ "%28", // (
+ "%29", // )
+ "%2528", // (
+ "%26", // &
+ "%24", // $
+ "%3f", // ?
+ "%3b", // ;
+ "%3d" // =
+ );
+
+ foreach ($bad as $val)
+ {
+ $filename = str_replace($val, '', $filename);
+ }
+
+ return $filename;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Runs the file through the XSS clean function
+ *
+ * This prevents people from embedding malicious code in their files.
+ * I'm not sure that it won't negatively affect certain files in unexpected ways,
+ * but so far I haven't found that it causes trouble.
+ *
+ * @access public
+ * @return void
+ */
+ function do_xss_clean()
+ {
+ $file = $this->upload_path.$this->file_name;
+
+ if (filesize($file) == 0)
+ {
+ return FALSE;
+ }
+
+ if ( ! $fp = @fopen($file, 'rb'))
+ {
+ return FALSE;
+ }
+
+ flock($fp, LOCK_EX);
+
+ $data = fread($fp, filesize($file));
+
+ $CI =& get_instance();
+ $data = $CI->input->xss_clean($data);
+
+ fwrite($fp, $data);
+ flock($fp, LOCK_UN);
+ fclose($fp);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set an error message
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ function set_error($msg)
+ {
+ $CI =& get_instance();
+ $CI->lang->load('upload');
+
+ if (is_array($msg))
+ {
+ foreach ($msg as $val)
+ {
+ $msg = ($CI->lang->line($val) == FALSE) ? $val : $CI->lang->line($val);
+ $this->error_msg[] = $msg;
+ log_message('error', $msg);
+ }
+ }
+ else
+ {
+ $msg = ($CI->lang->line($msg) == FALSE) ? $msg : $CI->lang->line($msg);
+ $this->error_msg[] = $msg;
+ log_message('error', $msg);
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Display the error message
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return string
+ */
+ function display_errors($open = '<p>', $close = '</p>')
+ {
+ $str = '';
+ foreach ($this->error_msg as $val)
+ {
+ $str .= $open.$val.$close;
+ }
+
+ return $str;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * List of Mime Types
+ *
+ * This is a list of mime types. We use it to validate
+ * the "allowed types" set by the developer
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function mimes_types($mime)
+ {
+ if (count($this->mimes) == 0)
+ {
+ if (@include(APPPATH.'config/mimes'.EXT))
+ {
+ $this->mimes = $mimes;
+ unset($mimes);
+ }
+ }
+
+ return ( ! isset($this->mimes[$mime])) ? FALSE : $this->mimes[$mime];
+ }
+
+}
+// END Upload Class
?> \ No newline at end of file
diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php
index afd012e30..b93bd340e 100644
--- a/system/libraries/User_agent.php
+++ b/system/libraries/User_agent.php
@@ -1,12 +1,12 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
- * Code Igniter
+ * CodeIgniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
* @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
* @license http://www.codeignitor.com/user_guide/license.html
* @link http://www.codeigniter.com
* @since Version 1.0
diff --git a/system/libraries/Validation.php b/system/libraries/Validation.php
index ec7e412c6..7ad8509a3 100644
--- a/system/libraries/Validation.php
+++ b/system/libraries/Validation.php
@@ -1,735 +1,735 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Validation Class
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Validation
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/libraries/validation.html
- */
-class CI_Validation {
-
- var $CI;
- var $error_string = '';
- var $_error_array = array();
- var $_rules = array();
- var $_fields = array();
- var $_error_messages = array();
- var $_current_field = '';
- var $_safe_form_data = FALSE;
- var $_error_prefix = '<p>';
- var $_error_suffix = '</p>';
-
-
-
- /**
- * Constructor
- *
- */
- function CI_Validation()
- {
- $this->CI =& get_instance();
- log_message('debug', "Validation Class Initialized");
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Fields
- *
- * This function takes an array of field names as input
- * and generates class variables with the same name, which will
- * either be blank or contain the $_POST value corresponding to it
- *
- * @access public
- * @param string
- * @param string
- * @return void
- */
- function set_fields($data = '', $field = '')
- {
- if ($data == '')
- {
- if (count($this->_fields) == 0)
- {
- return FALSE;
- }
- }
- else
- {
- if ( ! is_array($data))
- {
- $data = array($data => $field);
- }
-
- if (count($data) > 0)
- {
- $this->_fields = $data;
- }
- }
-
- foreach($this->_fields as $key => $val)
- {
- $this->$key = ( ! isset($_POST[$key]) OR is_array($_POST[$key])) ? '' : $this->prep_for_form($_POST[$key]);
-
- $error = $key.'_error';
- if ( ! isset($this->$error))
- {
- $this->$error = '';
- }
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Rules
- *
- * This function takes an array of field names and validation
- * rules as input ad simply stores is for use later.
- *
- * @access public
- * @param mixed
- * @param string
- * @return void
- */
- function set_rules($data, $rules = '')
- {
- if ( ! is_array($data))
- {
- if ($rules == '')
- return;
-
- $data[$data] = $rules;
- }
-
- foreach ($data as $key => $val)
- {
- $this->_rules[$key] = $val;
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Error Message
- *
- * Lets users set their own error messages on the fly. Note: The key
- * name has to match the function name that it corresponds to.
- *
- * @access public
- * @param string
- * @param string
- * @return string
- */
- function set_message($lang, $val = '')
- {
- if ( ! is_array($lang))
- {
- $lang = array($lang => $val);
- }
-
- $this->_error_messages = array_merge($this->_error_messages, $lang);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set The Error Delimiter
- *
- * Permits a prefix/suffix to be added to each error message
- *
- * @access public
- * @param string
- * @param string
- * @return void
- */
- function set_error_delimiters($prefix = '<p>', $suffix = '</p>')
- {
- $this->_error_prefix = $prefix;
- $this->_error_suffix = $suffix;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Run the Validator
- *
- * This function does all the work.
- *
- * @access public
- * @return bool
- */
- function run()
- {
- // Do we even have any data to process? Mm?
- if (count($_POST) == 0 OR count($this->_rules) == 0)
- {
- return FALSE;
- }
-
- // Load the language file containing error messages
- $this->CI->lang->load('validation');
-
- // Cycle through the rules and test for errors
- foreach ($this->_rules as $field => $rules)
- {
- //Explode out the rules!
- $ex = explode('|', $rules);
-
- // Is the field required? If not, if the field is blank we'll move on to the next text
- if ( ! in_array('required', $ex, TRUE) AND strpos($rules, 'callback_') === FALSE)
- {
- if ( ! isset($_POST[$field]) OR $_POST[$field] == '')
- {
- continue;
- }
- }
-
- /*
- * Are we dealing with an "isset" rule?
- *
- * Before going further, we'll see if one of the rules
- * is to check whether the item is set (typically this
- * applies only to checkboxes). If so, we'll
- * test for it here since there's not reason to go
- * further
- */
- if ( ! isset($_POST[$field]))
- {
- if (in_array('isset', $ex, TRUE) OR in_array('required', $ex))
- {
- if ( ! isset($this->_error_messages['isset']))
- {
- if (FALSE === ($line = $this->CI->lang->line('isset')))
- {
- $line = 'The field was not set';
- }
- }
- else
- {
- $line = $this->_error_messages['isset'];
- }
-
- $field = ( ! isset($this->_fields[$field])) ? $field : $this->_fields[$field];
- $this->_error_array[] = sprintf($line, $field);
- }
-
- continue;
- }
-
- /*
- * Set the current field
- *
- * The various prepping functions need to know the
- * current field name so they can do this:
- *
- * $_POST[$this->_current_field] == 'bla bla';
- */
- $this->_current_field = $field;
-
- // Cycle through the rules!
- foreach ($ex As $rule)
- {
- // Is the rule a callback?
- $callback = FALSE;
- if (substr($rule, 0, 9) == 'callback_')
- {
- $rule = substr($rule, 9);
- $callback = TRUE;
- }
-
- // Strip the parameter (if exists) from the rule
- // Rules can contain a parameter: max_length[5]
- $param = FALSE;
- if (preg_match("/(.*?)\[(.*?)\]/", $rule, $match))
- {
- $rule = $match[1];
- $param = $match[2];
- }
-
- // Call the function that corresponds to the rule
- if ($callback === TRUE)
- {
- if ( ! method_exists($this->CI, $rule))
- {
- continue;
- }
-
- $result = $this->CI->$rule($_POST[$field], $param);
-
- // If the field isn't required and we just processed a callback we'll move on...
- if ( ! in_array('required', $ex, TRUE) AND $result !== FALSE)
- {
- continue 2;
- }
-
- }
- else
- {
- if ( ! method_exists($this, $rule))
- {
- /*
- * Run the native PHP function if called for
- *
- * If our own wrapper function doesn't exist we see
- * if a native PHP function does. Users can use
- * any native PHP function call that has one param.
- */
- if (function_exists($rule))
- {
- $_POST[$field] = $rule($_POST[$field]);
- $this->$field = $_POST[$field];
- }
-
- continue;
- }
-
- $result = $this->$rule($_POST[$field], $param);
- }
-
- // Did the rule test negatively? If so, grab the error.
- if ($result === FALSE)
- {
- if ( ! isset($this->_error_messages[$rule]))
- {
- if (FALSE === ($line = $this->CI->lang->line($rule)))
- {
- $line = 'Unable to access an error message corresponding to your field name.';
- }
- }
- else
- {
- $line = $this->_error_messages[$rule];;
- }
-
- // Build the error message
- $mfield = ( ! isset($this->_fields[$field])) ? $field : $this->_fields[$field];
- $mparam = ( ! isset($this->_fields[$param])) ? $param : $this->_fields[$param];
- $message = sprintf($line, $mfield, $mparam);
-
- // Set the error variable. Example: $this->username_error
- $error = $field.'_error';
- $this->$error = $this->_error_prefix.$message.$this->_error_suffix;
-
- // Add the error to the error array
- $this->_error_array[] = $message;
- continue 2;
- }
- }
-
- }
-
- $total_errors = count($this->_error_array);
-
- /*
- * Recompile the class variables
- *
- * If any prepping functions were called the $_POST data
- * might now be different then the corresponding class
- * variables so we'll set them anew.
- */
- if ($total_errors > 0)
- {
- $this->_safe_form_data = TRUE;
- }
-
- $this->set_fields();
-
- // Did we end up with any errors?
- if ($total_errors == 0)
- {
- return TRUE;
- }
-
- // Generate the error string
- foreach ($this->_error_array as $val)
- {
- $this->error_string .= $this->_error_prefix.$val.$this->_error_suffix."\n";
- }
-
- return FALSE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Required
- *
- * @access public
- * @param string
- * @return bool
- */
- function required($str)
- {
- if ( ! is_array($str))
- {
- return (trim($str) == '') ? FALSE : TRUE;
- }
- else
- {
- return ( ! empty($str));
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Match one field to another
- *
- * @access public
- * @param string
- * @return bool
- */
- function matches($str, $field)
- {
- if ( ! isset($_POST[$field]))
- {
- return FALSE;
- }
-
- return ($str !== $_POST[$field]) ? FALSE : TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Minimum Length
- *
- * @access public
- * @param string
- * @return bool
- */
- function min_length($str, $val)
- {
- if ( ! is_numeric($val))
- {
- return FALSE;
- }
-
- return (strlen($str) < $val) ? FALSE : TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Max Length
- *
- * @access public
- * @param string
- * @return bool
- */
- function max_length($str, $val)
- {
- if ( ! is_numeric($val))
- {
- return FALSE;
- }
-
- return (strlen($str) > $val) ? FALSE : TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Exact Length
- *
- * @access public
- * @param string
- * @return bool
- */
- function exact_length($str, $val)
- {
- if ( ! is_numeric($val))
- {
- return FALSE;
- }
-
- return (strlen($str) != $val) ? FALSE : TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Valid Email
- *
- * @access public
- * @param string
- * @return bool
- */
- function valid_email($str)
- {
- return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Validate IP Address
- *
- * @access public
- * @param string
- * @return string
- */
- function valid_ip($ip)
- {
- return ( ! preg_match( "/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/", $ip)) ? FALSE : TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Alpha
- *
- * @access public
- * @param string
- * @return bool
- */
- function alpha($str)
- {
- return ( ! preg_match("/^([-a-z])+$/i", $str)) ? FALSE : TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Alpha-numeric
- *
- * @access public
- * @param string
- * @return bool
- */
- function alpha_numeric($str)
- {
- return ( ! preg_match("/^([-a-z0-9])+$/i", $str)) ? FALSE : TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Alpha-numeric with underscores and dashes
- *
- * @access public
- * @param string
- * @return bool
- */
- function alpha_dash($str)
- {
- return ( ! preg_match("/^([-a-z0-9_-])+$/i", $str)) ? FALSE : TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Numeric
- *
- * @access public
- * @param int
- * @return bool
- */
- function numeric($str)
- {
- return ( ! ereg("^[0-9\.]+$", $str)) ? FALSE : TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Is Numeric
- *
- * @access public
- * @param string
- * @return bool
- */
- function is_numeric($str)
- {
- return ( ! is_numeric($str)) ? FALSE : TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Select
- *
- * Enables pull-down lists to be set to the value the user
- * selected in the event of an error
- *
- * @access public
- * @param string
- * @param string
- * @return string
- */
- function set_select($field = '', $value = '')
- {
- if ($field == '' OR $value == '' OR ! isset($_POST[$field]))
- {
- return '';
- }
-
- if ($_POST[$field] == $value)
- {
- return ' selected="selected"';
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Radio
- *
- * Enables radio buttons to be set to the value the user
- * selected in the event of an error
- *
- * @access public
- * @param string
- * @param string
- * @return string
- */
- function set_radio($field = '', $value = '')
- {
- if ($field == '' OR $value == '' OR ! isset($_POST[$field]))
- {
- return '';
- }
-
- if ($_POST[$field] == $value)
- {
- return ' checked="checked"';
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Set Checkbox
- *
- * Enables checkboxes to be set to the value the user
- * selected in the event of an error
- *
- * @access public
- * @param string
- * @param string
- * @return string
- */
- function set_checkbox($field = '', $value = '')
- {
- if ($field == '' OR $value == '' OR ! isset($_POST[$field]))
- {
- return '';
- }
-
- if ($_POST[$field] == $value)
- {
- return ' checked="checked"';
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Prep data for form
- *
- * This function allows HTML to be safely shown in a form.
- * Special characters are converted.
- *
- * @access public
- * @param string
- * @return string
- */
- function prep_for_form($str = '')
- {
- if ($this->_safe_form_data == FALSE OR $str == '')
- {
- return $str;
- }
-
- return str_replace(array("'", '"', '<', '>'), array("&#39;", "&quot;", '&lt;', '&gt;'), stripslashes($str));
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Prep URL
- *
- * @access public
- * @param string
- * @return string
- */
- function prep_url($str = '')
- {
- if ($str == 'http://' OR $str == '')
- {
- $_POST[$this->_current_field] = '';
- return;
- }
-
- if (substr($str, 0, 7) != 'http://' && substr($str, 0, 8) != 'https://')
- {
- $str = 'http://'.$str;
- }
-
- $_POST[$this->_current_field] = $str;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Strip Image Tags
- *
- * @access public
- * @param string
- * @return string
- */
- function strip_image_tags($str)
- {
- $_POST[$this->_current_field] = $this->input->strip_image_tags($str);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * XSS Clean
- *
- * @access public
- * @param string
- * @return string
- */
- function xss_clean($str)
- {
- $_POST[$this->_current_field] = $this->CI->input->xss_clean($str);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Convert PHP tags to entities
- *
- * @access public
- * @param string
- * @return string
- */
- function encode_php_tags($str)
- {
- $_POST[$this->_current_field] = str_replace(array('<?php', '<?PHP', '<?', '?>'), array('&lt;?php', '&lt;?PHP', '&lt;?', '?&gt;'), $str);
- }
-
-}
-// END Validation Class
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Validation Class
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category Validation
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/libraries/validation.html
+ */
+class CI_Validation {
+
+ var $CI;
+ var $error_string = '';
+ var $_error_array = array();
+ var $_rules = array();
+ var $_fields = array();
+ var $_error_messages = array();
+ var $_current_field = '';
+ var $_safe_form_data = FALSE;
+ var $_error_prefix = '<p>';
+ var $_error_suffix = '</p>';
+
+
+
+ /**
+ * Constructor
+ *
+ */
+ function CI_Validation()
+ {
+ $this->CI =& get_instance();
+ log_message('debug', "Validation Class Initialized");
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Fields
+ *
+ * This function takes an array of field names as input
+ * and generates class variables with the same name, which will
+ * either be blank or contain the $_POST value corresponding to it
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return void
+ */
+ function set_fields($data = '', $field = '')
+ {
+ if ($data == '')
+ {
+ if (count($this->_fields) == 0)
+ {
+ return FALSE;
+ }
+ }
+ else
+ {
+ if ( ! is_array($data))
+ {
+ $data = array($data => $field);
+ }
+
+ if (count($data) > 0)
+ {
+ $this->_fields = $data;
+ }
+ }
+
+ foreach($this->_fields as $key => $val)
+ {
+ $this->$key = ( ! isset($_POST[$key]) OR is_array($_POST[$key])) ? '' : $this->prep_for_form($_POST[$key]);
+
+ $error = $key.'_error';
+ if ( ! isset($this->$error))
+ {
+ $this->$error = '';
+ }
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Rules
+ *
+ * This function takes an array of field names and validation
+ * rules as input ad simply stores is for use later.
+ *
+ * @access public
+ * @param mixed
+ * @param string
+ * @return void
+ */
+ function set_rules($data, $rules = '')
+ {
+ if ( ! is_array($data))
+ {
+ if ($rules == '')
+ return;
+
+ $data[$data] = $rules;
+ }
+
+ foreach ($data as $key => $val)
+ {
+ $this->_rules[$key] = $val;
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Error Message
+ *
+ * Lets users set their own error messages on the fly. Note: The key
+ * name has to match the function name that it corresponds to.
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return string
+ */
+ function set_message($lang, $val = '')
+ {
+ if ( ! is_array($lang))
+ {
+ $lang = array($lang => $val);
+ }
+
+ $this->_error_messages = array_merge($this->_error_messages, $lang);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set The Error Delimiter
+ *
+ * Permits a prefix/suffix to be added to each error message
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return void
+ */
+ function set_error_delimiters($prefix = '<p>', $suffix = '</p>')
+ {
+ $this->_error_prefix = $prefix;
+ $this->_error_suffix = $suffix;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Run the Validator
+ *
+ * This function does all the work.
+ *
+ * @access public
+ * @return bool
+ */
+ function run()
+ {
+ // Do we even have any data to process? Mm?
+ if (count($_POST) == 0 OR count($this->_rules) == 0)
+ {
+ return FALSE;
+ }
+
+ // Load the language file containing error messages
+ $this->CI->lang->load('validation');
+
+ // Cycle through the rules and test for errors
+ foreach ($this->_rules as $field => $rules)
+ {
+ //Explode out the rules!
+ $ex = explode('|', $rules);
+
+ // Is the field required? If not, if the field is blank we'll move on to the next text
+ if ( ! in_array('required', $ex, TRUE) AND strpos($rules, 'callback_') === FALSE)
+ {
+ if ( ! isset($_POST[$field]) OR $_POST[$field] == '')
+ {
+ continue;
+ }
+ }
+
+ /*
+ * Are we dealing with an "isset" rule?
+ *
+ * Before going further, we'll see if one of the rules
+ * is to check whether the item is set (typically this
+ * applies only to checkboxes). If so, we'll
+ * test for it here since there's not reason to go
+ * further
+ */
+ if ( ! isset($_POST[$field]))
+ {
+ if (in_array('isset', $ex, TRUE) OR in_array('required', $ex))
+ {
+ if ( ! isset($this->_error_messages['isset']))
+ {
+ if (FALSE === ($line = $this->CI->lang->line('isset')))
+ {
+ $line = 'The field was not set';
+ }
+ }
+ else
+ {
+ $line = $this->_error_messages['isset'];
+ }
+
+ $field = ( ! isset($this->_fields[$field])) ? $field : $this->_fields[$field];
+ $this->_error_array[] = sprintf($line, $field);
+ }
+
+ continue;
+ }
+
+ /*
+ * Set the current field
+ *
+ * The various prepping functions need to know the
+ * current field name so they can do this:
+ *
+ * $_POST[$this->_current_field] == 'bla bla';
+ */
+ $this->_current_field = $field;
+
+ // Cycle through the rules!
+ foreach ($ex As $rule)
+ {
+ // Is the rule a callback?
+ $callback = FALSE;
+ if (substr($rule, 0, 9) == 'callback_')
+ {
+ $rule = substr($rule, 9);
+ $callback = TRUE;
+ }
+
+ // Strip the parameter (if exists) from the rule
+ // Rules can contain a parameter: max_length[5]
+ $param = FALSE;
+ if (preg_match("/(.*?)\[(.*?)\]/", $rule, $match))
+ {
+ $rule = $match[1];
+ $param = $match[2];
+ }
+
+ // Call the function that corresponds to the rule
+ if ($callback === TRUE)
+ {
+ if ( ! method_exists($this->CI, $rule))
+ {
+ continue;
+ }
+
+ $result = $this->CI->$rule($_POST[$field], $param);
+
+ // If the field isn't required and we just processed a callback we'll move on...
+ if ( ! in_array('required', $ex, TRUE) AND $result !== FALSE)
+ {
+ continue 2;
+ }
+
+ }
+ else
+ {
+ if ( ! method_exists($this, $rule))
+ {
+ /*
+ * Run the native PHP function if called for
+ *
+ * If our own wrapper function doesn't exist we see
+ * if a native PHP function does. Users can use
+ * any native PHP function call that has one param.
+ */
+ if (function_exists($rule))
+ {
+ $_POST[$field] = $rule($_POST[$field]);
+ $this->$field = $_POST[$field];
+ }
+
+ continue;
+ }
+
+ $result = $this->$rule($_POST[$field], $param);
+ }
+
+ // Did the rule test negatively? If so, grab the error.
+ if ($result === FALSE)
+ {
+ if ( ! isset($this->_error_messages[$rule]))
+ {
+ if (FALSE === ($line = $this->CI->lang->line($rule)))
+ {
+ $line = 'Unable to access an error message corresponding to your field name.';
+ }
+ }
+ else
+ {
+ $line = $this->_error_messages[$rule];;
+ }
+
+ // Build the error message
+ $mfield = ( ! isset($this->_fields[$field])) ? $field : $this->_fields[$field];
+ $mparam = ( ! isset($this->_fields[$param])) ? $param : $this->_fields[$param];
+ $message = sprintf($line, $mfield, $mparam);
+
+ // Set the error variable. Example: $this->username_error
+ $error = $field.'_error';
+ $this->$error = $this->_error_prefix.$message.$this->_error_suffix;
+
+ // Add the error to the error array
+ $this->_error_array[] = $message;
+ continue 2;
+ }
+ }
+
+ }
+
+ $total_errors = count($this->_error_array);
+
+ /*
+ * Recompile the class variables
+ *
+ * If any prepping functions were called the $_POST data
+ * might now be different then the corresponding class
+ * variables so we'll set them anew.
+ */
+ if ($total_errors > 0)
+ {
+ $this->_safe_form_data = TRUE;
+ }
+
+ $this->set_fields();
+
+ // Did we end up with any errors?
+ if ($total_errors == 0)
+ {
+ return TRUE;
+ }
+
+ // Generate the error string
+ foreach ($this->_error_array as $val)
+ {
+ $this->error_string .= $this->_error_prefix.$val.$this->_error_suffix."\n";
+ }
+
+ return FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Required
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function required($str)
+ {
+ if ( ! is_array($str))
+ {
+ return (trim($str) == '') ? FALSE : TRUE;
+ }
+ else
+ {
+ return ( ! empty($str));
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Match one field to another
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function matches($str, $field)
+ {
+ if ( ! isset($_POST[$field]))
+ {
+ return FALSE;
+ }
+
+ return ($str !== $_POST[$field]) ? FALSE : TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Minimum Length
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function min_length($str, $val)
+ {
+ if ( ! is_numeric($val))
+ {
+ return FALSE;
+ }
+
+ return (strlen($str) < $val) ? FALSE : TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Max Length
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function max_length($str, $val)
+ {
+ if ( ! is_numeric($val))
+ {
+ return FALSE;
+ }
+
+ return (strlen($str) > $val) ? FALSE : TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Exact Length
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function exact_length($str, $val)
+ {
+ if ( ! is_numeric($val))
+ {
+ return FALSE;
+ }
+
+ return (strlen($str) != $val) ? FALSE : TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Valid Email
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function valid_email($str)
+ {
+ return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Validate IP Address
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function valid_ip($ip)
+ {
+ return ( ! preg_match( "/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/", $ip)) ? FALSE : TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Alpha
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function alpha($str)
+ {
+ return ( ! preg_match("/^([-a-z])+$/i", $str)) ? FALSE : TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Alpha-numeric
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function alpha_numeric($str)
+ {
+ return ( ! preg_match("/^([-a-z0-9])+$/i", $str)) ? FALSE : TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Alpha-numeric with underscores and dashes
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function alpha_dash($str)
+ {
+ return ( ! preg_match("/^([-a-z0-9_-])+$/i", $str)) ? FALSE : TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Numeric
+ *
+ * @access public
+ * @param int
+ * @return bool
+ */
+ function numeric($str)
+ {
+ return ( ! ereg("^[0-9\.]+$", $str)) ? FALSE : TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Is Numeric
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function is_numeric($str)
+ {
+ return ( ! is_numeric($str)) ? FALSE : TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Select
+ *
+ * Enables pull-down lists to be set to the value the user
+ * selected in the event of an error
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return string
+ */
+ function set_select($field = '', $value = '')
+ {
+ if ($field == '' OR $value == '' OR ! isset($_POST[$field]))
+ {
+ return '';
+ }
+
+ if ($_POST[$field] == $value)
+ {
+ return ' selected="selected"';
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Radio
+ *
+ * Enables radio buttons to be set to the value the user
+ * selected in the event of an error
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return string
+ */
+ function set_radio($field = '', $value = '')
+ {
+ if ($field == '' OR $value == '' OR ! isset($_POST[$field]))
+ {
+ return '';
+ }
+
+ if ($_POST[$field] == $value)
+ {
+ return ' checked="checked"';
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Checkbox
+ *
+ * Enables checkboxes to be set to the value the user
+ * selected in the event of an error
+ *
+ * @access public
+ * @param string
+ * @param string
+ * @return string
+ */
+ function set_checkbox($field = '', $value = '')
+ {
+ if ($field == '' OR $value == '' OR ! isset($_POST[$field]))
+ {
+ return '';
+ }
+
+ if ($_POST[$field] == $value)
+ {
+ return ' checked="checked"';
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Prep data for form
+ *
+ * This function allows HTML to be safely shown in a form.
+ * Special characters are converted.
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function prep_for_form($str = '')
+ {
+ if ($this->_safe_form_data == FALSE OR $str == '')
+ {
+ return $str;
+ }
+
+ return str_replace(array("'", '"', '<', '>'), array("&#39;", "&quot;", '&lt;', '&gt;'), stripslashes($str));
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Prep URL
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function prep_url($str = '')
+ {
+ if ($str == 'http://' OR $str == '')
+ {
+ $_POST[$this->_current_field] = '';
+ return;
+ }
+
+ if (substr($str, 0, 7) != 'http://' && substr($str, 0, 8) != 'https://')
+ {
+ $str = 'http://'.$str;
+ }
+
+ $_POST[$this->_current_field] = $str;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Strip Image Tags
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function strip_image_tags($str)
+ {
+ $_POST[$this->_current_field] = $this->input->strip_image_tags($str);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * XSS Clean
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function xss_clean($str)
+ {
+ $_POST[$this->_current_field] = $this->CI->input->xss_clean($str);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Convert PHP tags to entities
+ *
+ * @access public
+ * @param string
+ * @return string
+ */
+ function encode_php_tags($str)
+ {
+ $_POST[$this->_current_field] = str_replace(array('<?php', '<?PHP', '<?', '?>'), array('&lt;?php', '&lt;?PHP', '&lt;?', '?&gt;'), $str);
+ }
+
+}
+// END Validation Class
?> \ No newline at end of file
diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php
index 2d9a4c11b..49747e481 100644
--- a/system/libraries/Xmlrpc.php
+++ b/system/libraries/Xmlrpc.php
@@ -1,1412 +1,1412 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis, Paul Burdick
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-if ( ! function_exists('xml_parser_create'))
-{
- show_error('Your PHP installation does not support XML');
-}
-
-
-// ------------------------------------------------------------------------
-
-/**
- * XML-RPC request handler class
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category XML-RPC
- * @author Paul Burdick
- * @link http://www.codeigniter.com/user_guide/libraries/xmlrpc.html
- */
-class CI_Xmlrpc {
-
- var $debug = FALSE; // Debugging on or off
- var $xmlrpcI4 = 'i4';
- var $xmlrpcInt = 'int';
- var $xmlrpcBoolean = 'boolean';
- var $xmlrpcDouble = 'double';
- var $xmlrpcString = 'string';
- var $xmlrpcDateTime = 'dateTime.iso8601';
- var $xmlrpcBase64 = 'base64';
- var $xmlrpcArray = 'array';
- var $xmlrpcStruct = 'struct';
-
- var $xmlrpcTypes = array();
- var $valid_parents = array();
- var $xmlrpcerr = array(); // Response numbers
- var $xmlrpcstr = array(); // Response strings
-
- var $xmlrpc_defencoding = 'UTF-8';
- var $xmlrpcName = 'XML-RPC for CodeIgniter';
- var $xmlrpcVersion = '1.1';
- var $xmlrpcerruser = 800; // Start of user errors
- var $xmlrpcerrxml = 100; // Start of XML Parse errors
- var $xmlrpc_backslash = ''; // formulate backslashes for escaping regexp
-
- var $client;
- var $method;
- var $data;
- var $message = '';
- var $error = ''; // Error string for request
- var $result;
- var $response = array(); // Response from remote server
-
-
- //-------------------------------------
- // VALUES THAT MULTIPLE CLASSES NEED
- //-------------------------------------
-
- function CI_Xmlrpc ($config = array())
- {
-
- $this->xmlrpcName = $this->xmlrpcName;
- $this->xmlrpc_backslash = chr(92).chr(92);
-
- // Types for info sent back and forth
- $this->xmlrpcTypes = array(
- $this->xmlrpcI4 => '1',
- $this->xmlrpcInt => '1',
- $this->xmlrpcBoolean => '1',
- $this->xmlrpcString => '1',
- $this->xmlrpcDouble => '1',
- $this->xmlrpcDateTime => '1',
- $this->xmlrpcBase64 => '1',
- $this->xmlrpcArray => '2',
- $this->xmlrpcStruct => '3'
- );
-
- // Array of Valid Parents for Various XML-RPC elements
- $this->valid_parents = array('BOOLEAN' => array('VALUE'),
- 'I4' => array('VALUE'),
- 'INT' => array('VALUE'),
- 'STRING' => array('VALUE'),
- 'DOUBLE' => array('VALUE'),
- 'DATETIME.ISO8601' => array('VALUE'),
- 'BASE64' => array('VALUE'),
- 'ARRAY' => array('VALUE'),
- 'STRUCT' => array('VALUE'),
- 'PARAM' => array('PARAMS'),
- 'METHODNAME' => array('METHODCALL'),
- 'PARAMS' => array('METHODCALL', 'METHODRESPONSE'),
- 'MEMBER' => array('STRUCT'),
- 'NAME' => array('MEMBER'),
- 'DATA' => array('ARRAY'),
- 'FAULT' => array('METHODRESPONSE'),
- 'VALUE' => array('MEMBER', 'DATA', 'PARAM', 'FAULT')
- );
-
-
- // XML-RPC Responses
- $this->xmlrpcerr['unknown_method'] = '1';
- $this->xmlrpcstr['unknown_method'] = 'This is not a known method for this XML-RPC Server';
- $this->xmlrpcerr['invalid_return'] = '2';
- $this->xmlrpcstr['invalid_return'] = 'The XML data receieved was either invalid or not in the correct form for XML-RPC. Turn on debugging to examine the XML data further.';
- $this->xmlrpcerr['incorrect_params'] = '3';
- $this->xmlrpcstr['incorrect_params'] = 'Incorrect parameters were passed to method';
- $this->xmlrpcerr['introspect_unknown'] = '4';
- $this->xmlrpcstr['introspect_unknown'] = "Cannot inspect signature for request: method unknown";
- $this->xmlrpcerr['http_error'] = '5';
- $this->xmlrpcstr['http_error'] = "Did not receive a '200 OK' response from remote server.";
- $this->xmlrpcerr['no_data'] = '6';
- $this->xmlrpcstr['no_data'] ='No data received from server.';
-
- $this->initialize($config);
-
- log_message('debug', "XML-RPC Class Initialized");
- }
-
-
- //-------------------------------------
- // Initialize Prefs
- //-------------------------------------
-
- function initialize($config = array())
- {
- if (sizeof($config) > 0)
- {
- foreach ($config as $key => $val)
- {
- if (isset($this->$key))
- {
- $this->$key = $val;
- }
- }
- }
- }
- // END
-
- //-------------------------------------
- // Take URL and parse it
- //-------------------------------------
-
- function server($url, $port=80)
- {
- if (substr($url, 0, 4) != "http")
- {
- $url = "http://".$url;
- }
-
- $parts = parse_url($url);
-
- $path = (!isset($parts['path'])) ? '/' : $parts['path'];
-
- if (isset($parts['query']) && $parts['query'] != '')
- {
- $path .= '?'.$parts['query'];
- }
-
- $this->client = new XML_RPC_Client($path, $parts['host'], $port);
- }
- // END
-
- //-------------------------------------
- // Set Timeout
- //-------------------------------------
-
- function timeout($seconds=5)
- {
- if ( ! is_null($this->client) && is_int($seconds))
- {
- $this->client->timeout = $seconds;
- }
- }
- // END
-
- //-------------------------------------
- // Set Methods
- //-------------------------------------
-
- function method($function)
- {
- $this->method = $function;
- }
- // END
-
- //-------------------------------------
- // Take Array of Data and Create Objects
- //-------------------------------------
-
- function request($incoming)
- {
- if ( ! is_array($incoming))
- {
- // Send Error
- }
-
- foreach($incoming as $key => $value)
- {
- $this->data[$key] = $this->values_parsing($value);
- }
- }
- // END
-
-
- //-------------------------------------
- // Set Debug
- //-------------------------------------
-
- function set_debug($flag = TRUE)
- {
- $this->debug = ($flag == TRUE) ? TRUE : FALSE;
- }
-
- //-------------------------------------
- // Values Parsing
- //-------------------------------------
-
- function values_parsing($value, $return = FALSE)
- {
- if (is_array($value) && isset($value['0']))
- {
- if ( ! isset($value['1']) OR ! isset($this->xmlrpcTypes[strtolower($value['1'])]))
- {
- $temp = new XML_RPC_Values($value['0'], 'string');
- }
- elseif(is_array($value['0']) && ($value['1'] == 'struct' OR $value['1'] == 'array'))
- {
- while (list($k) = each($value['0']))
- {
- $value['0'][$k] = $this->values_parsing($value['0'][$k], TRUE);
- }
-
- $temp = new XML_RPC_Values($value['0'], $value['1']);
- }
- else
- {
- $temp = new XML_RPC_Values($value['0'], $value['1']);
- }
- }
- else
- {
- $temp = new XML_RPC_Values($value, 'string');
- }
-
- return $temp;
- }
- // END
-
-
- //-------------------------------------
- // Sends XML-RPC Request
- //-------------------------------------
-
- function send_request()
- {
- $this->message = new XML_RPC_Message($this->method,$this->data);
- $this->message->debug = $this->debug;
-
- if ( ! $this->result = $this->client->send($this->message))
- {
- $this->error = $this->result->errstr;
- return FALSE;
- }
- elseif( ! is_object($this->result->val))
- {
- $this->error = $this->result->errstr;
- return FALSE;
- }
-
- $this->response = $this->result->decode();
-
- return TRUE;
- }
- // END
-
- //-------------------------------------
- // Returns Error
- //-------------------------------------
-
- function display_error()
- {
- return $this->error;
- }
- // END
-
- //-------------------------------------
- // Returns Remote Server Response
- //-------------------------------------
-
- function display_response()
- {
- return $this->response;
- }
- // END
-
- //-------------------------------------
- // Sends an Error Message for Server Request
- //-------------------------------------
-
- function send_error_message($number, $message)
- {
- return new XML_RPC_Response('0',$number, $message);
- }
- // END
-
-
- //-------------------------------------
- // Send Response for Server Request
- //-------------------------------------
-
- function send_response($response)
- {
- // $response should be array of values, which will be parsed
- // based on their data and type into a valid group of XML-RPC values
-
- $response = $this->values_parsing($response);
-
- return new XML_RPC_Response($response);
- }
- // END
-
-} // END XML_RPC Class
-
-
-
-/**
- * XML-RPC Client class
- *
- * @category XML-RPC
- * @author Paul Burdick
- * @link http://www.codeigniter.com/user_guide/libraries/xmlrpc.html
- */
-class XML_RPC_Client extends CI_Xmlrpc
-{
- var $path = '';
- var $server = '';
- var $port = 80;
- var $errno = '';
- var $errstring = '';
- var $timeout = 5;
- var $no_multicall = false;
-
- function XML_RPC_Client($path, $server, $port=80)
- {
- parent::CI_Xmlrpc();
-
- $this->port = $port;
- $this->server = $server;
- $this->path = $path;
- }
-
- function send($msg)
- {
- if (is_array($msg))
- {
- // Multi-call disabled
- $r = new XML_RPC_Response(0, $this->xmlrpcerr['multicall_recursion'],$this->xmlrpcstr['multicall_recursion']);
- return $r;
- }
-
- return $this->sendPayload($msg);
- }
-
- function sendPayload($msg)
- {
- $fp = @fsockopen($this->server, $this->port,$this->errno, $this->errstr, $this->timeout);
-
- if (! is_resource($fp))
- {
- error_log($this->xmlrpcstr['http_error']);
- $r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'],$this->xmlrpcstr['http_error']);
- return $r;
- }
-
- if(empty($msg->payload))
- {
- // $msg = XML_RPC_Messages
- $msg->createPayload();
- }
-
- $r = "\r\n";
- $op = "POST {$this->path} HTTP/1.0$r";
- $op .= "Host: {$this->server}$r";
- $op .= "Content-Type: text/xml$r";
- $op .= "User-Agent: {$this->xmlrpcName}$r";
- $op .= "Content-Length: ".strlen($msg->payload). "$r$r";
- $op .= $msg->payload;
-
-
- if (!fputs($fp, $op, strlen($op)))
- {
- error_log($this->xmlrpcstr['http_error']);
- $r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error']);
- return $r;
- }
- $resp = $msg->parseResponse($fp);
- fclose($fp);
- return $resp;
- }
-
-} // end class XML_RPC_Client
-
-
-/**
- * XML-RPC Response class
- *
- * @category XML-RPC
- * @author Paul Burdick
- * @link http://www.codeigniter.com/user_guide/libraries/xmlrpc.html
- */
-class XML_RPC_Response
-{
- var $val = 0;
- var $errno = 0;
- var $errstr = '';
- var $headers = array();
-
- function XML_RPC_Response($val, $code = 0, $fstr = '')
- {
- if ($code != 0)
- {
- // error
- $this->errno = $code;
- $this->errstr = htmlentities($fstr);
- }
- else if (!is_object($val))
- {
- // programmer error, not an object
- error_log("Invalid type '" . gettype($val) . "' (value: $val) passed to XML_RPC_Response. Defaulting to empty value.");
- $this->val = new XML_RPC_Values();
- }
- else
- {
- $this->val = $val;
- }
- }
-
- function faultCode()
- {
- return $this->errno;
- }
-
- function faultString()
- {
- return $this->errstr;
- }
-
- function value()
- {
- return $this->val;
- }
-
- function prepare_response()
- {
- $result = "<methodResponse>\n";
- if ($this->errno)
- {
- $result .= '<fault>
- <value>
- <struct>
- <member>
- <name>faultCode</name>
- <value><int>' . $this->errno . '</int></value>
- </member>
- <member>
- <name>faultString</name>
- <value><string>' . $this->errstr . '</string></value>
- </member>
- </struct>
- </value>
-</fault>';
- }
- else
- {
- $result .= "<params>\n<param>\n" .
- $this->val->serialize_class() .
- "</param>\n</params>";
- }
- $result .= "\n</methodResponse>";
- return $result;
- }
-
- function decode($array=FALSE)
- {
- $CI =& get_instance();
-
- if ($array !== FALSE && is_array($array))
- {
- while (list($key) = each($array))
- {
- if (is_array($array[$key]))
- {
- $array[$key] = $this->decode($array[$key]);
- }
- else
- {
- $array[$key] = $CI->input->xss_clean($array[$key]);
- }
- }
-
- $result = $array;
- }
- else
- {
- $result = $this->xmlrpc_decoder($this->val);
-
- if (is_array($result))
- {
- $result = $this->decode($result);
- }
- else
- {
- $result = $CI->input->xss_clean($result);
- }
- }
-
- return $result;
- }
-
-
-
- //-------------------------------------
- // XML-RPC Object to PHP Types
- //-------------------------------------
-
- function xmlrpc_decoder($xmlrpc_val)
- {
- $kind = $xmlrpc_val->kindOf();
-
- if($kind == 'scalar')
- {
- return $xmlrpc_val->scalarval();
- }
- elseif($kind == 'array')
- {
- reset($xmlrpc_val->me);
- list($a,$b) = each($xmlrpc_val->me);
- $size = sizeof($b);
-
- $arr = array();
-
- for($i = 0; $i < $size; $i++)
- {
- $arr[] = $this->xmlrpc_decoder($xmlrpc_val->me['array'][$i]);
- }
- return $arr;
- }
- elseif($kind == 'struct')
- {
- reset($xmlrpc_val->me['struct']);
- $arr = array();
-
- while(list($key,$value) = each($xmlrpc_val->me['struct']))
- {
- $arr[$key] = $this->xmlrpc_decoder($value);
- }
- return $arr;
- }
- }
-
-
- //-------------------------------------
- // ISO-8601 time to server or UTC time
- //-------------------------------------
-
- function iso8601_decode($time, $utc=0)
- {
- // return a timet in the localtime, or UTC
- $t = 0;
- if (ereg("([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})", $time, $regs))
- {
- if ($utc == 1)
- $t = gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
- else
- $t = mktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
- }
- return $t;
- }
-
-} // End Response Class
-
-
-
-/**
- * XML-RPC Message class
- *
- * @category XML-RPC
- * @author Paul Burdick
- * @link http://www.codeigniter.com/user_guide/libraries/xmlrpc.html
- */
-class XML_RPC_Message extends CI_Xmlrpc
-{
- var $payload;
- var $method_name;
- var $params = array();
- var $xh = array();
-
- function XML_RPC_Message($method, $pars=0)
- {
- parent::CI_Xmlrpc();
-
- $this->method_name = $method;
- if (is_array($pars) && sizeof($pars) > 0)
- {
- for($i=0; $i<sizeof($pars); $i++)
- {
- // $pars[$i] = XML_RPC_Values
- $this->params[] = $pars[$i];
- }
- }
- }
-
- //-------------------------------------
- // Create Payload to Send
- //-------------------------------------
-
- function createPayload()
- {
- $this->payload = "<?xml version=\"1.0\"?".">\r\n<methodCall>\r\n";
- $this->payload .= '<methodName>' . $this->method_name . "</methodName>\r\n";
- $this->payload .= "<params>\r\n";
-
- for($i=0; $i<sizeof($this->params); $i++)
- {
- // $p = XML_RPC_Values
- $p = $this->params[$i];
- $this->payload .= "<param>\r\n".$p->serialize_class()."</param>\r\n";
- }
-
- $this->payload .= "</params>\r\n</methodCall>\r\n";
- }
-
- //-------------------------------------
- // Parse External XML-RPC Server's Response
- //-------------------------------------
-
- function parseResponse($fp)
- {
- $data = '';
-
- while($datum = fread($fp, 4096))
- {
- $data .= $datum;
- }
-
- //-------------------------------------
- // DISPLAY HTTP CONTENT for DEBUGGING
- //-------------------------------------
-
- if ($this->debug === TRUE)
- {
- echo "<pre>";
- echo "---DATA---\n" . htmlspecialchars($data) . "\n---END DATA---\n\n";
- echo "</pre>";
- }
-
- //-------------------------------------
- // Check for data
- //-------------------------------------
-
- if($data == "")
- {
- error_log($this->xmlrpcstr['no_data']);
- $r = new XML_RPC_Response(0, $this->xmlrpcerr['no_data'], $this->xmlrpcstr['no_data']);
- return $r;
- }
-
-
- //-------------------------------------
- // Check for HTTP 200 Response
- //-------------------------------------
-
- if(ereg("^HTTP",$data) && !ereg("^HTTP/[0-9\.]+ 200 ", $data))
- {
- $errstr= substr($data, 0, strpos($data, "\n")-1);
- $r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error']. ' (' . $errstr . ')');
- return $r;
- }
-
- //-------------------------------------
- // Create and Set Up XML Parser
- //-------------------------------------
-
- $parser = xml_parser_create($this->xmlrpc_defencoding);
-
- $this->xh[$parser] = array();
- $this->xh[$parser]['isf'] = 0;
- $this->xh[$parser]['ac'] = '';
- $this->xh[$parser]['headers'] = array();
- $this->xh[$parser]['stack'] = array();
- $this->xh[$parser]['valuestack'] = array();
- $this->xh[$parser]['isf_reason'] = 0;
-
- xml_set_object($parser, $this);
- xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
- xml_set_element_handler($parser, 'open_tag', 'closing_tag');
- xml_set_character_data_handler($parser, 'character_data');
- //xml_set_default_handler($parser, 'default_handler');
-
-
- //-------------------------------------
- // GET HEADERS
- //-------------------------------------
-
- $lines = explode("\r\n", $data);
- while (($line = array_shift($lines)))
- {
- if (strlen($line) < 1)
- {
- break;
- }
- $this->xh[$parser]['headers'][] = $line;
- }
- $data = implode("\r\n", $lines);
-
-
- //-------------------------------------
- // PARSE XML DATA
- //-------------------------------------
-
- if (!xml_parse($parser, $data, sizeof($data)))
- {
- $errstr = sprintf('XML error: %s at line %d',
- xml_error_string(xml_get_error_code($parser)),
- xml_get_current_line_number($parser));
- //error_log($errstr);
- $r = new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'], $this->xmlrpcstr['invalid_return']);
- xml_parser_free($parser);
- return $r;
- }
- xml_parser_free($parser);
-
- // ---------------------------------------
- // Got Ourselves Some Badness, It Seems
- // ---------------------------------------
-
- if ($this->xh[$parser]['isf'] > 1)
- {
- if ($this->debug === TRUE)
- {
- echo "---Invalid Return---\n";
- echo $this->xh[$parser]['isf_reason'];
- echo "---Invalid Return---\n\n";
- }
-
- $r = new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'],$this->xmlrpcstr['invalid_return'].' '.$this->xh[$parser]['isf_reason']);
- return $r;
- }
- elseif ( ! is_object($this->xh[$parser]['value']))
- {
- $r = new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'],$this->xmlrpcstr['invalid_return'].' '.$this->xh[$parser]['isf_reason']);
- return $r;
- }
-
- //-------------------------------------
- // DISPLAY XML CONTENT for DEBUGGING
- //-------------------------------------
-
- if ($this->debug === TRUE)
- {
- echo "<pre>";
-
- if (count($this->xh[$parser]['headers'] > 0))
- {
- echo "---HEADERS---\n";
- foreach ($this->xh[$parser]['headers'] as $header)
- {
- echo "$header\n";
- }
- echo "---END HEADERS---\n\n";
- }
-
- echo "---DATA---\n" . htmlspecialchars($data) . "\n---END DATA---\n\n";
-
- echo "---PARSED---\n" ;
- var_dump($this->xh[$parser]['value']);
- echo "\n---END PARSED---</pre>";
- }
-
- //-------------------------------------
- // SEND RESPONSE
- //-------------------------------------
-
- $v = $this->xh[$parser]['value'];
-
- if ($this->xh[$parser]['isf'])
- {
- $errno_v = $v->me['struct']['faultCode'];
- $errstr_v = $v->me['struct']['faultString'];
- $errno = $errno_v->scalarval();
-
- if ($errno == 0)
- {
- // FAULT returned, errno needs to reflect that
- $errno = -1;
- }
-
- $r = new XML_RPC_Response($v, $errno, $errstr_v->scalarval());
- }
- else
- {
- $r = new XML_RPC_Response($v);
- }
-
- $r->headers = $this->xh[$parser]['headers'];
- return $r;
- }
-
- // ------------------------------------
- // Begin Return Message Parsing section
- // ------------------------------------
-
- // quick explanation of components:
- // ac - used to accumulate values
- // isf - used to indicate a fault
- // lv - used to indicate "looking for a value": implements
- // the logic to allow values with no types to be strings
- // params - used to store parameters in method calls
- // method - used to store method name
- // stack - array with parent tree of the xml element,
- // used to validate the nesting of elements
-
- //-------------------------------------
- // Start Element Handler
- //-------------------------------------
-
- function open_tag($the_parser, $name, $attrs)
- {
- // If invalid nesting, then return
- if ($this->xh[$the_parser]['isf'] > 1) return;
-
- // Evaluate and check for correct nesting of XML elements
-
- if (count($this->xh[$the_parser]['stack']) == 0)
- {
- if ($name != 'METHODRESPONSE' && $name != 'METHODCALL')
- {
- $this->xh[$the_parser]['isf'] = 2;
- $this->xh[$the_parser]['isf_reason'] = 'Top level XML-RPC element is missing';
- return;
- }
- }
- else
- {
- // not top level element: see if parent is OK
- if (!in_array($this->xh[$the_parser]['stack'][0], $this->valid_parents[$name], TRUE))
- {
- $this->xh[$the_parser]['isf'] = 2;
- $this->xh[$the_parser]['isf_reason'] = "XML-RPC element $name cannot be child of ".$this->xh[$the_parser]['stack'][0];
- return;
- }
- }
-
- switch($name)
- {
- case 'STRUCT':
- case 'ARRAY':
- // Creates array for child elements
-
- $cur_val = array('value' => array(),
- 'type' => $name);
-
- array_unshift($this->xh[$the_parser]['valuestack'], $cur_val);
- break;
- case 'METHODNAME':
- case 'NAME':
- $this->xh[$the_parser]['ac'] = '';
- break;
- case 'FAULT':
- $this->xh[$the_parser]['isf'] = 1;
- break;
- case 'PARAM':
- $this->xh[$the_parser]['value'] = null;
- break;
- case 'VALUE':
- $this->xh[$the_parser]['vt'] = 'value';
- $this->xh[$the_parser]['ac'] = '';
- $this->xh[$the_parser]['lv'] = 1;
- break;
- case 'I4':
- case 'INT':
- case 'STRING':
- case 'BOOLEAN':
- case 'DOUBLE':
- case 'DATETIME.ISO8601':
- case 'BASE64':
- if ($this->xh[$the_parser]['vt'] != 'value')
- {
- //two data elements inside a value: an error occurred!
- $this->xh[$the_parser]['isf'] = 2;
- $this->xh[$the_parser]['isf_reason'] = "'Twas a $name element following a ".$this->xh[$the_parser]['vt']." element inside a single value";
- return;
- }
-
- $this->xh[$the_parser]['ac'] = '';
- break;
- case 'MEMBER':
- // Set name of <member> to nothing to prevent errors later if no <name> is found
- $this->xh[$the_parser]['valuestack'][0]['name'] = '';
-
- // Set NULL value to check to see if value passed for this param/member
- $this->xh[$the_parser]['value'] = null;
- break;
- case 'DATA':
- case 'METHODCALL':
- case 'METHODRESPONSE':
- case 'PARAMS':
- // valid elements that add little to processing
- break;
- default:
- /// An Invalid Element is Found, so we have trouble
- $this->xh[$the_parser]['isf'] = 2;
- $this->xh[$the_parser]['isf_reason'] = "Invalid XML-RPC element found: $name";
- break;
- }
-
- // Add current element name to stack, to allow validation of nesting
- array_unshift($this->xh[$the_parser]['stack'], $name);
-
- if ($name != 'VALUE') $this->xh[$the_parser]['lv'] = 0;
- }
- // END
-
-
- //-------------------------------------
- // End Element Handler
- //-------------------------------------
-
- function closing_tag($the_parser, $name)
- {
- if ($this->xh[$the_parser]['isf'] > 1) return;
-
- // Remove current element from stack and set variable
- // NOTE: If the XML validates, then we do not have to worry about
- // the opening and closing of elements. Nesting is checked on the opening
- // tag so we be safe there as well.
-
- $curr_elem = array_shift($this->xh[$the_parser]['stack']);
-
- switch($name)
- {
- case 'STRUCT':
- case 'ARRAY':
- $cur_val = array_shift($this->xh[$the_parser]['valuestack']);
- $this->xh[$the_parser]['value'] = ( ! isset($cur_val['values'])) ? array() : $cur_val['values'];
- $this->xh[$the_parser]['vt'] = strtolower($name);
- break;
- case 'NAME':
- $this->xh[$the_parser]['valuestack'][0]['name'] = $this->xh[$the_parser]['ac'];
- break;
- case 'BOOLEAN':
- case 'I4':
- case 'INT':
- case 'STRING':
- case 'DOUBLE':
- case 'DATETIME.ISO8601':
- case 'BASE64':
- $this->xh[$the_parser]['vt'] = strtolower($name);
-
- if ($name == 'STRING')
- {
- $this->xh[$the_parser]['value'] = $this->xh[$the_parser]['ac'];
- }
- elseif ($name=='DATETIME.ISO8601')
- {
- $this->xh[$the_parser]['vt'] = $this->xmlrpcDateTime;
- $this->xh[$the_parser]['value'] = $this->xh[$the_parser]['ac'];
- }
- elseif ($name=='BASE64')
- {
- $this->xh[$the_parser]['value'] = base64_decode($this->xh[$the_parser]['ac']);
- }
- elseif ($name=='BOOLEAN')
- {
- // Translated BOOLEAN values to TRUE AND FALSE
- if ($this->xh[$the_parser]['ac'] == '1')
- {
- $this->xh[$the_parser]['value'] = TRUE;
- }
- else
- {
- $this->xh[$the_parser]['value'] = FALSE;
- }
- }
- elseif ($name=='DOUBLE')
- {
- // we have a DOUBLE
- // we must check that only 0123456789-.<space> are characters here
- if (!ereg("^[+-]?[eE0123456789 \\t\\.]+$", $this->xh[$the_parser]['ac']))
- {
- $this->xh[$the_parser]['value'] = 'ERROR_NON_NUMERIC_FOUND';
- }
- else
- {
- $this->xh[$the_parser]['value'] = (double)$this->xh[$the_parser]['ac'];
- }
- }
- else
- {
- // we have an I4/INT
- // we must check that only 0123456789-<space> are characters here
- if (!ereg("^[+-]?[0123456789 \\t]+$", $this->xh[$the_parser]['ac']))
- {
- $this->xh[$the_parser]['value'] = 'ERROR_NON_NUMERIC_FOUND';
- }
- else
- {
- $this->xh[$the_parser]['value'] = (int)$this->xh[$the_parser]['ac'];
- }
- }
- $this->xh[$the_parser]['ac'] = '';
- $this->xh[$the_parser]['lv'] = 3; // indicate we've found a value
- break;
- case 'VALUE':
- // This if() detects if no scalar was inside <VALUE></VALUE>
- if ($this->xh[$the_parser]['vt']=='value')
- {
- $this->xh[$the_parser]['value'] = $this->xh[$the_parser]['ac'];
- $this->xh[$the_parser]['vt'] = $this->xmlrpcString;
- }
-
- // build the XML-RPC value out of the data received, and substitute it
- $temp = new XML_RPC_Values($this->xh[$the_parser]['value'], $this->xh[$the_parser]['vt']);
-
- if (count($this->xh[$the_parser]['valuestack']) && $this->xh[$the_parser]['valuestack'][0]['type'] == 'ARRAY')
- {
- // Array
- $this->xh[$the_parser]['valuestack'][0]['values'][] = $temp;
- }
- else
- {
- // Struct
- $this->xh[$the_parser]['value'] = $temp;
- }
- break;
- case 'MEMBER':
- $this->xh[$the_parser]['ac']='';
-
- // If value add to array in the stack for the last element built
- if ($this->xh[$the_parser]['value'])
- {
- $this->xh[$the_parser]['valuestack'][0]['values'][$this->xh[$the_parser]['valuestack'][0]['name']] = $this->xh[$the_parser]['value'];
- }
- break;
- case 'DATA':
- $this->xh[$the_parser]['ac']='';
- break;
- case 'PARAM':
- if ($this->xh[$the_parser]['value'])
- {
- $this->xh[$the_parser]['params'][] = $this->xh[$the_parser]['value'];
- }
- break;
- case 'METHODNAME':
- $this->xh[$the_parser]['method'] = ereg_replace("^[\n\r\t ]+", '', $this->xh[$the_parser]['ac']);
- break;
- case 'PARAMS':
- case 'FAULT':
- case 'METHODCALL':
- case 'METHORESPONSE':
- // We're all good kids with nuthin' to do
- break;
- default:
- // End of an Invalid Element. Taken care of during the opening tag though
- break;
- }
- }
-
- //-------------------------------------
- // Parses Character Data
- //-------------------------------------
-
- function character_data($the_parser, $data)
- {
- if ($this->xh[$the_parser]['isf'] > 1) return; // XML Fault found already
-
- // If a value has not been found
- if ($this->xh[$the_parser]['lv'] != 3)
- {
- if ($this->xh[$the_parser]['lv'] == 1)
- {
- $this->xh[$the_parser]['lv'] = 2; // Found a value
- }
-
- if( ! @isset($this->xh[$the_parser]['ac']))
- {
- $this->xh[$the_parser]['ac'] = '';
- }
-
- $this->xh[$the_parser]['ac'] .= $data;
- }
- }
-
-
- function addParam($par) { $this->params[]=$par; }
-
- function output_parameters($array=FALSE)
- {
- $CI =& get_instance();
-
- if ($array !== FALSE && is_array($array))
- {
- while (list($key) = each($array))
- {
- if (is_array($array[$key]))
- {
- $array[$key] = $this->output_parameters($array[$key]);
- }
- else
- {
- $array[$key] = $CI->input->xss_clean($array[$key]);
- }
- }
-
- $parameters = $array;
- }
- else
- {
- $parameters = array();
-
- for ($i = 0; $i < sizeof($this->params); $i++)
- {
- $a_param = $this->decode_message($this->params[$i]);
-
- if (is_array($a_param))
- {
- $parameters[] = $this->output_parameters($a_param);
- }
- else
- {
- $parameters[] = $CI->input->xss_clean($a_param);
- }
- }
- }
-
- return $parameters;
- }
-
-
- function decode_message($param)
- {
- $kind = $param->kindOf();
-
- if($kind == 'scalar')
- {
- return $param->scalarval();
- }
- elseif($kind == 'array')
- {
- reset($param->me);
- list($a,$b) = each($param->me);
-
- $arr = array();
-
- for($i = 0; $i < sizeof($b); $i++)
- {
- $arr[] = $this->decode_message($param->me['array'][$i]);
- }
-
- return $arr;
- }
- elseif($kind == 'struct')
- {
- reset($param->me['struct']);
-
- $arr = array();
-
- while(list($key,$value) = each($param->me['struct']))
- {
- $arr[$key] = $this->decode_message($value);
- }
-
- return $arr;
- }
- }
-
-} // End XML_RPC_Messages class
-
-
-
-/**
- * XML-RPC Values class
- *
- * @category XML-RPC
- * @author Paul Burdick
- * @link http://www.codeigniter.com/user_guide/libraries/xmlrpc.html
- */
-class XML_RPC_Values extends CI_Xmlrpc
-{
- var $me = array();
- var $mytype = 0;
-
- function XML_RPC_Values($val=-1, $type='')
- {
- parent::CI_Xmlrpc();
-
- if ($val != -1 || $type != '')
- {
- $type = $type == '' ? 'string' : $type;
-
- if ($this->xmlrpcTypes[$type] == 1)
- {
- $this->addScalar($val,$type);
- }
- elseif ($this->xmlrpcTypes[$type] == 2)
- {
- $this->addArray($val);
- }
- elseif ($this->xmlrpcTypes[$type] == 3)
- {
- $this->addStruct($val);
- }
- }
- }
-
- function addScalar($val, $type='string')
- {
- $typeof = $this->xmlrpcTypes[$type];
-
- if ($this->mytype==1)
- {
- echo '<strong>XML_RPC_Values</strong>: scalar can have only one value<br />';
- return 0;
- }
-
- if ($typeof != 1)
- {
- echo '<strong>XML_RPC_Values</strong>: not a scalar type (${typeof})<br />';
- return 0;
- }
-
- if ($type == $this->xmlrpcBoolean)
- {
- if (strcasecmp($val,'true')==0 || $val==1 || ($val==true && strcasecmp($val,'false')))
- {
- $val = 1;
- }
- else
- {
- $val=0;
- }
- }
-
- if ($this->mytype == 2)
- {
- // adding to an array here
- $ar = $this->me['array'];
- $ar[] = new XML_RPC_Values($val, $type);
- $this->me['array'] = $ar;
- }
- else
- {
- // a scalar, so set the value and remember we're scalar
- $this->me[$type] = $val;
- $this->mytype = $typeof;
- }
- return 1;
- }
-
- function addArray($vals)
- {
- if ($this->mytype != 0)
- {
- echo '<strong>XML_RPC_Values</strong>: already initialized as a [' . $this->kindOf() . ']<br />';
- return 0;
- }
-
- $this->mytype = $this->xmlrpcTypes['array'];
- $this->me['array'] = $vals;
- return 1;
- }
-
- function addStruct($vals)
- {
- if ($this->mytype != 0)
- {
- echo '<strong>XML_RPC_Values</strong>: already initialized as a [' . $this->kindOf() . ']<br />';
- return 0;
- }
- $this->mytype = $this->xmlrpcTypes['struct'];
- $this->me['struct'] = $vals;
- return 1;
- }
-
- function kindOf()
- {
- switch($this->mytype)
- {
- case 3:
- return 'struct';
- break;
- case 2:
- return 'array';
- break;
- case 1:
- return 'scalar';
- break;
- default:
- return 'undef';
- }
- }
-
- function serializedata($typ, $val)
- {
- $rs = '';
-
- switch($this->xmlrpcTypes[$typ])
- {
- case 3:
- // struct
- $rs .= "<struct>\n";
- reset($val);
- while(list($key2, $val2) = each($val))
- {
- $rs .= "<member>\n<name>{$key2}</name>\n";
- $rs .= $this->serializeval($val2);
- $rs .= "</member>\n";
- }
- $rs .= '</struct>';
- break;
- case 2:
- // array
- $rs .= "<array>\n<data>\n";
- for($i=0; $i < sizeof($val); $i++)
- {
- $rs .= $this->serializeval($val[$i]);
- }
- $rs.="</data>\n</array>\n";
- break;
- case 1:
- // others
- switch ($typ)
- {
- case $this->xmlrpcBase64:
- $rs .= "<{$typ}>" . base64_encode($val) . "</{$typ}>\n";
- break;
- case $this->xmlrpcBoolean:
- $rs .= "<{$typ}>" . ($val ? '1' : '0') . "</{$typ}>\n";
- break;
- case $this->xmlrpcString:
- $rs .= "<{$typ}>" . htmlspecialchars($val). "</{$typ}>\n";
- break;
- default:
- $rs .= "<{$typ}>{$val}</{$typ}>\n";
- break;
- }
- default:
- break;
- }
- return $rs;
- }
-
- function serialize_class()
- {
- return $this->serializeval($this);
- }
-
- function serializeval($o)
- {
-
- $ar = $o->me;
- reset($ar);
-
- list($typ, $val) = each($ar);
- $rs = "<value>\n".$this->serializedata($typ, $val)."</value>\n";
- return $rs;
- }
-
- function scalarval()
- {
- reset($this->me);
- list($a,$b) = each($this->me);
- return $b;
- }
-
-
- //-------------------------------------
- // Encode time in ISO-8601 form.
- //-------------------------------------
-
- // Useful for sending time in XML-RPC
-
- function iso8601_encode($time, $utc=0)
- {
- if ($utc == 1)
- {
- $t = strftime("%Y%m%dT%H:%M:%S", $time);
- }
- else
- {
- if (function_exists('gmstrftime'))
- $t = gmstrftime("%Y%m%dT%H:%M:%S", $time);
- else
- $t = strftime("%Y%m%dT%H:%M:%S", $time - date('Z'));
- }
- return $t;
- }
-
-}
-// END XML_RPC_Values Class
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis, Paul Burdick
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+if ( ! function_exists('xml_parser_create'))
+{
+ show_error('Your PHP installation does not support XML');
+}
+
+
+// ------------------------------------------------------------------------
+
+/**
+ * XML-RPC request handler class
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category XML-RPC
+ * @author Paul Burdick
+ * @link http://www.codeigniter.com/user_guide/libraries/xmlrpc.html
+ */
+class CI_Xmlrpc {
+
+ var $debug = FALSE; // Debugging on or off
+ var $xmlrpcI4 = 'i4';
+ var $xmlrpcInt = 'int';
+ var $xmlrpcBoolean = 'boolean';
+ var $xmlrpcDouble = 'double';
+ var $xmlrpcString = 'string';
+ var $xmlrpcDateTime = 'dateTime.iso8601';
+ var $xmlrpcBase64 = 'base64';
+ var $xmlrpcArray = 'array';
+ var $xmlrpcStruct = 'struct';
+
+ var $xmlrpcTypes = array();
+ var $valid_parents = array();
+ var $xmlrpcerr = array(); // Response numbers
+ var $xmlrpcstr = array(); // Response strings
+
+ var $xmlrpc_defencoding = 'UTF-8';
+ var $xmlrpcName = 'XML-RPC for CodeIgniter';
+ var $xmlrpcVersion = '1.1';
+ var $xmlrpcerruser = 800; // Start of user errors
+ var $xmlrpcerrxml = 100; // Start of XML Parse errors
+ var $xmlrpc_backslash = ''; // formulate backslashes for escaping regexp
+
+ var $client;
+ var $method;
+ var $data;
+ var $message = '';
+ var $error = ''; // Error string for request
+ var $result;
+ var $response = array(); // Response from remote server
+
+
+ //-------------------------------------
+ // VALUES THAT MULTIPLE CLASSES NEED
+ //-------------------------------------
+
+ function CI_Xmlrpc ($config = array())
+ {
+
+ $this->xmlrpcName = $this->xmlrpcName;
+ $this->xmlrpc_backslash = chr(92).chr(92);
+
+ // Types for info sent back and forth
+ $this->xmlrpcTypes = array(
+ $this->xmlrpcI4 => '1',
+ $this->xmlrpcInt => '1',
+ $this->xmlrpcBoolean => '1',
+ $this->xmlrpcString => '1',
+ $this->xmlrpcDouble => '1',
+ $this->xmlrpcDateTime => '1',
+ $this->xmlrpcBase64 => '1',
+ $this->xmlrpcArray => '2',
+ $this->xmlrpcStruct => '3'
+ );
+
+ // Array of Valid Parents for Various XML-RPC elements
+ $this->valid_parents = array('BOOLEAN' => array('VALUE'),
+ 'I4' => array('VALUE'),
+ 'INT' => array('VALUE'),
+ 'STRING' => array('VALUE'),
+ 'DOUBLE' => array('VALUE'),
+ 'DATETIME.ISO8601' => array('VALUE'),
+ 'BASE64' => array('VALUE'),
+ 'ARRAY' => array('VALUE'),
+ 'STRUCT' => array('VALUE'),
+ 'PARAM' => array('PARAMS'),
+ 'METHODNAME' => array('METHODCALL'),
+ 'PARAMS' => array('METHODCALL', 'METHODRESPONSE'),
+ 'MEMBER' => array('STRUCT'),
+ 'NAME' => array('MEMBER'),
+ 'DATA' => array('ARRAY'),
+ 'FAULT' => array('METHODRESPONSE'),
+ 'VALUE' => array('MEMBER', 'DATA', 'PARAM', 'FAULT')
+ );
+
+
+ // XML-RPC Responses
+ $this->xmlrpcerr['unknown_method'] = '1';
+ $this->xmlrpcstr['unknown_method'] = 'This is not a known method for this XML-RPC Server';
+ $this->xmlrpcerr['invalid_return'] = '2';
+ $this->xmlrpcstr['invalid_return'] = 'The XML data receieved was either invalid or not in the correct form for XML-RPC. Turn on debugging to examine the XML data further.';
+ $this->xmlrpcerr['incorrect_params'] = '3';
+ $this->xmlrpcstr['incorrect_params'] = 'Incorrect parameters were passed to method';
+ $this->xmlrpcerr['introspect_unknown'] = '4';
+ $this->xmlrpcstr['introspect_unknown'] = "Cannot inspect signature for request: method unknown";
+ $this->xmlrpcerr['http_error'] = '5';
+ $this->xmlrpcstr['http_error'] = "Did not receive a '200 OK' response from remote server.";
+ $this->xmlrpcerr['no_data'] = '6';
+ $this->xmlrpcstr['no_data'] ='No data received from server.';
+
+ $this->initialize($config);
+
+ log_message('debug', "XML-RPC Class Initialized");
+ }
+
+
+ //-------------------------------------
+ // Initialize Prefs
+ //-------------------------------------
+
+ function initialize($config = array())
+ {
+ if (sizeof($config) > 0)
+ {
+ foreach ($config as $key => $val)
+ {
+ if (isset($this->$key))
+ {
+ $this->$key = $val;
+ }
+ }
+ }
+ }
+ // END
+
+ //-------------------------------------
+ // Take URL and parse it
+ //-------------------------------------
+
+ function server($url, $port=80)
+ {
+ if (substr($url, 0, 4) != "http")
+ {
+ $url = "http://".$url;
+ }
+
+ $parts = parse_url($url);
+
+ $path = (!isset($parts['path'])) ? '/' : $parts['path'];
+
+ if (isset($parts['query']) && $parts['query'] != '')
+ {
+ $path .= '?'.$parts['query'];
+ }
+
+ $this->client = new XML_RPC_Client($path, $parts['host'], $port);
+ }
+ // END
+
+ //-------------------------------------
+ // Set Timeout
+ //-------------------------------------
+
+ function timeout($seconds=5)
+ {
+ if ( ! is_null($this->client) && is_int($seconds))
+ {
+ $this->client->timeout = $seconds;
+ }
+ }
+ // END
+
+ //-------------------------------------
+ // Set Methods
+ //-------------------------------------
+
+ function method($function)
+ {
+ $this->method = $function;
+ }
+ // END
+
+ //-------------------------------------
+ // Take Array of Data and Create Objects
+ //-------------------------------------
+
+ function request($incoming)
+ {
+ if ( ! is_array($incoming))
+ {
+ // Send Error
+ }
+
+ foreach($incoming as $key => $value)
+ {
+ $this->data[$key] = $this->values_parsing($value);
+ }
+ }
+ // END
+
+
+ //-------------------------------------
+ // Set Debug
+ //-------------------------------------
+
+ function set_debug($flag = TRUE)
+ {
+ $this->debug = ($flag == TRUE) ? TRUE : FALSE;
+ }
+
+ //-------------------------------------
+ // Values Parsing
+ //-------------------------------------
+
+ function values_parsing($value, $return = FALSE)
+ {
+ if (is_array($value) && isset($value['0']))
+ {
+ if ( ! isset($value['1']) OR ! isset($this->xmlrpcTypes[strtolower($value['1'])]))
+ {
+ $temp = new XML_RPC_Values($value['0'], 'string');
+ }
+ elseif(is_array($value['0']) && ($value['1'] == 'struct' OR $value['1'] == 'array'))
+ {
+ while (list($k) = each($value['0']))
+ {
+ $value['0'][$k] = $this->values_parsing($value['0'][$k], TRUE);
+ }
+
+ $temp = new XML_RPC_Values($value['0'], $value['1']);
+ }
+ else
+ {
+ $temp = new XML_RPC_Values($value['0'], $value['1']);
+ }
+ }
+ else
+ {
+ $temp = new XML_RPC_Values($value, 'string');
+ }
+
+ return $temp;
+ }
+ // END
+
+
+ //-------------------------------------
+ // Sends XML-RPC Request
+ //-------------------------------------
+
+ function send_request()
+ {
+ $this->message = new XML_RPC_Message($this->method,$this->data);
+ $this->message->debug = $this->debug;
+
+ if ( ! $this->result = $this->client->send($this->message))
+ {
+ $this->error = $this->result->errstr;
+ return FALSE;
+ }
+ elseif( ! is_object($this->result->val))
+ {
+ $this->error = $this->result->errstr;
+ return FALSE;
+ }
+
+ $this->response = $this->result->decode();
+
+ return TRUE;
+ }
+ // END
+
+ //-------------------------------------
+ // Returns Error
+ //-------------------------------------
+
+ function display_error()
+ {
+ return $this->error;
+ }
+ // END
+
+ //-------------------------------------
+ // Returns Remote Server Response
+ //-------------------------------------
+
+ function display_response()
+ {
+ return $this->response;
+ }
+ // END
+
+ //-------------------------------------
+ // Sends an Error Message for Server Request
+ //-------------------------------------
+
+ function send_error_message($number, $message)
+ {
+ return new XML_RPC_Response('0',$number, $message);
+ }
+ // END
+
+
+ //-------------------------------------
+ // Send Response for Server Request
+ //-------------------------------------
+
+ function send_response($response)
+ {
+ // $response should be array of values, which will be parsed
+ // based on their data and type into a valid group of XML-RPC values
+
+ $response = $this->values_parsing($response);
+
+ return new XML_RPC_Response($response);
+ }
+ // END
+
+} // END XML_RPC Class
+
+
+
+/**
+ * XML-RPC Client class
+ *
+ * @category XML-RPC
+ * @author Paul Burdick
+ * @link http://www.codeigniter.com/user_guide/libraries/xmlrpc.html
+ */
+class XML_RPC_Client extends CI_Xmlrpc
+{
+ var $path = '';
+ var $server = '';
+ var $port = 80;
+ var $errno = '';
+ var $errstring = '';
+ var $timeout = 5;
+ var $no_multicall = false;
+
+ function XML_RPC_Client($path, $server, $port=80)
+ {
+ parent::CI_Xmlrpc();
+
+ $this->port = $port;
+ $this->server = $server;
+ $this->path = $path;
+ }
+
+ function send($msg)
+ {
+ if (is_array($msg))
+ {
+ // Multi-call disabled
+ $r = new XML_RPC_Response(0, $this->xmlrpcerr['multicall_recursion'],$this->xmlrpcstr['multicall_recursion']);
+ return $r;
+ }
+
+ return $this->sendPayload($msg);
+ }
+
+ function sendPayload($msg)
+ {
+ $fp = @fsockopen($this->server, $this->port,$this->errno, $this->errstr, $this->timeout);
+
+ if (! is_resource($fp))
+ {
+ error_log($this->xmlrpcstr['http_error']);
+ $r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'],$this->xmlrpcstr['http_error']);
+ return $r;
+ }
+
+ if(empty($msg->payload))
+ {
+ // $msg = XML_RPC_Messages
+ $msg->createPayload();
+ }
+
+ $r = "\r\n";
+ $op = "POST {$this->path} HTTP/1.0$r";
+ $op .= "Host: {$this->server}$r";
+ $op .= "Content-Type: text/xml$r";
+ $op .= "User-Agent: {$this->xmlrpcName}$r";
+ $op .= "Content-Length: ".strlen($msg->payload). "$r$r";
+ $op .= $msg->payload;
+
+
+ if (!fputs($fp, $op, strlen($op)))
+ {
+ error_log($this->xmlrpcstr['http_error']);
+ $r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error']);
+ return $r;
+ }
+ $resp = $msg->parseResponse($fp);
+ fclose($fp);
+ return $resp;
+ }
+
+} // end class XML_RPC_Client
+
+
+/**
+ * XML-RPC Response class
+ *
+ * @category XML-RPC
+ * @author Paul Burdick
+ * @link http://www.codeigniter.com/user_guide/libraries/xmlrpc.html
+ */
+class XML_RPC_Response
+{
+ var $val = 0;
+ var $errno = 0;
+ var $errstr = '';
+ var $headers = array();
+
+ function XML_RPC_Response($val, $code = 0, $fstr = '')
+ {
+ if ($code != 0)
+ {
+ // error
+ $this->errno = $code;
+ $this->errstr = htmlentities($fstr);
+ }
+ else if (!is_object($val))
+ {
+ // programmer error, not an object
+ error_log("Invalid type '" . gettype($val) . "' (value: $val) passed to XML_RPC_Response. Defaulting to empty value.");
+ $this->val = new XML_RPC_Values();
+ }
+ else
+ {
+ $this->val = $val;
+ }
+ }
+
+ function faultCode()
+ {
+ return $this->errno;
+ }
+
+ function faultString()
+ {
+ return $this->errstr;
+ }
+
+ function value()
+ {
+ return $this->val;
+ }
+
+ function prepare_response()
+ {
+ $result = "<methodResponse>\n";
+ if ($this->errno)
+ {
+ $result .= '<fault>
+ <value>
+ <struct>
+ <member>
+ <name>faultCode</name>
+ <value><int>' . $this->errno . '</int></value>
+ </member>
+ <member>
+ <name>faultString</name>
+ <value><string>' . $this->errstr . '</string></value>
+ </member>
+ </struct>
+ </value>
+</fault>';
+ }
+ else
+ {
+ $result .= "<params>\n<param>\n" .
+ $this->val->serialize_class() .
+ "</param>\n</params>";
+ }
+ $result .= "\n</methodResponse>";
+ return $result;
+ }
+
+ function decode($array=FALSE)
+ {
+ $CI =& get_instance();
+
+ if ($array !== FALSE && is_array($array))
+ {
+ while (list($key) = each($array))
+ {
+ if (is_array($array[$key]))
+ {
+ $array[$key] = $this->decode($array[$key]);
+ }
+ else
+ {
+ $array[$key] = $CI->input->xss_clean($array[$key]);
+ }
+ }
+
+ $result = $array;
+ }
+ else
+ {
+ $result = $this->xmlrpc_decoder($this->val);
+
+ if (is_array($result))
+ {
+ $result = $this->decode($result);
+ }
+ else
+ {
+ $result = $CI->input->xss_clean($result);
+ }
+ }
+
+ return $result;
+ }
+
+
+
+ //-------------------------------------
+ // XML-RPC Object to PHP Types
+ //-------------------------------------
+
+ function xmlrpc_decoder($xmlrpc_val)
+ {
+ $kind = $xmlrpc_val->kindOf();
+
+ if($kind == 'scalar')
+ {
+ return $xmlrpc_val->scalarval();
+ }
+ elseif($kind == 'array')
+ {
+ reset($xmlrpc_val->me);
+ list($a,$b) = each($xmlrpc_val->me);
+ $size = sizeof($b);
+
+ $arr = array();
+
+ for($i = 0; $i < $size; $i++)
+ {
+ $arr[] = $this->xmlrpc_decoder($xmlrpc_val->me['array'][$i]);
+ }
+ return $arr;
+ }
+ elseif($kind == 'struct')
+ {
+ reset($xmlrpc_val->me['struct']);
+ $arr = array();
+
+ while(list($key,$value) = each($xmlrpc_val->me['struct']))
+ {
+ $arr[$key] = $this->xmlrpc_decoder($value);
+ }
+ return $arr;
+ }
+ }
+
+
+ //-------------------------------------
+ // ISO-8601 time to server or UTC time
+ //-------------------------------------
+
+ function iso8601_decode($time, $utc=0)
+ {
+ // return a timet in the localtime, or UTC
+ $t = 0;
+ if (ereg("([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})", $time, $regs))
+ {
+ if ($utc == 1)
+ $t = gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
+ else
+ $t = mktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
+ }
+ return $t;
+ }
+
+} // End Response Class
+
+
+
+/**
+ * XML-RPC Message class
+ *
+ * @category XML-RPC
+ * @author Paul Burdick
+ * @link http://www.codeigniter.com/user_guide/libraries/xmlrpc.html
+ */
+class XML_RPC_Message extends CI_Xmlrpc
+{
+ var $payload;
+ var $method_name;
+ var $params = array();
+ var $xh = array();
+
+ function XML_RPC_Message($method, $pars=0)
+ {
+ parent::CI_Xmlrpc();
+
+ $this->method_name = $method;
+ if (is_array($pars) && sizeof($pars) > 0)
+ {
+ for($i=0; $i<sizeof($pars); $i++)
+ {
+ // $pars[$i] = XML_RPC_Values
+ $this->params[] = $pars[$i];
+ }
+ }
+ }
+
+ //-------------------------------------
+ // Create Payload to Send
+ //-------------------------------------
+
+ function createPayload()
+ {
+ $this->payload = "<?xml version=\"1.0\"?".">\r\n<methodCall>\r\n";
+ $this->payload .= '<methodName>' . $this->method_name . "</methodName>\r\n";
+ $this->payload .= "<params>\r\n";
+
+ for($i=0; $i<sizeof($this->params); $i++)
+ {
+ // $p = XML_RPC_Values
+ $p = $this->params[$i];
+ $this->payload .= "<param>\r\n".$p->serialize_class()."</param>\r\n";
+ }
+
+ $this->payload .= "</params>\r\n</methodCall>\r\n";
+ }
+
+ //-------------------------------------
+ // Parse External XML-RPC Server's Response
+ //-------------------------------------
+
+ function parseResponse($fp)
+ {
+ $data = '';
+
+ while($datum = fread($fp, 4096))
+ {
+ $data .= $datum;
+ }
+
+ //-------------------------------------
+ // DISPLAY HTTP CONTENT for DEBUGGING
+ //-------------------------------------
+
+ if ($this->debug === TRUE)
+ {
+ echo "<pre>";
+ echo "---DATA---\n" . htmlspecialchars($data) . "\n---END DATA---\n\n";
+ echo "</pre>";
+ }
+
+ //-------------------------------------
+ // Check for data
+ //-------------------------------------
+
+ if($data == "")
+ {
+ error_log($this->xmlrpcstr['no_data']);
+ $r = new XML_RPC_Response(0, $this->xmlrpcerr['no_data'], $this->xmlrpcstr['no_data']);
+ return $r;
+ }
+
+
+ //-------------------------------------
+ // Check for HTTP 200 Response
+ //-------------------------------------
+
+ if(ereg("^HTTP",$data) && !ereg("^HTTP/[0-9\.]+ 200 ", $data))
+ {
+ $errstr= substr($data, 0, strpos($data, "\n")-1);
+ $r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error']. ' (' . $errstr . ')');
+ return $r;
+ }
+
+ //-------------------------------------
+ // Create and Set Up XML Parser
+ //-------------------------------------
+
+ $parser = xml_parser_create($this->xmlrpc_defencoding);
+
+ $this->xh[$parser] = array();
+ $this->xh[$parser]['isf'] = 0;
+ $this->xh[$parser]['ac'] = '';
+ $this->xh[$parser]['headers'] = array();
+ $this->xh[$parser]['stack'] = array();
+ $this->xh[$parser]['valuestack'] = array();
+ $this->xh[$parser]['isf_reason'] = 0;
+
+ xml_set_object($parser, $this);
+ xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
+ xml_set_element_handler($parser, 'open_tag', 'closing_tag');
+ xml_set_character_data_handler($parser, 'character_data');
+ //xml_set_default_handler($parser, 'default_handler');
+
+
+ //-------------------------------------
+ // GET HEADERS
+ //-------------------------------------
+
+ $lines = explode("\r\n", $data);
+ while (($line = array_shift($lines)))
+ {
+ if (strlen($line) < 1)
+ {
+ break;
+ }
+ $this->xh[$parser]['headers'][] = $line;
+ }
+ $data = implode("\r\n", $lines);
+
+
+ //-------------------------------------
+ // PARSE XML DATA
+ //-------------------------------------
+
+ if (!xml_parse($parser, $data, sizeof($data)))
+ {
+ $errstr = sprintf('XML error: %s at line %d',
+ xml_error_string(xml_get_error_code($parser)),
+ xml_get_current_line_number($parser));
+ //error_log($errstr);
+ $r = new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'], $this->xmlrpcstr['invalid_return']);
+ xml_parser_free($parser);
+ return $r;
+ }
+ xml_parser_free($parser);
+
+ // ---------------------------------------
+ // Got Ourselves Some Badness, It Seems
+ // ---------------------------------------
+
+ if ($this->xh[$parser]['isf'] > 1)
+ {
+ if ($this->debug === TRUE)
+ {
+ echo "---Invalid Return---\n";
+ echo $this->xh[$parser]['isf_reason'];
+ echo "---Invalid Return---\n\n";
+ }
+
+ $r = new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'],$this->xmlrpcstr['invalid_return'].' '.$this->xh[$parser]['isf_reason']);
+ return $r;
+ }
+ elseif ( ! is_object($this->xh[$parser]['value']))
+ {
+ $r = new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'],$this->xmlrpcstr['invalid_return'].' '.$this->xh[$parser]['isf_reason']);
+ return $r;
+ }
+
+ //-------------------------------------
+ // DISPLAY XML CONTENT for DEBUGGING
+ //-------------------------------------
+
+ if ($this->debug === TRUE)
+ {
+ echo "<pre>";
+
+ if (count($this->xh[$parser]['headers'] > 0))
+ {
+ echo "---HEADERS---\n";
+ foreach ($this->xh[$parser]['headers'] as $header)
+ {
+ echo "$header\n";
+ }
+ echo "---END HEADERS---\n\n";
+ }
+
+ echo "---DATA---\n" . htmlspecialchars($data) . "\n---END DATA---\n\n";
+
+ echo "---PARSED---\n" ;
+ var_dump($this->xh[$parser]['value']);
+ echo "\n---END PARSED---</pre>";
+ }
+
+ //-------------------------------------
+ // SEND RESPONSE
+ //-------------------------------------
+
+ $v = $this->xh[$parser]['value'];
+
+ if ($this->xh[$parser]['isf'])
+ {
+ $errno_v = $v->me['struct']['faultCode'];
+ $errstr_v = $v->me['struct']['faultString'];
+ $errno = $errno_v->scalarval();
+
+ if ($errno == 0)
+ {
+ // FAULT returned, errno needs to reflect that
+ $errno = -1;
+ }
+
+ $r = new XML_RPC_Response($v, $errno, $errstr_v->scalarval());
+ }
+ else
+ {
+ $r = new XML_RPC_Response($v);
+ }
+
+ $r->headers = $this->xh[$parser]['headers'];
+ return $r;
+ }
+
+ // ------------------------------------
+ // Begin Return Message Parsing section
+ // ------------------------------------
+
+ // quick explanation of components:
+ // ac - used to accumulate values
+ // isf - used to indicate a fault
+ // lv - used to indicate "looking for a value": implements
+ // the logic to allow values with no types to be strings
+ // params - used to store parameters in method calls
+ // method - used to store method name
+ // stack - array with parent tree of the xml element,
+ // used to validate the nesting of elements
+
+ //-------------------------------------
+ // Start Element Handler
+ //-------------------------------------
+
+ function open_tag($the_parser, $name, $attrs)
+ {
+ // If invalid nesting, then return
+ if ($this->xh[$the_parser]['isf'] > 1) return;
+
+ // Evaluate and check for correct nesting of XML elements
+
+ if (count($this->xh[$the_parser]['stack']) == 0)
+ {
+ if ($name != 'METHODRESPONSE' && $name != 'METHODCALL')
+ {
+ $this->xh[$the_parser]['isf'] = 2;
+ $this->xh[$the_parser]['isf_reason'] = 'Top level XML-RPC element is missing';
+ return;
+ }
+ }
+ else
+ {
+ // not top level element: see if parent is OK
+ if (!in_array($this->xh[$the_parser]['stack'][0], $this->valid_parents[$name], TRUE))
+ {
+ $this->xh[$the_parser]['isf'] = 2;
+ $this->xh[$the_parser]['isf_reason'] = "XML-RPC element $name cannot be child of ".$this->xh[$the_parser]['stack'][0];
+ return;
+ }
+ }
+
+ switch($name)
+ {
+ case 'STRUCT':
+ case 'ARRAY':
+ // Creates array for child elements
+
+ $cur_val = array('value' => array(),
+ 'type' => $name);
+
+ array_unshift($this->xh[$the_parser]['valuestack'], $cur_val);
+ break;
+ case 'METHODNAME':
+ case 'NAME':
+ $this->xh[$the_parser]['ac'] = '';
+ break;
+ case 'FAULT':
+ $this->xh[$the_parser]['isf'] = 1;
+ break;
+ case 'PARAM':
+ $this->xh[$the_parser]['value'] = null;
+ break;
+ case 'VALUE':
+ $this->xh[$the_parser]['vt'] = 'value';
+ $this->xh[$the_parser]['ac'] = '';
+ $this->xh[$the_parser]['lv'] = 1;
+ break;
+ case 'I4':
+ case 'INT':
+ case 'STRING':
+ case 'BOOLEAN':
+ case 'DOUBLE':
+ case 'DATETIME.ISO8601':
+ case 'BASE64':
+ if ($this->xh[$the_parser]['vt'] != 'value')
+ {
+ //two data elements inside a value: an error occurred!
+ $this->xh[$the_parser]['isf'] = 2;
+ $this->xh[$the_parser]['isf_reason'] = "'Twas a $name element following a ".$this->xh[$the_parser]['vt']." element inside a single value";
+ return;
+ }
+
+ $this->xh[$the_parser]['ac'] = '';
+ break;
+ case 'MEMBER':
+ // Set name of <member> to nothing to prevent errors later if no <name> is found
+ $this->xh[$the_parser]['valuestack'][0]['name'] = '';
+
+ // Set NULL value to check to see if value passed for this param/member
+ $this->xh[$the_parser]['value'] = null;
+ break;
+ case 'DATA':
+ case 'METHODCALL':
+ case 'METHODRESPONSE':
+ case 'PARAMS':
+ // valid elements that add little to processing
+ break;
+ default:
+ /// An Invalid Element is Found, so we have trouble
+ $this->xh[$the_parser]['isf'] = 2;
+ $this->xh[$the_parser]['isf_reason'] = "Invalid XML-RPC element found: $name";
+ break;
+ }
+
+ // Add current element name to stack, to allow validation of nesting
+ array_unshift($this->xh[$the_parser]['stack'], $name);
+
+ if ($name != 'VALUE') $this->xh[$the_parser]['lv'] = 0;
+ }
+ // END
+
+
+ //-------------------------------------
+ // End Element Handler
+ //-------------------------------------
+
+ function closing_tag($the_parser, $name)
+ {
+ if ($this->xh[$the_parser]['isf'] > 1) return;
+
+ // Remove current element from stack and set variable
+ // NOTE: If the XML validates, then we do not have to worry about
+ // the opening and closing of elements. Nesting is checked on the opening
+ // tag so we be safe there as well.
+
+ $curr_elem = array_shift($this->xh[$the_parser]['stack']);
+
+ switch($name)
+ {
+ case 'STRUCT':
+ case 'ARRAY':
+ $cur_val = array_shift($this->xh[$the_parser]['valuestack']);
+ $this->xh[$the_parser]['value'] = ( ! isset($cur_val['values'])) ? array() : $cur_val['values'];
+ $this->xh[$the_parser]['vt'] = strtolower($name);
+ break;
+ case 'NAME':
+ $this->xh[$the_parser]['valuestack'][0]['name'] = $this->xh[$the_parser]['ac'];
+ break;
+ case 'BOOLEAN':
+ case 'I4':
+ case 'INT':
+ case 'STRING':
+ case 'DOUBLE':
+ case 'DATETIME.ISO8601':
+ case 'BASE64':
+ $this->xh[$the_parser]['vt'] = strtolower($name);
+
+ if ($name == 'STRING')
+ {
+ $this->xh[$the_parser]['value'] = $this->xh[$the_parser]['ac'];
+ }
+ elseif ($name=='DATETIME.ISO8601')
+ {
+ $this->xh[$the_parser]['vt'] = $this->xmlrpcDateTime;
+ $this->xh[$the_parser]['value'] = $this->xh[$the_parser]['ac'];
+ }
+ elseif ($name=='BASE64')
+ {
+ $this->xh[$the_parser]['value'] = base64_decode($this->xh[$the_parser]['ac']);
+ }
+ elseif ($name=='BOOLEAN')
+ {
+ // Translated BOOLEAN values to TRUE AND FALSE
+ if ($this->xh[$the_parser]['ac'] == '1')
+ {
+ $this->xh[$the_parser]['value'] = TRUE;
+ }
+ else
+ {
+ $this->xh[$the_parser]['value'] = FALSE;
+ }
+ }
+ elseif ($name=='DOUBLE')
+ {
+ // we have a DOUBLE
+ // we must check that only 0123456789-.<space> are characters here
+ if (!ereg("^[+-]?[eE0123456789 \\t\\.]+$", $this->xh[$the_parser]['ac']))
+ {
+ $this->xh[$the_parser]['value'] = 'ERROR_NON_NUMERIC_FOUND';
+ }
+ else
+ {
+ $this->xh[$the_parser]['value'] = (double)$this->xh[$the_parser]['ac'];
+ }
+ }
+ else
+ {
+ // we have an I4/INT
+ // we must check that only 0123456789-<space> are characters here
+ if (!ereg("^[+-]?[0123456789 \\t]+$", $this->xh[$the_parser]['ac']))
+ {
+ $this->xh[$the_parser]['value'] = 'ERROR_NON_NUMERIC_FOUND';
+ }
+ else
+ {
+ $this->xh[$the_parser]['value'] = (int)$this->xh[$the_parser]['ac'];
+ }
+ }
+ $this->xh[$the_parser]['ac'] = '';
+ $this->xh[$the_parser]['lv'] = 3; // indicate we've found a value
+ break;
+ case 'VALUE':
+ // This if() detects if no scalar was inside <VALUE></VALUE>
+ if ($this->xh[$the_parser]['vt']=='value')
+ {
+ $this->xh[$the_parser]['value'] = $this->xh[$the_parser]['ac'];
+ $this->xh[$the_parser]['vt'] = $this->xmlrpcString;
+ }
+
+ // build the XML-RPC value out of the data received, and substitute it
+ $temp = new XML_RPC_Values($this->xh[$the_parser]['value'], $this->xh[$the_parser]['vt']);
+
+ if (count($this->xh[$the_parser]['valuestack']) && $this->xh[$the_parser]['valuestack'][0]['type'] == 'ARRAY')
+ {
+ // Array
+ $this->xh[$the_parser]['valuestack'][0]['values'][] = $temp;
+ }
+ else
+ {
+ // Struct
+ $this->xh[$the_parser]['value'] = $temp;
+ }
+ break;
+ case 'MEMBER':
+ $this->xh[$the_parser]['ac']='';
+
+ // If value add to array in the stack for the last element built
+ if ($this->xh[$the_parser]['value'])
+ {
+ $this->xh[$the_parser]['valuestack'][0]['values'][$this->xh[$the_parser]['valuestack'][0]['name']] = $this->xh[$the_parser]['value'];
+ }
+ break;
+ case 'DATA':
+ $this->xh[$the_parser]['ac']='';
+ break;
+ case 'PARAM':
+ if ($this->xh[$the_parser]['value'])
+ {
+ $this->xh[$the_parser]['params'][] = $this->xh[$the_parser]['value'];
+ }
+ break;
+ case 'METHODNAME':
+ $this->xh[$the_parser]['method'] = ereg_replace("^[\n\r\t ]+", '', $this->xh[$the_parser]['ac']);
+ break;
+ case 'PARAMS':
+ case 'FAULT':
+ case 'METHODCALL':
+ case 'METHORESPONSE':
+ // We're all good kids with nuthin' to do
+ break;
+ default:
+ // End of an Invalid Element. Taken care of during the opening tag though
+ break;
+ }
+ }
+
+ //-------------------------------------
+ // Parses Character Data
+ //-------------------------------------
+
+ function character_data($the_parser, $data)
+ {
+ if ($this->xh[$the_parser]['isf'] > 1) return; // XML Fault found already
+
+ // If a value has not been found
+ if ($this->xh[$the_parser]['lv'] != 3)
+ {
+ if ($this->xh[$the_parser]['lv'] == 1)
+ {
+ $this->xh[$the_parser]['lv'] = 2; // Found a value
+ }
+
+ if( ! @isset($this->xh[$the_parser]['ac']))
+ {
+ $this->xh[$the_parser]['ac'] = '';
+ }
+
+ $this->xh[$the_parser]['ac'] .= $data;
+ }
+ }
+
+
+ function addParam($par) { $this->params[]=$par; }
+
+ function output_parameters($array=FALSE)
+ {
+ $CI =& get_instance();
+
+ if ($array !== FALSE && is_array($array))
+ {
+ while (list($key) = each($array))
+ {
+ if (is_array($array[$key]))
+ {
+ $array[$key] = $this->output_parameters($array[$key]);
+ }
+ else
+ {
+ $array[$key] = $CI->input->xss_clean($array[$key]);
+ }
+ }
+
+ $parameters = $array;
+ }
+ else
+ {
+ $parameters = array();
+
+ for ($i = 0; $i < sizeof($this->params); $i++)
+ {
+ $a_param = $this->decode_message($this->params[$i]);
+
+ if (is_array($a_param))
+ {
+ $parameters[] = $this->output_parameters($a_param);
+ }
+ else
+ {
+ $parameters[] = $CI->input->xss_clean($a_param);
+ }
+ }
+ }
+
+ return $parameters;
+ }
+
+
+ function decode_message($param)
+ {
+ $kind = $param->kindOf();
+
+ if($kind == 'scalar')
+ {
+ return $param->scalarval();
+ }
+ elseif($kind == 'array')
+ {
+ reset($param->me);
+ list($a,$b) = each($param->me);
+
+ $arr = array();
+
+ for($i = 0; $i < sizeof($b); $i++)
+ {
+ $arr[] = $this->decode_message($param->me['array'][$i]);
+ }
+
+ return $arr;
+ }
+ elseif($kind == 'struct')
+ {
+ reset($param->me['struct']);
+
+ $arr = array();
+
+ while(list($key,$value) = each($param->me['struct']))
+ {
+ $arr[$key] = $this->decode_message($value);
+ }
+
+ return $arr;
+ }
+ }
+
+} // End XML_RPC_Messages class
+
+
+
+/**
+ * XML-RPC Values class
+ *
+ * @category XML-RPC
+ * @author Paul Burdick
+ * @link http://www.codeigniter.com/user_guide/libraries/xmlrpc.html
+ */
+class XML_RPC_Values extends CI_Xmlrpc
+{
+ var $me = array();
+ var $mytype = 0;
+
+ function XML_RPC_Values($val=-1, $type='')
+ {
+ parent::CI_Xmlrpc();
+
+ if ($val != -1 || $type != '')
+ {
+ $type = $type == '' ? 'string' : $type;
+
+ if ($this->xmlrpcTypes[$type] == 1)
+ {
+ $this->addScalar($val,$type);
+ }
+ elseif ($this->xmlrpcTypes[$type] == 2)
+ {
+ $this->addArray($val);
+ }
+ elseif ($this->xmlrpcTypes[$type] == 3)
+ {
+ $this->addStruct($val);
+ }
+ }
+ }
+
+ function addScalar($val, $type='string')
+ {
+ $typeof = $this->xmlrpcTypes[$type];
+
+ if ($this->mytype==1)
+ {
+ echo '<strong>XML_RPC_Values</strong>: scalar can have only one value<br />';
+ return 0;
+ }
+
+ if ($typeof != 1)
+ {
+ echo '<strong>XML_RPC_Values</strong>: not a scalar type (${typeof})<br />';
+ return 0;
+ }
+
+ if ($type == $this->xmlrpcBoolean)
+ {
+ if (strcasecmp($val,'true')==0 || $val==1 || ($val==true && strcasecmp($val,'false')))
+ {
+ $val = 1;
+ }
+ else
+ {
+ $val=0;
+ }
+ }
+
+ if ($this->mytype == 2)
+ {
+ // adding to an array here
+ $ar = $this->me['array'];
+ $ar[] = new XML_RPC_Values($val, $type);
+ $this->me['array'] = $ar;
+ }
+ else
+ {
+ // a scalar, so set the value and remember we're scalar
+ $this->me[$type] = $val;
+ $this->mytype = $typeof;
+ }
+ return 1;
+ }
+
+ function addArray($vals)
+ {
+ if ($this->mytype != 0)
+ {
+ echo '<strong>XML_RPC_Values</strong>: already initialized as a [' . $this->kindOf() . ']<br />';
+ return 0;
+ }
+
+ $this->mytype = $this->xmlrpcTypes['array'];
+ $this->me['array'] = $vals;
+ return 1;
+ }
+
+ function addStruct($vals)
+ {
+ if ($this->mytype != 0)
+ {
+ echo '<strong>XML_RPC_Values</strong>: already initialized as a [' . $this->kindOf() . ']<br />';
+ return 0;
+ }
+ $this->mytype = $this->xmlrpcTypes['struct'];
+ $this->me['struct'] = $vals;
+ return 1;
+ }
+
+ function kindOf()
+ {
+ switch($this->mytype)
+ {
+ case 3:
+ return 'struct';
+ break;
+ case 2:
+ return 'array';
+ break;
+ case 1:
+ return 'scalar';
+ break;
+ default:
+ return 'undef';
+ }
+ }
+
+ function serializedata($typ, $val)
+ {
+ $rs = '';
+
+ switch($this->xmlrpcTypes[$typ])
+ {
+ case 3:
+ // struct
+ $rs .= "<struct>\n";
+ reset($val);
+ while(list($key2, $val2) = each($val))
+ {
+ $rs .= "<member>\n<name>{$key2}</name>\n";
+ $rs .= $this->serializeval($val2);
+ $rs .= "</member>\n";
+ }
+ $rs .= '</struct>';
+ break;
+ case 2:
+ // array
+ $rs .= "<array>\n<data>\n";
+ for($i=0; $i < sizeof($val); $i++)
+ {
+ $rs .= $this->serializeval($val[$i]);
+ }
+ $rs.="</data>\n</array>\n";
+ break;
+ case 1:
+ // others
+ switch ($typ)
+ {
+ case $this->xmlrpcBase64:
+ $rs .= "<{$typ}>" . base64_encode($val) . "</{$typ}>\n";
+ break;
+ case $this->xmlrpcBoolean:
+ $rs .= "<{$typ}>" . ($val ? '1' : '0') . "</{$typ}>\n";
+ break;
+ case $this->xmlrpcString:
+ $rs .= "<{$typ}>" . htmlspecialchars($val). "</{$typ}>\n";
+ break;
+ default:
+ $rs .= "<{$typ}>{$val}</{$typ}>\n";
+ break;
+ }
+ default:
+ break;
+ }
+ return $rs;
+ }
+
+ function serialize_class()
+ {
+ return $this->serializeval($this);
+ }
+
+ function serializeval($o)
+ {
+
+ $ar = $o->me;
+ reset($ar);
+
+ list($typ, $val) = each($ar);
+ $rs = "<value>\n".$this->serializedata($typ, $val)."</value>\n";
+ return $rs;
+ }
+
+ function scalarval()
+ {
+ reset($this->me);
+ list($a,$b) = each($this->me);
+ return $b;
+ }
+
+
+ //-------------------------------------
+ // Encode time in ISO-8601 form.
+ //-------------------------------------
+
+ // Useful for sending time in XML-RPC
+
+ function iso8601_encode($time, $utc=0)
+ {
+ if ($utc == 1)
+ {
+ $t = strftime("%Y%m%dT%H:%M:%S", $time);
+ }
+ else
+ {
+ if (function_exists('gmstrftime'))
+ $t = gmstrftime("%Y%m%dT%H:%M:%S", $time);
+ else
+ $t = strftime("%Y%m%dT%H:%M:%S", $time - date('Z'));
+ }
+ return $t;
+ }
+
+}
+// END XML_RPC_Values Class
?> \ No newline at end of file
diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php
index bdb058e82..fe55e36d6 100644
--- a/system/libraries/Xmlrpcs.php
+++ b/system/libraries/Xmlrpcs.php
@@ -1,503 +1,503 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis, Paul Burdick
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-if ( ! function_exists('xml_parser_create'))
-{
- show_error('Your PHP installation does not support XML');
-}
-
-if ( ! class_exists('CI_Xmlrpc'))
-{
- show_error('You must load the Xmlrpc class before loading the Xmlrpcs class in order to create a server.');
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * XML-RPC server class
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category XML-RPC
- * @author Paul Burdick
- * @link http://www.codeigniter.com/user_guide/libraries/xmlrpc.html
- */
-class CI_Xmlrpcs extends CI_Xmlrpc
-{
- var $methods = array(); //array of methods mapped to function names and signatures
- var $debug_msg = ''; // Debug Message
- var $system_methods = array(); // XML RPC Server methods
- var $controller_obj;
-
-
- //-------------------------------------
- // Constructor, more or less
- //-------------------------------------
-
- function CI_Xmlrpcs($config=array())
- {
- parent::CI_Xmlrpc();
- $this->set_system_methods();
-
- if (isset($config['functions']) && is_array($config['functions']))
- {
- $this->methods = $config['functions'];
- }
-
- log_message('debug', "XML-RPC Server Class Initialized");
- }
-
- //-------------------------------------
- // Initialize Prefs and Serve
- //-------------------------------------
-
- function initialize($config=array())
- {
- if (isset($config['functions']) && is_array($config['functions']))
- {
- $this->methods = $config['functions'];
- }
-
- if (isset($config['debug']))
- {
- $this->debug = $config['debug'];
- }
- }
-
- //-------------------------------------
- // Setting of System Methods
- //-------------------------------------
-
- function set_system_methods ()
- {
- $system_methods = array(
- 'system.listMethods' => array(
- 'function' => 'this.listMethods',
- 'signature' => array(array($this->xmlrpcArray, $this->xmlrpcString), array($this->xmlrpcArray)),
- 'docstring' => 'Returns an array of available methods on this server'),
- 'system.methodHelp' => array(
- 'function' => 'this.methodHelp',
- 'signature' => array(array($this->xmlrpcString, $this->xmlrpcString)),
- 'docstring' => 'Returns a documentation string for the specified method'),
- 'system.methodSignature' => array(
- 'function' => 'this.methodSignature',
- 'signature' => array(array($this->xmlrpcArray, $this->xmlrpcString)),
- 'docstring' => 'Returns an array describing the return type and required parameters of a method'),
- 'system.multicall' => array(
- 'function' => 'this.multicall',
- 'signature' => array(array($this->xmlrpcArray, $this->xmlrpcArray)),
- 'docstring' => 'Combine multiple RPC calls in one request. See http://www.xmlrpc.com/discuss/msgReader$1208 for details')
- );
- }
-
-
- //-------------------------------------
- // Main Server Function
- //-------------------------------------
-
- function serve()
- {
- $r = $this->parseRequest();
- $payload = '<?xml version="1.0" encoding="'.$this->xmlrpc_defencoding.'"?'.'>'."\n";
- $payload .= $this->debug_msg;
- $payload .= $r->prepare_response();
-
- header("Content-Type: text/xml");
- header("Content-Length: ".strlen($payload));
- echo $payload;
- }
-
- //-------------------------------------
- // Add Method to Class
- //-------------------------------------
-
- function add_to_map($methodname,$function,$sig,$doc)
- {
- $this->methods[$methodname] = array(
- 'function' => $function,
- 'signature' => $sig,
- 'docstring' => $doc
- );
- }
-
-
- //-------------------------------------
- // Parse Server Request
- //-------------------------------------
-
- function parseRequest($data='')
- {
- global $HTTP_RAW_POST_DATA;
-
- //-------------------------------------
- // Get Data
- //-------------------------------------
-
- if ($data == '')
- {
- $data = $HTTP_RAW_POST_DATA;
- }
-
-
- //-------------------------------------
- // Set up XML Parser
- //-------------------------------------
-
- $parser = xml_parser_create($this->xmlrpc_defencoding);
- $parser_object = new XML_RPC_Message("filler");
-
- $parser_object->xh[$parser] = array();
- $parser_object->xh[$parser]['isf'] = 0;
- $parser_object->xh[$parser]['isf_reason'] = '';
- $parser_object->xh[$parser]['params'] = array();
- $parser_object->xh[$parser]['stack'] = array();
- $parser_object->xh[$parser]['valuestack'] = array();
- $parser_object->xh[$parser]['method'] = '';
-
- xml_set_object($parser, $parser_object);
- xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
- xml_set_element_handler($parser, 'open_tag', 'closing_tag');
- xml_set_character_data_handler($parser, 'character_data');
- //xml_set_default_handler($parser, 'default_handler');
-
-
- //-------------------------------------
- // PARSE + PROCESS XML DATA
- //-------------------------------------
-
- if ( ! xml_parse($parser, $data, 1))
- {
- // return XML error as a faultCode
- $r = new XML_RPC_Response(0,
- $this->xmlrpcerrxml + xml_get_error_code($parser),
- sprintf('XML error: %s at line %d',
- xml_error_string(xml_get_error_code($parser)),
- xml_get_current_line_number($parser)));
- xml_parser_free($parser);
- }
- elseif($parser_object->xh[$parser]['isf'])
- {
- return new XML_RPC_Response(0,
- $this->xmlrpcerr['invalid_return'],
- $this->xmlrpcstr['invalid_retrun']);
- }
- else
- {
- xml_parser_free($parser);
-
- $m = new XML_RPC_Message($parser_object->xh[$parser]['method']);
- $plist='';
-
- for($i=0; $i < sizeof($parser_object->xh[$parser]['params']); $i++)
- {
- $plist .= "$i - " . print_r(get_object_vars($parser_object->xh[$parser]['params'][$i]), TRUE). ";\n";
-
- $m->addParam($parser_object->xh[$parser]['params'][$i]);
- }
-
- if ($this->debug === TRUE)
- {
- echo "<pre>";
- echo "---PLIST---\n" . $plist . "\n---PLIST END---\n\n";
- echo "</pre>";
- }
-
- $r = $this->_execute($m);
- }
-
- //-------------------------------------
- // SET DEBUGGING MESSAGE
- //-------------------------------------
-
- if ($this->debug === TRUE)
- {
- $this->debug_msg = "<!-- DEBUG INFO:\n\n".$plist."\n END DEBUG-->\n";
- }
-
- return $r;
- }
-
- //-------------------------------------
- // Executes the Method
- //-------------------------------------
-
- function _execute($m)
- {
- $methName = $m->method_name;
-
- // Check to see if it is a system call
- // If so, load the system_methods
- $sysCall = ereg("^system\.", $methName);
- $methods = $sysCall ? $this->system_methods : $this->methods;
-
- //-------------------------------------
- // Check for Function
- //-------------------------------------
-
- if (!isset($methods[$methName]['function']))
- {
- return new XML_RPC_Response(0,
- $this->xmlrpcerr['unknown_method'],
- $this->xmlrpcstr['unknown_method']);
- }
- else
- {
- // See if we are calling function in an object
-
- $method_parts = explode(".",$methods[$methName]['function']);
- $objectCall = (isset($method_parts['1']) && $method_parts['1'] != "") ? true : false;
-
- if ($objectCall && !is_callable(array($method_parts['0'],$method_parts['1'])))
- {
- return new XML_RPC_Response(0,
- $this->xmlrpcerr['unknown_method'],
- $this->xmlrpcstr['unknown_method']);
- }
- elseif (!$objectCall && !is_callable($methods[$methName]['function']))
- {
- return new XML_RPC_Response(0,
- $this->xmlrpcerr['unknown_method'],
- $this->xmlrpcstr['unknown_method']);
- }
- }
-
- //-------------------------------------
- // Checking Methods Signature
- //-------------------------------------
-
- if (isset($methods[$methName]['signature']))
- {
- $sig = $methods[$methName]['signature'];
- for($i=0; $i<sizeof($sig); $i++)
- {
- $current_sig = $sig[$i];
-
- if (sizeof($current_sig) == sizeof($m->params)+1)
- {
- for($n=0; $n < sizeof($m->params); $n++)
- {
- $p = $m->params[$n];
- $pt = ($p->kindOf() == 'scalar') ? $p->scalartyp() : $p->kindOf();
-
- if ($pt != $current_sig[$n+1])
- {
- $pno = $n+1;
- $wanted = $current_sig[$n+1];
-
- return new XML_RPC_Response(0,
- $this->xmlrpcerr['incorrect_params'],
- $this->xmlrpcstr['incorrect_params'] .
- ": Wanted {$wanted}, got {$pt} at param {$pno})");
- }
- }
- }
- }
- }
-
- //-------------------------------------
- // Calls the Function
- //-------------------------------------
-
- if ($objectCall)
- {
- if ($method_parts['1'] == "this")
- {
- return call_user_func(array($this, $method_parts['0']), $m);
- }
- else
- {
- $CI =& get_instance();
- return $CI->$method_parts['1']($m);
- //$class = new $method_parts['0'];
- //return $class->$method_parts['1']($m);
- //return call_user_func(array(&$method_parts['0'],$method_parts['1']), $m);
- }
- }
- else
- {
- return call_user_func($methods[$methName]['function'], $m);
- }
- }
-
-
- //-------------------------------------
- // Server Function: List Methods
- //-------------------------------------
-
- function listMethods($m)
- {
- $v = new XML_RPC_Values();
- $output = array();
- foreach($this->$methods as $key => $value)
- {
- $output[] = new XML_RPC_Values($key, 'string');
- }
-
- foreach($this->system_methods as $key => $value)
- {
- $output[]= new XML_RPC_Values($key, 'string');
- }
-
- $v->addArray($output);
- return new XML_RPC_Response($v);
- }
-
- //-------------------------------------
- // Server Function: Return Signature for Method
- //-------------------------------------
-
- function methodSignature($m)
- {
- $methName = $m->getParam(0);
- $method_name = $methName->scalarval();
-
- $methods = ereg("^system\.", $method_name) ? $this->system_methods : $this->methods;
-
- if (isset($methods[$method_name]))
- {
- if ($methods[$method_name]['signature'])
- {
- $sigs = array();
- $signature = $methods[$method_name]['signature'];
-
- for($i=0; $i < sizeof($signature); $i++)
- {
- $cursig = array();
- $inSig = $signature[$i];
- for($j=0; $j<sizeof($inSig); $j++)
- {
- $cursig[]= new XML_RPC_Values($inSig[$j], 'string');
- }
- $sigs[]= new XML_RPC_Values($cursig, 'array');
- }
- $r = new XML_RPC_Response(new XML_RPC_Values($sigs, 'array'));
- }
- else
- {
- $r = new XML_RPC_Response(new XML_RPC_Values('undef', 'string'));
- }
- }
- else
- {
- $r = new XML_RPC_Response(0,$this->xmlrpcerr['introspect_unknown'], $this->xmlrpcstr['introspect_unknown']);
- }
- return $r;
- }
-
- //-------------------------------------
- // Server Function: Doc String for Method
- //-------------------------------------
-
- function methodHelp($m)
- {
- $methName = $m->getParam(0);
- $method_name = $methName->scalarval();
-
- $methods = ereg("^system\.", $method_name) ? $this->system_methods : $this->methods;
-
- if (isset($methods[$methName]))
- {
- $docstring = isset($methods[$method_name]['docstring']) ? $methods[$method_name]['docstring'] : '';
- $r = new XML_RPC_Response(new XML_RPC_Values($docstring, 'string'));
- }
- else
- {
- $r = new XML_RPC_Response(0, $this->xmlrpcerr['introspect_unknown'], $this->xmlrpcstr['introspect_unknown']);
- }
- return $r;
- }
-
- //-------------------------------------
- // Server Function: Multi-call
- //-------------------------------------
-
- function multicall($m)
- {
- $calls = $m->getParam(0);
- list($a,$b)=each($calls->me);
- $result = array();
-
- for ($i = 0; $i < sizeof($b); $i++)
- {
- $call = $calls->me['array'][$i];
- $result[$i] = $this->do_multicall($call);
- }
-
- return new XML_RPC_Response(new XML_RPC_Values($result, 'array'));
- }
-
-
- //-------------------------------------
- // Multi-call Function: Error Handling
- //-------------------------------------
-
- function multicall_error($err)
- {
- $str = is_string($err) ? $this->xmlrpcstr["multicall_${err}"] : $err->faultString();
- $code = is_string($err) ? $this->xmlrpcerr["multicall_${err}"] : $err->faultCode();
-
- $struct['faultCode'] = new XML_RPC_Values($code, 'int');
- $struct['faultString'] = new XML_RPC_Values($str, 'string');
-
- return new XML_RPC_Values($struct, 'struct');
- }
-
-
- //-------------------------------------
- // Multi-call Function: Processes method
- //-------------------------------------
-
- function do_multicall($call)
- {
- if ($call->kindOf() != 'struct')
- return $this->multicall_error('notstruct');
- elseif (!$methName = $call->me['struct']['methodName'])
- return $this->multicall_error('nomethod');
-
- list($scalar_type,$scalar_value)=each($methName->me);
- $scalar_type = $scalar_type == $this->xmlrpcI4 ? $this->xmlrpcInt : $scalar_type;
-
- if ($methName->kindOf() != 'scalar' || $scalar_type != 'string')
- return $this->multicall_error('notstring');
- elseif ($scalar_value == 'system.multicall')
- return $this->multicall_error('recursion');
- elseif (!$params = $call->me['struct']['params'])
- return $this->multicall_error('noparams');
- elseif ($params->kindOf() != 'array')
- return $this->multicall_error('notarray');
-
- list($a,$b)=each($params->me);
- $numParams = sizeof($b);
-
- $msg = new XML_RPC_Message($scalar_value);
- for ($i = 0; $i < $numParams; $i++)
- {
- $msg->params[] = $params->me['array'][$i];
- }
-
- $result = $this->_execute($msg);
-
- if ($result->faultCode() != 0)
- {
- return $this->multicall_error($result);
- }
-
- return new XML_RPC_Values(array($result->value()), 'array');
- }
-
-}
-// END XML_RPC_Server class
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis, Paul Burdick
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+if ( ! function_exists('xml_parser_create'))
+{
+ show_error('Your PHP installation does not support XML');
+}
+
+if ( ! class_exists('CI_Xmlrpc'))
+{
+ show_error('You must load the Xmlrpc class before loading the Xmlrpcs class in order to create a server.');
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * XML-RPC server class
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category XML-RPC
+ * @author Paul Burdick
+ * @link http://www.codeigniter.com/user_guide/libraries/xmlrpc.html
+ */
+class CI_Xmlrpcs extends CI_Xmlrpc
+{
+ var $methods = array(); //array of methods mapped to function names and signatures
+ var $debug_msg = ''; // Debug Message
+ var $system_methods = array(); // XML RPC Server methods
+ var $controller_obj;
+
+
+ //-------------------------------------
+ // Constructor, more or less
+ //-------------------------------------
+
+ function CI_Xmlrpcs($config=array())
+ {
+ parent::CI_Xmlrpc();
+ $this->set_system_methods();
+
+ if (isset($config['functions']) && is_array($config['functions']))
+ {
+ $this->methods = $config['functions'];
+ }
+
+ log_message('debug', "XML-RPC Server Class Initialized");
+ }
+
+ //-------------------------------------
+ // Initialize Prefs and Serve
+ //-------------------------------------
+
+ function initialize($config=array())
+ {
+ if (isset($config['functions']) && is_array($config['functions']))
+ {
+ $this->methods = $config['functions'];
+ }
+
+ if (isset($config['debug']))
+ {
+ $this->debug = $config['debug'];
+ }
+ }
+
+ //-------------------------------------
+ // Setting of System Methods
+ //-------------------------------------
+
+ function set_system_methods ()
+ {
+ $system_methods = array(
+ 'system.listMethods' => array(
+ 'function' => 'this.listMethods',
+ 'signature' => array(array($this->xmlrpcArray, $this->xmlrpcString), array($this->xmlrpcArray)),
+ 'docstring' => 'Returns an array of available methods on this server'),
+ 'system.methodHelp' => array(
+ 'function' => 'this.methodHelp',
+ 'signature' => array(array($this->xmlrpcString, $this->xmlrpcString)),
+ 'docstring' => 'Returns a documentation string for the specified method'),
+ 'system.methodSignature' => array(
+ 'function' => 'this.methodSignature',
+ 'signature' => array(array($this->xmlrpcArray, $this->xmlrpcString)),
+ 'docstring' => 'Returns an array describing the return type and required parameters of a method'),
+ 'system.multicall' => array(
+ 'function' => 'this.multicall',
+ 'signature' => array(array($this->xmlrpcArray, $this->xmlrpcArray)),
+ 'docstring' => 'Combine multiple RPC calls in one request. See http://www.xmlrpc.com/discuss/msgReader$1208 for details')
+ );
+ }
+
+
+ //-------------------------------------
+ // Main Server Function
+ //-------------------------------------
+
+ function serve()
+ {
+ $r = $this->parseRequest();
+ $payload = '<?xml version="1.0" encoding="'.$this->xmlrpc_defencoding.'"?'.'>'."\n";
+ $payload .= $this->debug_msg;
+ $payload .= $r->prepare_response();
+
+ header("Content-Type: text/xml");
+ header("Content-Length: ".strlen($payload));
+ echo $payload;
+ }
+
+ //-------------------------------------
+ // Add Method to Class
+ //-------------------------------------
+
+ function add_to_map($methodname,$function,$sig,$doc)
+ {
+ $this->methods[$methodname] = array(
+ 'function' => $function,
+ 'signature' => $sig,
+ 'docstring' => $doc
+ );
+ }
+
+
+ //-------------------------------------
+ // Parse Server Request
+ //-------------------------------------
+
+ function parseRequest($data='')
+ {
+ global $HTTP_RAW_POST_DATA;
+
+ //-------------------------------------
+ // Get Data
+ //-------------------------------------
+
+ if ($data == '')
+ {
+ $data = $HTTP_RAW_POST_DATA;
+ }
+
+
+ //-------------------------------------
+ // Set up XML Parser
+ //-------------------------------------
+
+ $parser = xml_parser_create($this->xmlrpc_defencoding);
+ $parser_object = new XML_RPC_Message("filler");
+
+ $parser_object->xh[$parser] = array();
+ $parser_object->xh[$parser]['isf'] = 0;
+ $parser_object->xh[$parser]['isf_reason'] = '';
+ $parser_object->xh[$parser]['params'] = array();
+ $parser_object->xh[$parser]['stack'] = array();
+ $parser_object->xh[$parser]['valuestack'] = array();
+ $parser_object->xh[$parser]['method'] = '';
+
+ xml_set_object($parser, $parser_object);
+ xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
+ xml_set_element_handler($parser, 'open_tag', 'closing_tag');
+ xml_set_character_data_handler($parser, 'character_data');
+ //xml_set_default_handler($parser, 'default_handler');
+
+
+ //-------------------------------------
+ // PARSE + PROCESS XML DATA
+ //-------------------------------------
+
+ if ( ! xml_parse($parser, $data, 1))
+ {
+ // return XML error as a faultCode
+ $r = new XML_RPC_Response(0,
+ $this->xmlrpcerrxml + xml_get_error_code($parser),
+ sprintf('XML error: %s at line %d',
+ xml_error_string(xml_get_error_code($parser)),
+ xml_get_current_line_number($parser)));
+ xml_parser_free($parser);
+ }
+ elseif($parser_object->xh[$parser]['isf'])
+ {
+ return new XML_RPC_Response(0,
+ $this->xmlrpcerr['invalid_return'],
+ $this->xmlrpcstr['invalid_retrun']);
+ }
+ else
+ {
+ xml_parser_free($parser);
+
+ $m = new XML_RPC_Message($parser_object->xh[$parser]['method']);
+ $plist='';
+
+ for($i=0; $i < sizeof($parser_object->xh[$parser]['params']); $i++)
+ {
+ $plist .= "$i - " . print_r(get_object_vars($parser_object->xh[$parser]['params'][$i]), TRUE). ";\n";
+
+ $m->addParam($parser_object->xh[$parser]['params'][$i]);
+ }
+
+ if ($this->debug === TRUE)
+ {
+ echo "<pre>";
+ echo "---PLIST---\n" . $plist . "\n---PLIST END---\n\n";
+ echo "</pre>";
+ }
+
+ $r = $this->_execute($m);
+ }
+
+ //-------------------------------------
+ // SET DEBUGGING MESSAGE
+ //-------------------------------------
+
+ if ($this->debug === TRUE)
+ {
+ $this->debug_msg = "<!-- DEBUG INFO:\n\n".$plist."\n END DEBUG-->\n";
+ }
+
+ return $r;
+ }
+
+ //-------------------------------------
+ // Executes the Method
+ //-------------------------------------
+
+ function _execute($m)
+ {
+ $methName = $m->method_name;
+
+ // Check to see if it is a system call
+ // If so, load the system_methods
+ $sysCall = ereg("^system\.", $methName);
+ $methods = $sysCall ? $this->system_methods : $this->methods;
+
+ //-------------------------------------
+ // Check for Function
+ //-------------------------------------
+
+ if (!isset($methods[$methName]['function']))
+ {
+ return new XML_RPC_Response(0,
+ $this->xmlrpcerr['unknown_method'],
+ $this->xmlrpcstr['unknown_method']);
+ }
+ else
+ {
+ // See if we are calling function in an object
+
+ $method_parts = explode(".",$methods[$methName]['function']);
+ $objectCall = (isset($method_parts['1']) && $method_parts['1'] != "") ? true : false;
+
+ if ($objectCall && !is_callable(array($method_parts['0'],$method_parts['1'])))
+ {
+ return new XML_RPC_Response(0,
+ $this->xmlrpcerr['unknown_method'],
+ $this->xmlrpcstr['unknown_method']);
+ }
+ elseif (!$objectCall && !is_callable($methods[$methName]['function']))
+ {
+ return new XML_RPC_Response(0,
+ $this->xmlrpcerr['unknown_method'],
+ $this->xmlrpcstr['unknown_method']);
+ }
+ }
+
+ //-------------------------------------
+ // Checking Methods Signature
+ //-------------------------------------
+
+ if (isset($methods[$methName]['signature']))
+ {
+ $sig = $methods[$methName]['signature'];
+ for($i=0; $i<sizeof($sig); $i++)
+ {
+ $current_sig = $sig[$i];
+
+ if (sizeof($current_sig) == sizeof($m->params)+1)
+ {
+ for($n=0; $n < sizeof($m->params); $n++)
+ {
+ $p = $m->params[$n];
+ $pt = ($p->kindOf() == 'scalar') ? $p->scalartyp() : $p->kindOf();
+
+ if ($pt != $current_sig[$n+1])
+ {
+ $pno = $n+1;
+ $wanted = $current_sig[$n+1];
+
+ return new XML_RPC_Response(0,
+ $this->xmlrpcerr['incorrect_params'],
+ $this->xmlrpcstr['incorrect_params'] .
+ ": Wanted {$wanted}, got {$pt} at param {$pno})");
+ }
+ }
+ }
+ }
+ }
+
+ //-------------------------------------
+ // Calls the Function
+ //-------------------------------------
+
+ if ($objectCall)
+ {
+ if ($method_parts['1'] == "this")
+ {
+ return call_user_func(array($this, $method_parts['0']), $m);
+ }
+ else
+ {
+ $CI =& get_instance();
+ return $CI->$method_parts['1']($m);
+ //$class = new $method_parts['0'];
+ //return $class->$method_parts['1']($m);
+ //return call_user_func(array(&$method_parts['0'],$method_parts['1']), $m);
+ }
+ }
+ else
+ {
+ return call_user_func($methods[$methName]['function'], $m);
+ }
+ }
+
+
+ //-------------------------------------
+ // Server Function: List Methods
+ //-------------------------------------
+
+ function listMethods($m)
+ {
+ $v = new XML_RPC_Values();
+ $output = array();
+ foreach($this->$methods as $key => $value)
+ {
+ $output[] = new XML_RPC_Values($key, 'string');
+ }
+
+ foreach($this->system_methods as $key => $value)
+ {
+ $output[]= new XML_RPC_Values($key, 'string');
+ }
+
+ $v->addArray($output);
+ return new XML_RPC_Response($v);
+ }
+
+ //-------------------------------------
+ // Server Function: Return Signature for Method
+ //-------------------------------------
+
+ function methodSignature($m)
+ {
+ $methName = $m->getParam(0);
+ $method_name = $methName->scalarval();
+
+ $methods = ereg("^system\.", $method_name) ? $this->system_methods : $this->methods;
+
+ if (isset($methods[$method_name]))
+ {
+ if ($methods[$method_name]['signature'])
+ {
+ $sigs = array();
+ $signature = $methods[$method_name]['signature'];
+
+ for($i=0; $i < sizeof($signature); $i++)
+ {
+ $cursig = array();
+ $inSig = $signature[$i];
+ for($j=0; $j<sizeof($inSig); $j++)
+ {
+ $cursig[]= new XML_RPC_Values($inSig[$j], 'string');
+ }
+ $sigs[]= new XML_RPC_Values($cursig, 'array');
+ }
+ $r = new XML_RPC_Response(new XML_RPC_Values($sigs, 'array'));
+ }
+ else
+ {
+ $r = new XML_RPC_Response(new XML_RPC_Values('undef', 'string'));
+ }
+ }
+ else
+ {
+ $r = new XML_RPC_Response(0,$this->xmlrpcerr['introspect_unknown'], $this->xmlrpcstr['introspect_unknown']);
+ }
+ return $r;
+ }
+
+ //-------------------------------------
+ // Server Function: Doc String for Method
+ //-------------------------------------
+
+ function methodHelp($m)
+ {
+ $methName = $m->getParam(0);
+ $method_name = $methName->scalarval();
+
+ $methods = ereg("^system\.", $method_name) ? $this->system_methods : $this->methods;
+
+ if (isset($methods[$methName]))
+ {
+ $docstring = isset($methods[$method_name]['docstring']) ? $methods[$method_name]['docstring'] : '';
+ $r = new XML_RPC_Response(new XML_RPC_Values($docstring, 'string'));
+ }
+ else
+ {
+ $r = new XML_RPC_Response(0, $this->xmlrpcerr['introspect_unknown'], $this->xmlrpcstr['introspect_unknown']);
+ }
+ return $r;
+ }
+
+ //-------------------------------------
+ // Server Function: Multi-call
+ //-------------------------------------
+
+ function multicall($m)
+ {
+ $calls = $m->getParam(0);
+ list($a,$b)=each($calls->me);
+ $result = array();
+
+ for ($i = 0; $i < sizeof($b); $i++)
+ {
+ $call = $calls->me['array'][$i];
+ $result[$i] = $this->do_multicall($call);
+ }
+
+ return new XML_RPC_Response(new XML_RPC_Values($result, 'array'));
+ }
+
+
+ //-------------------------------------
+ // Multi-call Function: Error Handling
+ //-------------------------------------
+
+ function multicall_error($err)
+ {
+ $str = is_string($err) ? $this->xmlrpcstr["multicall_${err}"] : $err->faultString();
+ $code = is_string($err) ? $this->xmlrpcerr["multicall_${err}"] : $err->faultCode();
+
+ $struct['faultCode'] = new XML_RPC_Values($code, 'int');
+ $struct['faultString'] = new XML_RPC_Values($str, 'string');
+
+ return new XML_RPC_Values($struct, 'struct');
+ }
+
+
+ //-------------------------------------
+ // Multi-call Function: Processes method
+ //-------------------------------------
+
+ function do_multicall($call)
+ {
+ if ($call->kindOf() != 'struct')
+ return $this->multicall_error('notstruct');
+ elseif (!$methName = $call->me['struct']['methodName'])
+ return $this->multicall_error('nomethod');
+
+ list($scalar_type,$scalar_value)=each($methName->me);
+ $scalar_type = $scalar_type == $this->xmlrpcI4 ? $this->xmlrpcInt : $scalar_type;
+
+ if ($methName->kindOf() != 'scalar' || $scalar_type != 'string')
+ return $this->multicall_error('notstring');
+ elseif ($scalar_value == 'system.multicall')
+ return $this->multicall_error('recursion');
+ elseif (!$params = $call->me['struct']['params'])
+ return $this->multicall_error('noparams');
+ elseif ($params->kindOf() != 'array')
+ return $this->multicall_error('notarray');
+
+ list($a,$b)=each($params->me);
+ $numParams = sizeof($b);
+
+ $msg = new XML_RPC_Message($scalar_value);
+ for ($i = 0; $i < $numParams; $i++)
+ {
+ $msg->params[] = $params->me['array'][$i];
+ }
+
+ $result = $this->_execute($msg);
+
+ if ($result->faultCode() != 0)
+ {
+ return $this->multicall_error($result);
+ }
+
+ return new XML_RPC_Values(array($result->value()), 'array');
+ }
+
+}
+// END XML_RPC_Server class
+
?> \ No newline at end of file
diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php
index 1ff175fe2..377c38741 100644
--- a/system/libraries/Zip.php
+++ b/system/libraries/Zip.php
@@ -1,380 +1,380 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Zip Compression Class
- *
- * This class is based on a library I found at Zend:
- * http://www.zend.com/codex.php?id=696&single=1
- *
- * The original library is a little rough around the edges so I
- * refactored it and added several additional methods -- Rick Ellis
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Encryption
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/libraries/zip.html
- */
-class CI_Zip {
-
- var $zipfile = '';
- var $zipdata = array();
- var $directory = array();
- var $offset = 0;
-
- function CI_Zip()
- {
- log_message('debug', "Zip Compression Class Initialized");
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Add Directory
- *
- * Lets you add a virtual directory into which you can place files.
- *
- * @access public
- * @param mixed the directory name. Can be string or array
- * @return void
- */
- function add_dir($directory)
- {
- foreach ((array)$directory as $dir)
- {
- if ( ! preg_match("|.+/$|", $dir))
- {
- $dir .= '/';
- }
-
- $this->_add_dir($dir);
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Add Directory
- *
- * @access private
- * @param string the directory name
- * @return void
- */
- function _add_dir($dir)
- {
- $dir = str_replace("\\", "/", $dir);
-
- $this->zipdata[] = "\x50\x4b\x03\x04\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- .pack('V', 0)
- .pack('V', 0)
- .pack('V', 0)
- .pack('v', strlen($dir))
- .pack('v', 0)
- .$dir
- .pack('V', 0)
- .pack('V', 0)
- .pack('V', 0);
-
- $newoffset = strlen(implode('', $this->zipdata));
-
- $record = "\x50\x4b\x01\x02\x00\x00\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- .pack('V',0)
- .pack('V',0)
- .pack('V',0)
- .pack('v', strlen($dir))
- .pack('v', 0)
- .pack('v', 0)
- .pack('v', 0)
- .pack('v', 0)
- .pack('V', 16)
- .pack('V', $this->offset)
- .$dir;
-
- $this->offset = $newoffset;
- $this->directory[] = $record;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Add Data to Zip
- *
- * Lets you add files to the archive. If the path is included
- * in the filename it will be placed within a directory. Make
- * sure you use add_dir() first to create the folder.
- *
- * @access public
- * @param mixed
- * @param string
- * @return void
- */
- function add_data($filepath, $data = NULL)
- {
- if (is_array($filepath))
- {
- foreach ($filepath as $path => $data)
- {
- $this->_add_data($path, $data);
- }
- }
- else
- {
- $this->_add_data($filepath, $data);
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Add Data to Zip
- *
- * @access private
- * @param string the file name/path
- * @param string the data to be encoded
- * @return void
- */
- function _add_data($filepath, $data)
- {
- $filepath = str_replace("\\", "/", $filepath);
-
- $oldlen = strlen($data);
- $crc32 = crc32($data);
-
- $gzdata = gzcompress($data);
- $gzdata = substr(substr($gzdata, 0, strlen($gzdata) - 4), 2);
- $newlen = strlen($gzdata);
-
- $this->zipdata[] = "\x50\x4b\x03\x04\x14\x00\x00\x00\x08\x00\x00\x00\x00\x00"
- .pack('V', $crc32)
- .pack('V', $newlen)
- .pack('V', $oldlen)
- .pack('v', strlen($filepath))
- .pack('v', 0)
- .$filepath
- .$gzdata
- .pack('V', $crc32)
- .pack('V', $newlen)
- .pack('V', $oldlen);
-
- $newoffset = strlen(implode("", $this->zipdata));
-
- $record = "\x50\x4b\x01\x02\x00\x00\x14\x00\x00\x00\x08\x00\x00\x00\x00\x00"
- .pack('V', $crc32)
- .pack('V', $newlen)
- .pack('V', $oldlen)
- .pack('v', strlen($filepath))
- .pack('v', 0)
- .pack('v', 0)
- .pack('v', 0)
- .pack('v', 0)
- .pack('V', 32)
- .pack('V', $this->offset);
-
- $this->offset = $newoffset;
- $this->directory[] = $record.$filepath;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Read the contents of a file and add it to the zip
- *
- * @access public
- * @return bool
- */
- function read_file($path, $preserve_filepath = FALSE)
- {
- if ( ! file_exists($path))
- {
- return FALSE;
- }
-
- if (FALSE !== ($data = file_get_contents($path)))
- {
- $name = str_replace("\\", "/", $path);
-
- if ($preserve_filepath === FALSE)
- {
- $name = preg_replace("|.*/(.+)|", "\\1", $name);
- }
-
- $this->add_data($name, $data);
- return TRUE;
- }
- return FALSE;
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * Read a directory and add it to the zip.
- *
- * This function recursively reads a folder and everything it contains (including
- * sub-folders) and creates a zip based on it. Whatever directory structure
- * is in the original file path will be recreated in the zip file.
- *
- * @access public
- * @param string path to source
- * @return bool
- */
- function read_dir($path)
- {
- if ($fp = @opendir($path))
- {
- while (FALSE !== ($file = readdir($fp)))
- {
- if (@is_dir($path.$file) && substr($file, 0, 1) != '.')
- {
- $this->read_dir($path.$file."/");
- }
- elseif (substr($file, 0, 1) != ".")
- {
- if (FALSE !== ($data = file_get_contents($path.$file)))
- {
- $this->add_data(str_replace("\\", "/", $path).$file, $data);
- }
- }
- }
- return TRUE;
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Get the Zip file
- *
- * @access public
- * @return binary string
- */
- function get_zip()
- {
- // We cache the zip data so multiple calls
- // do not require recompiling
- if ($this->zipfile != '')
- {
- return $this->zipfile;
- }
-
- // Is there any data to return?
- if (count($this->zipdata) == 0)
- {
- return FALSE;
- }
-
- $data = implode('', $this->zipdata);
- $dir = implode('', $this->directory);
-
- $this->zipfile = $data.$dir."\x50\x4b\x05\x06\x00\x00\x00\x00"
- .pack('v', sizeof($this->directory))
- .pack('v', sizeof($this->directory))
- .pack('V', strlen($dir))
- .pack('V', strlen($data))
- ."\x00\x00";
-
- return $this->zipfile;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Write File to the specified directory
- *
- * Lets you write a file
- *
- * @access public
- * @param string the file name
- * @param string the data to be encoded
- * @return bool
- */
- function archive($filepath)
- {
- if ( ! ($fp = @fopen($filepath, "wb")))
- {
- return FALSE;
- }
-
- flock($fp, LOCK_EX);
- fwrite($fp, $this->get_zip());
- flock($fp, LOCK_UN);
- fclose($fp);
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Download
- *
- * @access public
- * @param string the file name
- * @param string the data to be encoded
- * @return bool
- */
- function download($filename = 'backup.zip')
- {
- if ( ! preg_match("|.+?\.zip$|", $filename))
- {
- $filename .= '.zip';
- }
-
- if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE"))
- {
- header('Content-Type: application/x-zip');
- header('Content-Disposition: inline; filename="'.$filename.'"');
- header('Expires: 0');
- header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
- header("Content-Transfer-Encoding: binary");
- header('Pragma: public');
- header("Content-Length: ".strlen($this->get_zip()));
- }
- else
- {
- header('Content-Type: application/x-zip');
- header('Content-Disposition: attachment; filename="'.$filename.'"');
- header("Content-Transfer-Encoding: binary");
- header('Expires: 0');
- header('Pragma: no-cache');
- header("Content-Length: ".strlen($this->get_zip()));
- }
-
- echo $this->get_zip();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Initialize Data
- *
- * Lets you clear current zip data. Useful if you need to create
- * multiple zips with different data.
- *
- * @access public
- * @return void
- */
- function clear_data()
- {
- $this->zipfile = '';
- $this->zipdata = array();
- $this->directory = array();
- $this->offset = array();
- }
-
-}
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Zip Compression Class
+ *
+ * This class is based on a library I found at Zend:
+ * http://www.zend.com/codex.php?id=696&single=1
+ *
+ * The original library is a little rough around the edges so I
+ * refactored it and added several additional methods -- Rick Ellis
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category Encryption
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/libraries/zip.html
+ */
+class CI_Zip {
+
+ var $zipfile = '';
+ var $zipdata = array();
+ var $directory = array();
+ var $offset = 0;
+
+ function CI_Zip()
+ {
+ log_message('debug', "Zip Compression Class Initialized");
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Add Directory
+ *
+ * Lets you add a virtual directory into which you can place files.
+ *
+ * @access public
+ * @param mixed the directory name. Can be string or array
+ * @return void
+ */
+ function add_dir($directory)
+ {
+ foreach ((array)$directory as $dir)
+ {
+ if ( ! preg_match("|.+/$|", $dir))
+ {
+ $dir .= '/';
+ }
+
+ $this->_add_dir($dir);
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Add Directory
+ *
+ * @access private
+ * @param string the directory name
+ * @return void
+ */
+ function _add_dir($dir)
+ {
+ $dir = str_replace("\\", "/", $dir);
+
+ $this->zipdata[] = "\x50\x4b\x03\x04\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ .pack('V', 0)
+ .pack('V', 0)
+ .pack('V', 0)
+ .pack('v', strlen($dir))
+ .pack('v', 0)
+ .$dir
+ .pack('V', 0)
+ .pack('V', 0)
+ .pack('V', 0);
+
+ $newoffset = strlen(implode('', $this->zipdata));
+
+ $record = "\x50\x4b\x01\x02\x00\x00\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ .pack('V',0)
+ .pack('V',0)
+ .pack('V',0)
+ .pack('v', strlen($dir))
+ .pack('v', 0)
+ .pack('v', 0)
+ .pack('v', 0)
+ .pack('v', 0)
+ .pack('V', 16)
+ .pack('V', $this->offset)
+ .$dir;
+
+ $this->offset = $newoffset;
+ $this->directory[] = $record;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Add Data to Zip
+ *
+ * Lets you add files to the archive. If the path is included
+ * in the filename it will be placed within a directory. Make
+ * sure you use add_dir() first to create the folder.
+ *
+ * @access public
+ * @param mixed
+ * @param string
+ * @return void
+ */
+ function add_data($filepath, $data = NULL)
+ {
+ if (is_array($filepath))
+ {
+ foreach ($filepath as $path => $data)
+ {
+ $this->_add_data($path, $data);
+ }
+ }
+ else
+ {
+ $this->_add_data($filepath, $data);
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Add Data to Zip
+ *
+ * @access private
+ * @param string the file name/path
+ * @param string the data to be encoded
+ * @return void
+ */
+ function _add_data($filepath, $data)
+ {
+ $filepath = str_replace("\\", "/", $filepath);
+
+ $oldlen = strlen($data);
+ $crc32 = crc32($data);
+
+ $gzdata = gzcompress($data);
+ $gzdata = substr(substr($gzdata, 0, strlen($gzdata) - 4), 2);
+ $newlen = strlen($gzdata);
+
+ $this->zipdata[] = "\x50\x4b\x03\x04\x14\x00\x00\x00\x08\x00\x00\x00\x00\x00"
+ .pack('V', $crc32)
+ .pack('V', $newlen)
+ .pack('V', $oldlen)
+ .pack('v', strlen($filepath))
+ .pack('v', 0)
+ .$filepath
+ .$gzdata
+ .pack('V', $crc32)
+ .pack('V', $newlen)
+ .pack('V', $oldlen);
+
+ $newoffset = strlen(implode("", $this->zipdata));
+
+ $record = "\x50\x4b\x01\x02\x00\x00\x14\x00\x00\x00\x08\x00\x00\x00\x00\x00"
+ .pack('V', $crc32)
+ .pack('V', $newlen)
+ .pack('V', $oldlen)
+ .pack('v', strlen($filepath))
+ .pack('v', 0)
+ .pack('v', 0)
+ .pack('v', 0)
+ .pack('v', 0)
+ .pack('V', 32)
+ .pack('V', $this->offset);
+
+ $this->offset = $newoffset;
+ $this->directory[] = $record.$filepath;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Read the contents of a file and add it to the zip
+ *
+ * @access public
+ * @return bool
+ */
+ function read_file($path, $preserve_filepath = FALSE)
+ {
+ if ( ! file_exists($path))
+ {
+ return FALSE;
+ }
+
+ if (FALSE !== ($data = file_get_contents($path)))
+ {
+ $name = str_replace("\\", "/", $path);
+
+ if ($preserve_filepath === FALSE)
+ {
+ $name = preg_replace("|.*/(.+)|", "\\1", $name);
+ }
+
+ $this->add_data($name, $data);
+ return TRUE;
+ }
+ return FALSE;
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Read a directory and add it to the zip.
+ *
+ * This function recursively reads a folder and everything it contains (including
+ * sub-folders) and creates a zip based on it. Whatever directory structure
+ * is in the original file path will be recreated in the zip file.
+ *
+ * @access public
+ * @param string path to source
+ * @return bool
+ */
+ function read_dir($path)
+ {
+ if ($fp = @opendir($path))
+ {
+ while (FALSE !== ($file = readdir($fp)))
+ {
+ if (@is_dir($path.$file) && substr($file, 0, 1) != '.')
+ {
+ $this->read_dir($path.$file."/");
+ }
+ elseif (substr($file, 0, 1) != ".")
+ {
+ if (FALSE !== ($data = file_get_contents($path.$file)))
+ {
+ $this->add_data(str_replace("\\", "/", $path).$file, $data);
+ }
+ }
+ }
+ return TRUE;
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get the Zip file
+ *
+ * @access public
+ * @return binary string
+ */
+ function get_zip()
+ {
+ // We cache the zip data so multiple calls
+ // do not require recompiling
+ if ($this->zipfile != '')
+ {
+ return $this->zipfile;
+ }
+
+ // Is there any data to return?
+ if (count($this->zipdata) == 0)
+ {
+ return FALSE;
+ }
+
+ $data = implode('', $this->zipdata);
+ $dir = implode('', $this->directory);
+
+ $this->zipfile = $data.$dir."\x50\x4b\x05\x06\x00\x00\x00\x00"
+ .pack('v', sizeof($this->directory))
+ .pack('v', sizeof($this->directory))
+ .pack('V', strlen($dir))
+ .pack('V', strlen($data))
+ ."\x00\x00";
+
+ return $this->zipfile;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Write File to the specified directory
+ *
+ * Lets you write a file
+ *
+ * @access public
+ * @param string the file name
+ * @param string the data to be encoded
+ * @return bool
+ */
+ function archive($filepath)
+ {
+ if ( ! ($fp = @fopen($filepath, "wb")))
+ {
+ return FALSE;
+ }
+
+ flock($fp, LOCK_EX);
+ fwrite($fp, $this->get_zip());
+ flock($fp, LOCK_UN);
+ fclose($fp);
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Download
+ *
+ * @access public
+ * @param string the file name
+ * @param string the data to be encoded
+ * @return bool
+ */
+ function download($filename = 'backup.zip')
+ {
+ if ( ! preg_match("|.+?\.zip$|", $filename))
+ {
+ $filename .= '.zip';
+ }
+
+ if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE"))
+ {
+ header('Content-Type: application/x-zip');
+ header('Content-Disposition: inline; filename="'.$filename.'"');
+ header('Expires: 0');
+ header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
+ header("Content-Transfer-Encoding: binary");
+ header('Pragma: public');
+ header("Content-Length: ".strlen($this->get_zip()));
+ }
+ else
+ {
+ header('Content-Type: application/x-zip');
+ header('Content-Disposition: attachment; filename="'.$filename.'"');
+ header("Content-Transfer-Encoding: binary");
+ header('Expires: 0');
+ header('Pragma: no-cache');
+ header("Content-Length: ".strlen($this->get_zip()));
+ }
+
+ echo $this->get_zip();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Initialize Data
+ *
+ * Lets you clear current zip data. Useful if you need to create
+ * multiple zips with different data.
+ *
+ * @access public
+ * @return void
+ */
+ function clear_data()
+ {
+ $this->zipfile = '';
+ $this->zipdata = array();
+ $this->directory = array();
+ $this->offset = array();
+ }
+
+}
?> \ No newline at end of file
diff --git a/system/plugins/captcha_pi.php b/system/plugins/captcha_pi.php
index b3c22f092..e16a214b6 100644
--- a/system/plugins/captcha_pi.php
+++ b/system/plugins/captcha_pi.php
@@ -1,346 +1,346 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/*
-Instructions:
-
-Load the plugin using:
-
- $this->load->plugin('captcha');
-
-Once loaded you can generate a captcha like this:
-
- $vals = array(
- 'word' => 'Random word',
- 'img_path' => './captcha/',
- 'img_url' => 'http://www.your-site.com/captcha/',
- 'font_path' => './system/texb.ttf',
- 'img_width' => '150',
- 'img_height' => 30,
- 'expiration' => 7200
- );
-
- $cap = create_captcha($vals);
- echo $cap['image'];
-
-
-NOTES:
-
- The captcha function requires the GD image library.
-
- Only the img_path and img_url are required.
-
- If a "word" is not supplied, the function will generate a random
- ASCII string. You might put together your own word library that
- you can draw randomly from.
-
- If you do not specify a path to a TRUE TYPE font, the native ugly GD
- font will be used.
-
- The "captcha" folder must be writable (666, or 777)
-
- The "expiration" (in seconds) signifies how long an image will
- remain in the captcha folder before it will be deleted. The default
- is two hours.
-
-RETURNED DATA
-
-The create_captcha() function returns an associative array with this data:
-
- [array]
- (
- 'image' => IMAGE TAG
- 'time' => TIMESTAMP (in microtime)
- 'word' => CAPTCHA WORD
- )
-
-The "image" is the actual image tag:
-<img src="http://your-site.com/captcha/12345.jpg" width="140" height="50" />
-
-The "time" is the micro timestamp used as the image name without the file
-extension. It will be a number like this: 1139612155.3422
-
-The "word" is the word that appears in the captcha image, which if not
-supplied to the function, will be a random string.
-
-
-ADDING A DATABASE
-
-In order for the captcha function to prevent someone from posting, you will need
-to add the information returned from create_captcha() function to your database.
-Then, when the data from the form is submitted by the user you will need to verify
-that the data exists in the database and has not expired.
-
-Here is a table prototype:
-
- CREATE TABLE captcha (
- captcha_id bigint(13) unsigned NOT NULL auto_increment,
- captcha_time int(10) unsigned NOT NULL,
- ip_address varchar(16) default '0' NOT NULL,
- word varchar(20) NOT NULL,
- PRIMARY KEY (captcha_id),
- KEY (word)
- )
-
-
-Here is an example of usage with a DB.
-
-On the page where the captcha will be shown you'll have something like this:
-
- $this->load->plugin('captcha');
- $vals = array(
- 'img_path' => './captcha/',
- 'img_url' => 'http://www.your-site.com/captcha/'
- );
-
- $cap = create_captcha($vals);
-
- $data = array(
- 'captcha_id' => '',
- 'captcha_time' => $cap['time'],
- 'ip_address' => $this->input->ip_address(),
- 'word' => $cap['word']
- );
-
- $query = $this->db->insert_string('captcha', $data);
- $this->db->query($query);
-
- echo 'Submit the word you see below:';
- echo $cap['image'];
- echo '<input type="text" name="captcha" value="" />';
-
-
-Then, on the page that accepts the submission you'll have something like this:
-
- // First, delete old captchas
- $expiration = time()-7200; // Two hour limit
- $DB->query("DELETE FROM captcha WHERE captcha_time < ".$expiration);
-
- // Then see if a captcha exists:
- $sql = "SELECT COUNT(*) AS count FROM captcha WHERE word = ? AND ip_address = ? AND date > ?";
- $binds = array($_POST['captcha'], $this->input->ip_address(), $expiration);
- $query = $this->db->query($sql, $binds);
- $row = $query->row();
-
- if ($row->count == 0)
- {
- echo "You must submit the word that appears in the image";
- }
-
-*/
-
-
-
-/**
-|==========================================================
-| Create Captcha
-|==========================================================
-|
-*/
-function create_captcha($data = '', $img_path = '', $img_url = '', $font_path = '')
-{
- $defaults = array('word' => '', 'img_path' => '', 'img_url' => '', 'img_width' => '150', 'img_height' => '30', 'font_path' => '', 'expiration' => 7200);
-
- foreach ($defaults as $key => $val)
- {
- if ( ! is_array($data))
- {
- if ( ! isset($$key) OR $$key == '')
- {
- $$key = $val;
- }
- }
- else
- {
- $$key = ( ! isset($data[$key])) ? $val : $data[$key];
- }
- }
-
- if ($img_path == '' OR $img_url == '')
- {
- return FALSE;
- }
-
- if ( ! @is_dir($img_path))
- {
- return FALSE;
- }
-
- if ( ! is_writable($img_path))
- {
- return FALSE;
- }
-
- if ( ! extension_loaded('gd'))
- {
- return FALSE;
- }
-
- // -----------------------------------
- // Remove old images
- // -----------------------------------
-
- list($usec, $sec) = explode(" ", microtime());
- $now = ((float)$usec + (float)$sec);
-
- $current_dir = @opendir($img_path);
-
- while($filename = @readdir($current_dir))
- {
- if ($filename != "." and $filename != ".." and $filename != "index.html")
- {
- $name = str_replace(".jpg", "", $filename);
-
- if (($name + $expiration) < $now)
- {
- @unlink($img_path.$filename);
- }
- }
- }
-
- @closedir($current_dir);
-
- // -----------------------------------
- // Do we have a "word" yet?
- // -----------------------------------
-
- if ($word == '')
- {
- $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
-
- $str = '';
- for ($i = 0; $i < 8; $i++)
- {
- $str .= substr($pool, mt_rand(0, strlen($pool) -1), 1);
- }
-
- $word = $str;
- }
-
- // -----------------------------------
- // Determine angle and position
- // -----------------------------------
-
- $length = strlen($word);
- $angle = ($length >= 6) ? rand(-($length-6), ($length-6)) : 0;
- $x_axis = rand(6, (360/$length)-16);
- $y_axis = ($angle >= 0 ) ? rand($img_height, $img_width) : rand(6, $img_height);
-
- // -----------------------------------
- // Create image
- // -----------------------------------
-
- $im = ImageCreate($img_width, $img_height);
-
- // -----------------------------------
- // Assign colors
- // -----------------------------------
-
- $bg_color = ImageColorAllocate($im, 255, 255, 255);
- $border_color = ImageColorAllocate($im, 153, 102, 102);
- $text_color = ImageColorAllocate($im, 204, 153, 153);
- $grid_color = imagecolorallocate($im, 255, 182, 182);
- $shadow_color = imagecolorallocate($im, 255, 240, 240);
-
- // -----------------------------------
- // Create the rectangle
- // -----------------------------------
-
- ImageFilledRectangle($im, 0, 0, $img_width, $img_height, $bg_color);
-
- // -----------------------------------
- // Create the spiral pattern
- // -----------------------------------
-
- $theta = 1;
- $thetac = 7;
- $radius = 16;
- $circles = 20;
- $points = 32;
-
- for ($i = 0; $i < ($circles * $points) - 1; $i++)
- {
- $theta = $theta + $thetac;
- $rad = $radius * ($i / $points );
- $x = ($rad * cos($theta)) + $x_axis;
- $y = ($rad * sin($theta)) + $y_axis;
- $theta = $theta + $thetac;
- $rad1 = $radius * (($i + 1) / $points);
- $x1 = ($rad1 * cos($theta)) + $x_axis;
- $y1 = ($rad1 * sin($theta )) + $y_axis;
- imageline($im, $x, $y, $x1, $y1, $grid_color);
- $theta = $theta - $thetac;
- }
-
- // -----------------------------------
- // Write the text
- // -----------------------------------
-
- $use_font = ($font_path != '' AND file_exists($font_path) AND function_exists('imagettftext')) ? TRUE : FALSE;
-
- if ($use_font == FALSE)
- {
- $font_size = 5;
- $x = rand(0, $img_width/($length/3));
- $y = 0;
- }
- else
- {
- $font_size = 16;
- $x = rand(0, $img_width/($length/1.5));
- $y = $font_size+2;
- }
-
- for ($i = 0; $i < strlen($word); $i++)
- {
- if ($use_font == FALSE)
- {
- $y = rand(0 , $img_height/2);
- imagestring($im, $font_size, $x, $y, substr($word, $i, 1), $text_color);
- $x += ($font_size*2);
- }
- else
- {
- $y = rand($img_height/2, $img_height-3);
- imagettftext($im, $font_size, $angle, $x, $y, $text_color, $font_path, substr($word, $i, 1));
- $x += $font_size;
- }
- }
-
-
- // -----------------------------------
- // Create the border
- // -----------------------------------
-
- imagerectangle($im, 0, 0, $img_width-1, $img_height-1, $border_color);
-
- // -----------------------------------
- // Generate the image
- // -----------------------------------
-
- $img_name = $now.'.jpg';
-
- ImageJPEG($im, $img_path.$img_name);
-
- $img = "<img src=\"$img_url$img_name\" width=\"$img_width\" height=\"$img_height\" style=\"border:0;\" alt=\" \" />";
-
- ImageDestroy($im);
-
- return array('word' => $word, 'time' => $now, 'image' => $img);
-}
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/*
+Instructions:
+
+Load the plugin using:
+
+ $this->load->plugin('captcha');
+
+Once loaded you can generate a captcha like this:
+
+ $vals = array(
+ 'word' => 'Random word',
+ 'img_path' => './captcha/',
+ 'img_url' => 'http://www.your-site.com/captcha/',
+ 'font_path' => './system/texb.ttf',
+ 'img_width' => '150',
+ 'img_height' => 30,
+ 'expiration' => 7200
+ );
+
+ $cap = create_captcha($vals);
+ echo $cap['image'];
+
+
+NOTES:
+
+ The captcha function requires the GD image library.
+
+ Only the img_path and img_url are required.
+
+ If a "word" is not supplied, the function will generate a random
+ ASCII string. You might put together your own word library that
+ you can draw randomly from.
+
+ If you do not specify a path to a TRUE TYPE font, the native ugly GD
+ font will be used.
+
+ The "captcha" folder must be writable (666, or 777)
+
+ The "expiration" (in seconds) signifies how long an image will
+ remain in the captcha folder before it will be deleted. The default
+ is two hours.
+
+RETURNED DATA
+
+The create_captcha() function returns an associative array with this data:
+
+ [array]
+ (
+ 'image' => IMAGE TAG
+ 'time' => TIMESTAMP (in microtime)
+ 'word' => CAPTCHA WORD
+ )
+
+The "image" is the actual image tag:
+<img src="http://your-site.com/captcha/12345.jpg" width="140" height="50" />
+
+The "time" is the micro timestamp used as the image name without the file
+extension. It will be a number like this: 1139612155.3422
+
+The "word" is the word that appears in the captcha image, which if not
+supplied to the function, will be a random string.
+
+
+ADDING A DATABASE
+
+In order for the captcha function to prevent someone from posting, you will need
+to add the information returned from create_captcha() function to your database.
+Then, when the data from the form is submitted by the user you will need to verify
+that the data exists in the database and has not expired.
+
+Here is a table prototype:
+
+ CREATE TABLE captcha (
+ captcha_id bigint(13) unsigned NOT NULL auto_increment,
+ captcha_time int(10) unsigned NOT NULL,
+ ip_address varchar(16) default '0' NOT NULL,
+ word varchar(20) NOT NULL,
+ PRIMARY KEY (captcha_id),
+ KEY (word)
+ )
+
+
+Here is an example of usage with a DB.
+
+On the page where the captcha will be shown you'll have something like this:
+
+ $this->load->plugin('captcha');
+ $vals = array(
+ 'img_path' => './captcha/',
+ 'img_url' => 'http://www.your-site.com/captcha/'
+ );
+
+ $cap = create_captcha($vals);
+
+ $data = array(
+ 'captcha_id' => '',
+ 'captcha_time' => $cap['time'],
+ 'ip_address' => $this->input->ip_address(),
+ 'word' => $cap['word']
+ );
+
+ $query = $this->db->insert_string('captcha', $data);
+ $this->db->query($query);
+
+ echo 'Submit the word you see below:';
+ echo $cap['image'];
+ echo '<input type="text" name="captcha" value="" />';
+
+
+Then, on the page that accepts the submission you'll have something like this:
+
+ // First, delete old captchas
+ $expiration = time()-7200; // Two hour limit
+ $DB->query("DELETE FROM captcha WHERE captcha_time < ".$expiration);
+
+ // Then see if a captcha exists:
+ $sql = "SELECT COUNT(*) AS count FROM captcha WHERE word = ? AND ip_address = ? AND date > ?";
+ $binds = array($_POST['captcha'], $this->input->ip_address(), $expiration);
+ $query = $this->db->query($sql, $binds);
+ $row = $query->row();
+
+ if ($row->count == 0)
+ {
+ echo "You must submit the word that appears in the image";
+ }
+
+*/
+
+
+
+/**
+|==========================================================
+| Create Captcha
+|==========================================================
+|
+*/
+function create_captcha($data = '', $img_path = '', $img_url = '', $font_path = '')
+{
+ $defaults = array('word' => '', 'img_path' => '', 'img_url' => '', 'img_width' => '150', 'img_height' => '30', 'font_path' => '', 'expiration' => 7200);
+
+ foreach ($defaults as $key => $val)
+ {
+ if ( ! is_array($data))
+ {
+ if ( ! isset($$key) OR $$key == '')
+ {
+ $$key = $val;
+ }
+ }
+ else
+ {
+ $$key = ( ! isset($data[$key])) ? $val : $data[$key];
+ }
+ }
+
+ if ($img_path == '' OR $img_url == '')
+ {
+ return FALSE;
+ }
+
+ if ( ! @is_dir($img_path))
+ {
+ return FALSE;
+ }
+
+ if ( ! is_writable($img_path))
+ {
+ return FALSE;
+ }
+
+ if ( ! extension_loaded('gd'))
+ {
+ return FALSE;
+ }
+
+ // -----------------------------------
+ // Remove old images
+ // -----------------------------------
+
+ list($usec, $sec) = explode(" ", microtime());
+ $now = ((float)$usec + (float)$sec);
+
+ $current_dir = @opendir($img_path);
+
+ while($filename = @readdir($current_dir))
+ {
+ if ($filename != "." and $filename != ".." and $filename != "index.html")
+ {
+ $name = str_replace(".jpg", "", $filename);
+
+ if (($name + $expiration) < $now)
+ {
+ @unlink($img_path.$filename);
+ }
+ }
+ }
+
+ @closedir($current_dir);
+
+ // -----------------------------------
+ // Do we have a "word" yet?
+ // -----------------------------------
+
+ if ($word == '')
+ {
+ $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
+
+ $str = '';
+ for ($i = 0; $i < 8; $i++)
+ {
+ $str .= substr($pool, mt_rand(0, strlen($pool) -1), 1);
+ }
+
+ $word = $str;
+ }
+
+ // -----------------------------------
+ // Determine angle and position
+ // -----------------------------------
+
+ $length = strlen($word);
+ $angle = ($length >= 6) ? rand(-($length-6), ($length-6)) : 0;
+ $x_axis = rand(6, (360/$length)-16);
+ $y_axis = ($angle >= 0 ) ? rand($img_height, $img_width) : rand(6, $img_height);
+
+ // -----------------------------------
+ // Create image
+ // -----------------------------------
+
+ $im = ImageCreate($img_width, $img_height);
+
+ // -----------------------------------
+ // Assign colors
+ // -----------------------------------
+
+ $bg_color = ImageColorAllocate($im, 255, 255, 255);
+ $border_color = ImageColorAllocate($im, 153, 102, 102);
+ $text_color = ImageColorAllocate($im, 204, 153, 153);
+ $grid_color = imagecolorallocate($im, 255, 182, 182);
+ $shadow_color = imagecolorallocate($im, 255, 240, 240);
+
+ // -----------------------------------
+ // Create the rectangle
+ // -----------------------------------
+
+ ImageFilledRectangle($im, 0, 0, $img_width, $img_height, $bg_color);
+
+ // -----------------------------------
+ // Create the spiral pattern
+ // -----------------------------------
+
+ $theta = 1;
+ $thetac = 7;
+ $radius = 16;
+ $circles = 20;
+ $points = 32;
+
+ for ($i = 0; $i < ($circles * $points) - 1; $i++)
+ {
+ $theta = $theta + $thetac;
+ $rad = $radius * ($i / $points );
+ $x = ($rad * cos($theta)) + $x_axis;
+ $y = ($rad * sin($theta)) + $y_axis;
+ $theta = $theta + $thetac;
+ $rad1 = $radius * (($i + 1) / $points);
+ $x1 = ($rad1 * cos($theta)) + $x_axis;
+ $y1 = ($rad1 * sin($theta )) + $y_axis;
+ imageline($im, $x, $y, $x1, $y1, $grid_color);
+ $theta = $theta - $thetac;
+ }
+
+ // -----------------------------------
+ // Write the text
+ // -----------------------------------
+
+ $use_font = ($font_path != '' AND file_exists($font_path) AND function_exists('imagettftext')) ? TRUE : FALSE;
+
+ if ($use_font == FALSE)
+ {
+ $font_size = 5;
+ $x = rand(0, $img_width/($length/3));
+ $y = 0;
+ }
+ else
+ {
+ $font_size = 16;
+ $x = rand(0, $img_width/($length/1.5));
+ $y = $font_size+2;
+ }
+
+ for ($i = 0; $i < strlen($word); $i++)
+ {
+ if ($use_font == FALSE)
+ {
+ $y = rand(0 , $img_height/2);
+ imagestring($im, $font_size, $x, $y, substr($word, $i, 1), $text_color);
+ $x += ($font_size*2);
+ }
+ else
+ {
+ $y = rand($img_height/2, $img_height-3);
+ imagettftext($im, $font_size, $angle, $x, $y, $text_color, $font_path, substr($word, $i, 1));
+ $x += $font_size;
+ }
+ }
+
+
+ // -----------------------------------
+ // Create the border
+ // -----------------------------------
+
+ imagerectangle($im, 0, 0, $img_width-1, $img_height-1, $border_color);
+
+ // -----------------------------------
+ // Generate the image
+ // -----------------------------------
+
+ $img_name = $now.'.jpg';
+
+ ImageJPEG($im, $img_path.$img_name);
+
+ $img = "<img src=\"$img_url$img_name\" width=\"$img_width\" height=\"$img_height\" style=\"border:0;\" alt=\" \" />";
+
+ ImageDestroy($im);
+
+ return array('word' => $word, 'time' => $now, 'image' => $img);
+}
+
?> \ No newline at end of file
diff --git a/system/plugins/js_calendar_pi.php b/system/plugins/js_calendar_pi.php
index 987bd49ed..a461e34a7 100644
--- a/system/plugins/js_calendar_pi.php
+++ b/system/plugins/js_calendar_pi.php
@@ -1,604 +1,604 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/*
-Instructions:
-
-Load the plugin using:
-
- $this->load->plugin('js_calendar');
-
-Once loaded you'll add the calendar script to the <head> of your page like this:
-
-<?php echo js_calendar_script('my_form'); ?>
-
-The above function will be passed the name of your form.
-
-Then to show the actual calendar you'll do this:
-
-<?php echo js_calendar_write('entry_date', time(), true); ?>
-<form name="my_form">
-<input type="text" name="entry_date" value="" onblur="update_calendar(this.name, this.value);" />
-<p><a href="javascript:void(0);" onClick="set_to_time('entry_date', '<?php echo time(); ?>')" >Today</a></p>
-</form>
-
-
-Note: The first parameter is the name of the field containing your date, the second parameter contains the "now" time,
-and the third tells the calendar whether to highlight the current day or not.
-
-Lastly, you'll need some CSS for your calendar:
-
-.calendar {
- border: 1px #6975A3 solid;
- background-color: transparent;
-}
-.calheading {
- background-color: #7C8BC0;
- color: #fff;
- font-family: Lucida Grande, Verdana, Geneva, Sans-serif;
- font-size: 11px;
- font-weight: bold;
- text-align: center;
-}
-.calnavleft {
- background-color: #7C8BC0;
- font-family: Lucida Grande, Verdana, Geneva, Sans-serif;
- font-size: 10px;
- font-weight: bold;
- color: #fff;
- padding: 4px;
- cursor: pointer;
-}
-.calnavright {
- background-color: #7C8BC0;
- font-family: Lucida Grande, Verdana, Geneva, Sans-serif;
- font-size: 10px;
- font-weight: bold;
- color: #fff;
- text-align: right;
- padding: 4px;
- cursor: pointer;
-}
-.caldayheading {
- background-color: #000;
- color: #fff;
- font-family: Lucida Grande, Verdana, Geneva, Sans-serif;
- font-size: 10px;
- text-align: center;
- padding: 6px 2px 6px 2px;
-}
-.caldaycells{
- color: #000;
- background-color: #D1D7E6;
- font-family: Lucida Grande, Verdana, Geneva, Sans-serif;
- font-size: 11px;
- text-align: center;
- padding: 4px;
- border: 1px #E0E5F1 solid;
- cursor: pointer;
-}
-.caldaycellhover{
- color: #fff;
- background-color: #B3BCD4;
- font-family: Lucida Grande, Verdana, Geneva, Sans-serif;
- font-size: 11px;
- text-align: center;
- padding: 4px;
- border: 1px #B3BCD4 solid;
- cursor: pointer;
-}
-.caldayselected{
- background-color: #737FAC;
- color: #fff;
- font-family: Lucida Grande, Verdana, Geneva, Sans-serif;
- font-size: 11px;
- font-weight: bold;
- text-align: center;
- border: 1px #566188 solid;
- padding: 3px;
- cursor: pointer;
-}
-.calblanktop {
- background-color: #fff;
- padding: 4px;
-}
-.calblankbot {
- background-color: #fff;
- padding: 4px;
-}
-
-
-*/
-
-function js_calendar_script($form_name = 'entryform')
-{
-
-ob_start();
-?>
-<script type="text/javascript">
-<!--
-var form_name = "<?php echo $form_name; ?>";
-var format = 'us'; // eu or us
-var days = new Array('Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa');
-var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
-var last_click = new Array();
-var current_month = '';
-var current_year = '';
-var last_date = '';
-
-function calendar(id, d, highlight, adjusted)
-{
- if (adjusted == undefined)
- {
- var d = new Date(d * 1000);
- }
-
- this.id = id;
- this.highlight = highlight;
- this.date_obj = d;
- this.write = build_calendar;
- this.total_days = total_days;
- this.month = d.getMonth();
- this.date = d.getDate();
- this.day = d.getDay();
- this.year = d.getFullYear();
- this.hours = d.getHours();
- this.minutes = d.getMinutes();
- this.seconds = d.getSeconds();
- this.date_str = date_str;
-
- if (highlight == false)
- {
- this.selected_date = '';
- }
- else
- {
- this.selected_date = this.year + '' + this.month + '' + this.date;
- }
-
- // Set the "selected date"
- d.setDate(1);
- this.firstDay = d.getDay();
-
- //then reset the date object to the correct date
- d.setDate(this.date);
-}
-
-// Build the body of the calendar
-function build_calendar()
-{
- var str = '';
-
- // Calendar Heading
-
- str += '<div id="cal' + this.id + '">';
- str += '<table class="calendar" cellspacing="0" cellpadding="0" border="0" >';
- str += '<tr>';
- str += '<td class="calnavleft" onClick="change_month(-1, \'' + this.id + '\')">&lt;&lt;<\/td>';
- str += '<td colspan="5" class="calheading">' + months[this.month] + ' ' + this.year + '<\/td>';
- str += '<td class="calnavright" onClick="change_month(1, \'' + this.id + '\')">&gt;&gt;<\/td>';
- str += '<\/tr>';
-
- // Day Names
-
- str += '<tr>';
-
- for (i = 0; i < 7; i++)
- {
- str += '<td class="caldayheading">' + days[i] + '<\/td>';
- }
-
- str += '<\/tr>';
-
- // Day Cells
-
- str += '<tr>';
-
- selDate = (last_date != '') ? last_date : this.date;
-
- for (j = 0; j < 42; j++)
- {
- var displayNum = (j - this.firstDay + 1);
-
- if (j < this.firstDay) // leading empty cells
- {
- str += '<td class="calblanktop">&nbsp;<\/td>';
- }
- else if (displayNum == selDate && this.highlight == true) // Selected date
- {
- str += '<td id="' + this.id +'selected" class="caldayselected" onClick="set_date(this,\'' + this.id + '\')">' + displayNum + '<\/td>';
- }
- else if (displayNum > this.total_days())
- {
- str += '<td class="calblankbot">&nbsp;<\/td>'; // trailing empty cells
- }
- else // Unselected days
- {
- str += '<td id="" class="caldaycells" onClick="set_date(this,\'' + this.id + '\'); return false;" onMouseOver="javascript:cell_highlight(this,\'' + displayNum + '\',\'' + this.id + '\');" onMouseOut="javascript:cell_reset(this,\'' + displayNum + '\',\'' + this.id + '\');" >' + displayNum + '<\/td>';
- }
-
- if (j % 7 == 6)
- {
- str += '<\/tr><tr>';
- }
- }
-
- str += '<\/tr>';
- str += '<\/table>';
- str += '<\/div>';
-
- return str;
-}
-
-// Total number of days in a month
-function total_days()
-{
- switch(this.month)
- {
- case 1: // Check for leap year
- if (( this.date_obj.getFullYear() % 4 == 0
- && this.date_obj.getFullYear() % 100 != 0)
- || this.date_obj.getFullYear() % 400 == 0)
- return 29;
- else
- return 28;
- case 3:
- return 30;
- case 5:
- return 30;
- case 8:
- return 30;
- case 10:
- return 30
- default:
- return 31;
- }
-}
-
-// Highlight Cell on Mouseover
-function cell_highlight(td, num, cal)
-{
- cal = eval(cal);
-
- if (last_click[cal.id] != num)
- {
- td.className = "caldaycellhover";
- }
-}
-
-// Reset Cell on MouseOut
-function cell_reset(td, num, cal)
-{
- cal = eval(cal);
-
- if (last_click[cal.id] == num)
- {
- td.className = "caldayselected";
- }
- else
- {
- td.className = "caldaycells";
- }
-}
-
-// Clear Field
-function clear_field(id)
-{
- eval("document." + form_name + "." + id + ".value = ''");
-
- document.getElementById(id + "selected").className = "caldaycells";
- document.getElementById(id + "selected").id = "";
-
- cal = eval(id);
- cal.selected_date = '';
-}
-
-
-// Set date to specified time
-function set_to_time(id, raw)
-{
- if (document.getElementById(id + "selected"))
- {
- document.getElementById(id + "selected").className = "caldaycells";
- document.getElementById(id + "selected").id = "";
- }
-
- document.getElementById('cal' + id).innerHTML = '<div id="tempcal'+id+'">&nbsp;<'+'/div>';
-
- var nowDate = new Date();
- nowDate.setTime = raw * 1000;
-
- current_month = nowDate.getMonth();
- current_year = nowDate.getFullYear();
- current_date = nowDate.getDate();
-
- oldcal = eval(id);
- oldcal.selected_date = current_year + '' + current_month + '' + current_date;
-
- cal = new calendar(id, nowDate, true, true);
- cal.selected_date = current_year + '' + current_month + '' + current_date;
-
- last_date = cal.date;
-
- document.getElementById('tempcal'+id).innerHTML = cal.write();
-
- insert_date(cal);
-}
-
-// Set date to what is in the field
-var lastDates = new Array();
-
-function update_calendar(id, dateValue)
-{
- if (lastDates[id] == dateValue) return;
-
- lastDates[id] = dateValue;
-
- var fieldString = dateValue.replace(/\s+/g, ' ');
-
- while (fieldString.substring(0,1) == ' ')
- {
- fieldString = fieldString.substring(1, fieldString.length);
- }
-
- var dateString = fieldString.split(' ');
- var dateParts = dateString[0].split('-')
-
- if (dateParts.length < 3) return;
- var newYear = dateParts[0];
- var newMonth = dateParts[1];
- var newDay = dateParts[2];
-
- if (isNaN(newDay) || newDay < 1 || (newDay.length != 1 && newDay.length != 2)) return;
- if (isNaN(newYear) || newYear < 1 || newYear.length != 4) return;
- if (isNaN(newMonth) || newMonth < 1 || (newMonth.length != 1 && newMonth.length != 2)) return;
-
- if (newMonth > 12) newMonth = 12;
-
- if (newDay > 28)
- {
- switch(newMonth - 1)
- {
- case 1: // Check for leap year
- if ((newYear % 4 == 0 && newYear % 100 != 0) || newYear % 400 == 0)
- {
- if (newDay > 29) newDay = 29;
- }
- else
- {
- if (newDay > 28) newDay = 28;
- }
- case 3:
- if (newDay > 30) newDay = 30;
- case 5:
- if (newDay > 30) newDay = 30;
- case 8:
- if (newDay > 30) newDay = 30;
- case 10:
- if (newDay > 30) newDay = 30;
- default:
- if (newDay > 31) newDay = 31;
- }
- }
-
- if (document.getElementById(id + "selected"))
- {
- document.getElementById(id + "selected").className = "caldaycells";
- document.getElementById(id + "selected").id = "";
- }
-
- document.getElementById('cal' + id).innerHTML = '<div id="tempcal'+id+'">&nbsp;<'+'/div>';
-
- var nowDate = new Date();
- nowDate.setDate(newDay);
- nowDate.setMonth(newMonth - 1);
- nowDate.setYear(newYear);
- nowDate.setHours(12);
-
- current_month = nowDate.getMonth();
- current_year = nowDate.getFullYear();
-
- cal = new calendar(id, nowDate, true, true);
- document.getElementById('tempcal'+id).innerHTML = cal.write();
-}
-
-// Set the date
-function set_date(td, cal)
-{
- cal = eval(cal);
-
- // If the user is clicking a cell that is already
- // selected we'll de-select it and clear the form field
-
- if (last_click[cal.id] == td.firstChild.nodeValue)
- {
- td.className = "caldaycells";
- last_click[cal.id] = '';
- remove_date(cal);
- cal.selected_date = '';
- return;
- }
-
- // Onward!
- if (document.getElementById(cal.id + "selected"))
- {
- document.getElementById(cal.id + "selected").className = "caldaycells";
- document.getElementById(cal.id + "selected").id = "";
- }
-
- td.className = "caldayselected";
- td.id = cal.id + "selected";
-
- cal.selected_date = cal.date_obj.getFullYear() + '' + cal.date_obj.getMonth() + '' + cal.date;
- cal.date_obj.setDate(td.firstChild.nodeValue);
- cal = new calendar(cal.id, cal.date_obj, true, true);
- cal.selected_date = cal.date_obj.getFullYear() + '' + cal.date_obj.getMonth() + '' + cal.date;
-
- last_date = cal.date;
-
- //cal.date
- last_click[cal.id] = cal.date;
-
- // Insert the date into the form
- insert_date(cal);
-}
-
-// Insert the date into the form field
-function insert_date(cal)
-{
- cal = eval(cal);
- fval = eval("document." + form_name + "." + cal.id);
-
- if (fval.value == '')
- {
- fval.value = cal.date_str('y');
- }
- else
- {
- time = fval.value.substring(10);
- new_date = cal.date_str('n') + time;
- fval.value = new_date;
- }
-}
-
-// Remove the date from the form field
-function remove_date(cal)
-{
- cal = eval(cal);
- fval = eval("document." + form_name + "." + cal.id);
- fval.value = '';
-}
-
-// Change to a new month
-function change_month(mo, cal)
-{
- cal = eval(cal);
-
- if (current_month != '')
- {
- cal.date_obj.setMonth(current_month);
- cal.date_obj.setYear(current_year);
-
- current_month = '';
- current_year = '';
- }
-
- var newMonth = cal.date_obj.getMonth() + mo;
- var newDate = cal.date_obj.getDate();
-
- if (newMonth == 12)
- {
- cal.date_obj.setYear(cal.date_obj.getFullYear() + 1)
- newMonth = 0;
- }
- else if (newMonth == -1)
- {
- cal.date_obj.setYear(cal.date_obj.getFullYear() - 1)
- newMonth = 11;
- }
-
- if (newDate > 28)
- {
- var newYear = cal.date_obj.getFullYear();
-
- switch(newMonth)
- {
- case 1: // Check for leap year
- if ((newYear % 4 == 0 && newYear % 100 != 0) || newYear % 400 == 0)
- {
- if (newDate > 29) newDate = 29;
- }
- else
- {
- if (newDate > 28) newDate = 28;
- }
- case 3:
- if (newDate > 30) newDate = 30;
- case 5:
- if (newDate > 30) newDate = 30;
- case 8:
- if (newDate > 30) newDate = 30;
- case 10:
- if (newDate > 30) newDate = 30;
- default:
- if (newDate > 31) newDate = 31;
- }
- }
-
- cal.date_obj.setDate(newDate);
- cal.date_obj.setMonth(newMonth);
- new_mdy = cal.date_obj.getFullYear() + '' + cal.date_obj.getMonth() + '' + cal.date;
-
- highlight = (cal.selected_date == new_mdy) ? true : false;
- cal = new calendar(cal.id, cal.date_obj, highlight, true);
- document.getElementById('cal' + cal.id).innerHTML = cal.write();
-}
-
-// Finalize the date string
-function date_str(time)
-{
- var month = this.month + 1;
- if (month < 10)
- month = '0' + month;
-
- var day = (this.date < 10) ? '0' + this.date : this.date;
- var minutes = (this.minutes < 10) ? '0' + this.minutes : this.minutes;
-
- if (format == 'us')
- {
- var hours = (this.hours > 12) ? this.hours - 12 : this.hours;
- var ampm = (this.hours > 11) ? 'PM' : 'AM'
- }
- else
- {
- var hours = this.hours;
- var ampm = '';
- }
-
- if (time == 'y')
- {
- return this.year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ' ' + ampm;
- }
- else
- {
- return this.year + '-' + month + '-' + day;
- }
-}
-
-//-->
-</script>
-<?php
-
-$r = ob_get_contents();
-ob_end_clean();
-return $r;
-}
-
-
-function js_calendar_write($field_id, $time = '', $highlight = TRUE)
-{
- if ($time == '')
- $time = time();
-
- return
- '<script type="text/javascript">
- var '.$field_id.' = new calendar("'.$field_id.'", '.$time.', '.(($highlight == TRUE) ? 'true' : 'false').');
- document.write('.$field_id.'.write());
- </script>';
-}
-
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/*
+Instructions:
+
+Load the plugin using:
+
+ $this->load->plugin('js_calendar');
+
+Once loaded you'll add the calendar script to the <head> of your page like this:
+
+<?php echo js_calendar_script('my_form'); ?>
+
+The above function will be passed the name of your form.
+
+Then to show the actual calendar you'll do this:
+
+<?php echo js_calendar_write('entry_date', time(), true); ?>
+<form name="my_form">
+<input type="text" name="entry_date" value="" onblur="update_calendar(this.name, this.value);" />
+<p><a href="javascript:void(0);" onClick="set_to_time('entry_date', '<?php echo time(); ?>')" >Today</a></p>
+</form>
+
+
+Note: The first parameter is the name of the field containing your date, the second parameter contains the "now" time,
+and the third tells the calendar whether to highlight the current day or not.
+
+Lastly, you'll need some CSS for your calendar:
+
+.calendar {
+ border: 1px #6975A3 solid;
+ background-color: transparent;
+}
+.calheading {
+ background-color: #7C8BC0;
+ color: #fff;
+ font-family: Lucida Grande, Verdana, Geneva, Sans-serif;
+ font-size: 11px;
+ font-weight: bold;
+ text-align: center;
+}
+.calnavleft {
+ background-color: #7C8BC0;
+ font-family: Lucida Grande, Verdana, Geneva, Sans-serif;
+ font-size: 10px;
+ font-weight: bold;
+ color: #fff;
+ padding: 4px;
+ cursor: pointer;
+}
+.calnavright {
+ background-color: #7C8BC0;
+ font-family: Lucida Grande, Verdana, Geneva, Sans-serif;
+ font-size: 10px;
+ font-weight: bold;
+ color: #fff;
+ text-align: right;
+ padding: 4px;
+ cursor: pointer;
+}
+.caldayheading {
+ background-color: #000;
+ color: #fff;
+ font-family: Lucida Grande, Verdana, Geneva, Sans-serif;
+ font-size: 10px;
+ text-align: center;
+ padding: 6px 2px 6px 2px;
+}
+.caldaycells{
+ color: #000;
+ background-color: #D1D7E6;
+ font-family: Lucida Grande, Verdana, Geneva, Sans-serif;
+ font-size: 11px;
+ text-align: center;
+ padding: 4px;
+ border: 1px #E0E5F1 solid;
+ cursor: pointer;
+}
+.caldaycellhover{
+ color: #fff;
+ background-color: #B3BCD4;
+ font-family: Lucida Grande, Verdana, Geneva, Sans-serif;
+ font-size: 11px;
+ text-align: center;
+ padding: 4px;
+ border: 1px #B3BCD4 solid;
+ cursor: pointer;
+}
+.caldayselected{
+ background-color: #737FAC;
+ color: #fff;
+ font-family: Lucida Grande, Verdana, Geneva, Sans-serif;
+ font-size: 11px;
+ font-weight: bold;
+ text-align: center;
+ border: 1px #566188 solid;
+ padding: 3px;
+ cursor: pointer;
+}
+.calblanktop {
+ background-color: #fff;
+ padding: 4px;
+}
+.calblankbot {
+ background-color: #fff;
+ padding: 4px;
+}
+
+
+*/
+
+function js_calendar_script($form_name = 'entryform')
+{
+
+ob_start();
+?>
+<script type="text/javascript">
+<!--
+var form_name = "<?php echo $form_name; ?>";
+var format = 'us'; // eu or us
+var days = new Array('Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa');
+var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
+var last_click = new Array();
+var current_month = '';
+var current_year = '';
+var last_date = '';
+
+function calendar(id, d, highlight, adjusted)
+{
+ if (adjusted == undefined)
+ {
+ var d = new Date(d * 1000);
+ }
+
+ this.id = id;
+ this.highlight = highlight;
+ this.date_obj = d;
+ this.write = build_calendar;
+ this.total_days = total_days;
+ this.month = d.getMonth();
+ this.date = d.getDate();
+ this.day = d.getDay();
+ this.year = d.getFullYear();
+ this.hours = d.getHours();
+ this.minutes = d.getMinutes();
+ this.seconds = d.getSeconds();
+ this.date_str = date_str;
+
+ if (highlight == false)
+ {
+ this.selected_date = '';
+ }
+ else
+ {
+ this.selected_date = this.year + '' + this.month + '' + this.date;
+ }
+
+ // Set the "selected date"
+ d.setDate(1);
+ this.firstDay = d.getDay();
+
+ //then reset the date object to the correct date
+ d.setDate(this.date);
+}
+
+// Build the body of the calendar
+function build_calendar()
+{
+ var str = '';
+
+ // Calendar Heading
+
+ str += '<div id="cal' + this.id + '">';
+ str += '<table class="calendar" cellspacing="0" cellpadding="0" border="0" >';
+ str += '<tr>';
+ str += '<td class="calnavleft" onClick="change_month(-1, \'' + this.id + '\')">&lt;&lt;<\/td>';
+ str += '<td colspan="5" class="calheading">' + months[this.month] + ' ' + this.year + '<\/td>';
+ str += '<td class="calnavright" onClick="change_month(1, \'' + this.id + '\')">&gt;&gt;<\/td>';
+ str += '<\/tr>';
+
+ // Day Names
+
+ str += '<tr>';
+
+ for (i = 0; i < 7; i++)
+ {
+ str += '<td class="caldayheading">' + days[i] + '<\/td>';
+ }
+
+ str += '<\/tr>';
+
+ // Day Cells
+
+ str += '<tr>';
+
+ selDate = (last_date != '') ? last_date : this.date;
+
+ for (j = 0; j < 42; j++)
+ {
+ var displayNum = (j - this.firstDay + 1);
+
+ if (j < this.firstDay) // leading empty cells
+ {
+ str += '<td class="calblanktop">&nbsp;<\/td>';
+ }
+ else if (displayNum == selDate && this.highlight == true) // Selected date
+ {
+ str += '<td id="' + this.id +'selected" class="caldayselected" onClick="set_date(this,\'' + this.id + '\')">' + displayNum + '<\/td>';
+ }
+ else if (displayNum > this.total_days())
+ {
+ str += '<td class="calblankbot">&nbsp;<\/td>'; // trailing empty cells
+ }
+ else // Unselected days
+ {
+ str += '<td id="" class="caldaycells" onClick="set_date(this,\'' + this.id + '\'); return false;" onMouseOver="javascript:cell_highlight(this,\'' + displayNum + '\',\'' + this.id + '\');" onMouseOut="javascript:cell_reset(this,\'' + displayNum + '\',\'' + this.id + '\');" >' + displayNum + '<\/td>';
+ }
+
+ if (j % 7 == 6)
+ {
+ str += '<\/tr><tr>';
+ }
+ }
+
+ str += '<\/tr>';
+ str += '<\/table>';
+ str += '<\/div>';
+
+ return str;
+}
+
+// Total number of days in a month
+function total_days()
+{
+ switch(this.month)
+ {
+ case 1: // Check for leap year
+ if (( this.date_obj.getFullYear() % 4 == 0
+ && this.date_obj.getFullYear() % 100 != 0)
+ || this.date_obj.getFullYear() % 400 == 0)
+ return 29;
+ else
+ return 28;
+ case 3:
+ return 30;
+ case 5:
+ return 30;
+ case 8:
+ return 30;
+ case 10:
+ return 30
+ default:
+ return 31;
+ }
+}
+
+// Highlight Cell on Mouseover
+function cell_highlight(td, num, cal)
+{
+ cal = eval(cal);
+
+ if (last_click[cal.id] != num)
+ {
+ td.className = "caldaycellhover";
+ }
+}
+
+// Reset Cell on MouseOut
+function cell_reset(td, num, cal)
+{
+ cal = eval(cal);
+
+ if (last_click[cal.id] == num)
+ {
+ td.className = "caldayselected";
+ }
+ else
+ {
+ td.className = "caldaycells";
+ }
+}
+
+// Clear Field
+function clear_field(id)
+{
+ eval("document." + form_name + "." + id + ".value = ''");
+
+ document.getElementById(id + "selected").className = "caldaycells";
+ document.getElementById(id + "selected").id = "";
+
+ cal = eval(id);
+ cal.selected_date = '';
+}
+
+
+// Set date to specified time
+function set_to_time(id, raw)
+{
+ if (document.getElementById(id + "selected"))
+ {
+ document.getElementById(id + "selected").className = "caldaycells";
+ document.getElementById(id + "selected").id = "";
+ }
+
+ document.getElementById('cal' + id).innerHTML = '<div id="tempcal'+id+'">&nbsp;<'+'/div>';
+
+ var nowDate = new Date();
+ nowDate.setTime = raw * 1000;
+
+ current_month = nowDate.getMonth();
+ current_year = nowDate.getFullYear();
+ current_date = nowDate.getDate();
+
+ oldcal = eval(id);
+ oldcal.selected_date = current_year + '' + current_month + '' + current_date;
+
+ cal = new calendar(id, nowDate, true, true);
+ cal.selected_date = current_year + '' + current_month + '' + current_date;
+
+ last_date = cal.date;
+
+ document.getElementById('tempcal'+id).innerHTML = cal.write();
+
+ insert_date(cal);
+}
+
+// Set date to what is in the field
+var lastDates = new Array();
+
+function update_calendar(id, dateValue)
+{
+ if (lastDates[id] == dateValue) return;
+
+ lastDates[id] = dateValue;
+
+ var fieldString = dateValue.replace(/\s+/g, ' ');
+
+ while (fieldString.substring(0,1) == ' ')
+ {
+ fieldString = fieldString.substring(1, fieldString.length);
+ }
+
+ var dateString = fieldString.split(' ');
+ var dateParts = dateString[0].split('-')
+
+ if (dateParts.length < 3) return;
+ var newYear = dateParts[0];
+ var newMonth = dateParts[1];
+ var newDay = dateParts[2];
+
+ if (isNaN(newDay) || newDay < 1 || (newDay.length != 1 && newDay.length != 2)) return;
+ if (isNaN(newYear) || newYear < 1 || newYear.length != 4) return;
+ if (isNaN(newMonth) || newMonth < 1 || (newMonth.length != 1 && newMonth.length != 2)) return;
+
+ if (newMonth > 12) newMonth = 12;
+
+ if (newDay > 28)
+ {
+ switch(newMonth - 1)
+ {
+ case 1: // Check for leap year
+ if ((newYear % 4 == 0 && newYear % 100 != 0) || newYear % 400 == 0)
+ {
+ if (newDay > 29) newDay = 29;
+ }
+ else
+ {
+ if (newDay > 28) newDay = 28;
+ }
+ case 3:
+ if (newDay > 30) newDay = 30;
+ case 5:
+ if (newDay > 30) newDay = 30;
+ case 8:
+ if (newDay > 30) newDay = 30;
+ case 10:
+ if (newDay > 30) newDay = 30;
+ default:
+ if (newDay > 31) newDay = 31;
+ }
+ }
+
+ if (document.getElementById(id + "selected"))
+ {
+ document.getElementById(id + "selected").className = "caldaycells";
+ document.getElementById(id + "selected").id = "";
+ }
+
+ document.getElementById('cal' + id).innerHTML = '<div id="tempcal'+id+'">&nbsp;<'+'/div>';
+
+ var nowDate = new Date();
+ nowDate.setDate(newDay);
+ nowDate.setMonth(newMonth - 1);
+ nowDate.setYear(newYear);
+ nowDate.setHours(12);
+
+ current_month = nowDate.getMonth();
+ current_year = nowDate.getFullYear();
+
+ cal = new calendar(id, nowDate, true, true);
+ document.getElementById('tempcal'+id).innerHTML = cal.write();
+}
+
+// Set the date
+function set_date(td, cal)
+{
+ cal = eval(cal);
+
+ // If the user is clicking a cell that is already
+ // selected we'll de-select it and clear the form field
+
+ if (last_click[cal.id] == td.firstChild.nodeValue)
+ {
+ td.className = "caldaycells";
+ last_click[cal.id] = '';
+ remove_date(cal);
+ cal.selected_date = '';
+ return;
+ }
+
+ // Onward!
+ if (document.getElementById(cal.id + "selected"))
+ {
+ document.getElementById(cal.id + "selected").className = "caldaycells";
+ document.getElementById(cal.id + "selected").id = "";
+ }
+
+ td.className = "caldayselected";
+ td.id = cal.id + "selected";
+
+ cal.selected_date = cal.date_obj.getFullYear() + '' + cal.date_obj.getMonth() + '' + cal.date;
+ cal.date_obj.setDate(td.firstChild.nodeValue);
+ cal = new calendar(cal.id, cal.date_obj, true, true);
+ cal.selected_date = cal.date_obj.getFullYear() + '' + cal.date_obj.getMonth() + '' + cal.date;
+
+ last_date = cal.date;
+
+ //cal.date
+ last_click[cal.id] = cal.date;
+
+ // Insert the date into the form
+ insert_date(cal);
+}
+
+// Insert the date into the form field
+function insert_date(cal)
+{
+ cal = eval(cal);
+ fval = eval("document." + form_name + "." + cal.id);
+
+ if (fval.value == '')
+ {
+ fval.value = cal.date_str('y');
+ }
+ else
+ {
+ time = fval.value.substring(10);
+ new_date = cal.date_str('n') + time;
+ fval.value = new_date;
+ }
+}
+
+// Remove the date from the form field
+function remove_date(cal)
+{
+ cal = eval(cal);
+ fval = eval("document." + form_name + "." + cal.id);
+ fval.value = '';
+}
+
+// Change to a new month
+function change_month(mo, cal)
+{
+ cal = eval(cal);
+
+ if (current_month != '')
+ {
+ cal.date_obj.setMonth(current_month);
+ cal.date_obj.setYear(current_year);
+
+ current_month = '';
+ current_year = '';
+ }
+
+ var newMonth = cal.date_obj.getMonth() + mo;
+ var newDate = cal.date_obj.getDate();
+
+ if (newMonth == 12)
+ {
+ cal.date_obj.setYear(cal.date_obj.getFullYear() + 1)
+ newMonth = 0;
+ }
+ else if (newMonth == -1)
+ {
+ cal.date_obj.setYear(cal.date_obj.getFullYear() - 1)
+ newMonth = 11;
+ }
+
+ if (newDate > 28)
+ {
+ var newYear = cal.date_obj.getFullYear();
+
+ switch(newMonth)
+ {
+ case 1: // Check for leap year
+ if ((newYear % 4 == 0 && newYear % 100 != 0) || newYear % 400 == 0)
+ {
+ if (newDate > 29) newDate = 29;
+ }
+ else
+ {
+ if (newDate > 28) newDate = 28;
+ }
+ case 3:
+ if (newDate > 30) newDate = 30;
+ case 5:
+ if (newDate > 30) newDate = 30;
+ case 8:
+ if (newDate > 30) newDate = 30;
+ case 10:
+ if (newDate > 30) newDate = 30;
+ default:
+ if (newDate > 31) newDate = 31;
+ }
+ }
+
+ cal.date_obj.setDate(newDate);
+ cal.date_obj.setMonth(newMonth);
+ new_mdy = cal.date_obj.getFullYear() + '' + cal.date_obj.getMonth() + '' + cal.date;
+
+ highlight = (cal.selected_date == new_mdy) ? true : false;
+ cal = new calendar(cal.id, cal.date_obj, highlight, true);
+ document.getElementById('cal' + cal.id).innerHTML = cal.write();
+}
+
+// Finalize the date string
+function date_str(time)
+{
+ var month = this.month + 1;
+ if (month < 10)
+ month = '0' + month;
+
+ var day = (this.date < 10) ? '0' + this.date : this.date;
+ var minutes = (this.minutes < 10) ? '0' + this.minutes : this.minutes;
+
+ if (format == 'us')
+ {
+ var hours = (this.hours > 12) ? this.hours - 12 : this.hours;
+ var ampm = (this.hours > 11) ? 'PM' : 'AM'
+ }
+ else
+ {
+ var hours = this.hours;
+ var ampm = '';
+ }
+
+ if (time == 'y')
+ {
+ return this.year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ' ' + ampm;
+ }
+ else
+ {
+ return this.year + '-' + month + '-' + day;
+ }
+}
+
+//-->
+</script>
+<?php
+
+$r = ob_get_contents();
+ob_end_clean();
+return $r;
+}
+
+
+function js_calendar_write($field_id, $time = '', $highlight = TRUE)
+{
+ if ($time == '')
+ $time = time();
+
+ return
+ '<script type="text/javascript">
+ var '.$field_id.' = new calendar("'.$field_id.'", '.$time.', '.(($highlight == TRUE) ? 'true' : 'false').');
+ document.write('.$field_id.'.write());
+ </script>';
+}
+
?> \ No newline at end of file
diff --git a/system/scaffolding/Scaffolding.php b/system/scaffolding/Scaffolding.php
index d42b56863..fe2744e77 100644
--- a/system/scaffolding/Scaffolding.php
+++ b/system/scaffolding/Scaffolding.php
@@ -1,289 +1,289 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
-/**
- * Code Igniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, pMachine, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
-
-// ------------------------------------------------------------------------
-
-/**
- * Scaffolding Class
- *
- * Provides the Scaffolding framework
- *
- * @package CodeIgniter
- * @subpackage Scaffolding
- * @author Rick Ellis
- * @link http://www.codeigniter.com/user_guide/general/scaffolding.html
- */
-class Scaffolding {
-
- var $CI;
- var $current_table;
- var $base_url = '';
- var $lang = array();
-
- function Scaffolding($db_table)
- {
- $this->CI =& get_instance();
-
- $this->CI->load->database("", FALSE, TRUE);
- $this->CI->load->library('pagination');
-
- // Turn off caching
- $this->CI->db->cache_off();
-
- /**
- * Set the current table name
- * This is done when initializing scaffolding:
- * $this->load->scaffolding('table_name')
- *
- */
- $this->current_table = $db_table;
-
- /**
- * Set the path to the "view" files
- * We'll manually override the "view" path so that
- * the load->view function knows where to look.
- */
-
- $this->CI->load->_ci_view_path = BASEPATH.'scaffolding/views/';
-
- // Set the base URL
- $this->base_url = $this->CI->config->site_url().'/'.$this->CI->uri->segment(1).$this->CI->uri->slash_segment(2, 'both');
- $this->base_uri = $this->CI->uri->segment(1).$this->CI->uri->slash_segment(2, 'leading');
-
- // Set a few globals
- $data = array(
- 'image_url' => $this->CI->config->system_url().'scaffolding/images/',
- 'base_uri' => $this->base_uri,
- 'base_url' => $this->base_url,
- 'title' => $this->current_table
- );
-
- $this->CI->load->vars($data);
-
- // Load the language file and create variables
- $this->lang = $this->CI->load->language('scaffolding', '', TRUE);
- $this->CI->load->vars($this->lang);
-
- // Load the helper files we plan to use
- $this->CI->load->helper(array('url', 'form'));
-
-
- log_message('debug', 'Scaffolding Class Initialized');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * "Add" Page
- *
- * Shows a form representing the currently selected DB
- * so that data can be inserted
- *
- * @access public
- * @return string the HTML "add" page
- */
- function add()
- {
- $data = array(
- 'title' => ( ! isset($this->lang['scaff_add'])) ? 'Add Data' : $this->lang['scaff_add'],
- 'fields' => $this->CI->db->field_data($this->current_table),
- 'action' => $this->base_uri.'/insert'
- );
-
- $this->CI->load->view('add', $data);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Insert the data
- *
- * @access public
- * @return void redirects to the view page
- */
- function insert()
- {
- if ($this->CI->db->insert($this->current_table, $_POST) === FALSE)
- {
- $this->add();
- }
- else
- {
- redirect($this->base_uri.'/view/');
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * "View" Page
- *
- * Shows a table containing the data in the currently
- * selected DB
- *
- * @access public
- * @return string the HTML "view" page
- */
- function view()
- {
- // Fetch the total number of DB rows
- $total_rows = $this->CI->db->count_all($this->current_table);
-
- if ($total_rows < 1)
- {
- return $this->CI->load->view('no_data');
- }
-
- // Set the query limit/offset
- $per_page = 20;
- $offset = $this->CI->uri->segment(4, 0);
-
- // Run the query
- $query = $this->CI->db->get($this->current_table, $per_page, $offset);
-
- // Now let's get the field names
- $fields = $this->CI->db->list_fields($this->current_table);
-
- // We assume that the column in the first position is the primary field.
- $primary = current($fields);
-
- // Pagination!
- $this->CI->pagination->initialize(
- array(
- 'base_url' => $this->base_url.'/view',
- 'total_rows' => $total_rows,
- 'per_page' => $per_page,
- 'uri_segment' => 4,
- 'full_tag_open' => '<p>',
- 'full_tag_close' => '</p>'
- )
- );
-
- $data = array(
- 'title' => ( ! isset($this->lang['scaff_view'])) ? 'View Data' : $this->lang['scaff_view'],
- 'query' => $query,
- 'fields' => $fields,
- 'primary' => $primary,
- 'paginate' => $this->CI->pagination->create_links()
- );
-
- $this->CI->load->view('view', $data);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * "Edit" Page
- *
- * Shows a form representing the currently selected DB
- * so that data can be edited
- *
- * @access public
- * @return string the HTML "edit" page
- */
- function edit()
- {
- if (FALSE === ($id = $this->CI->uri->segment(4)))
- {
- return $this->view();
- }
-
- // Fetch the primary field name
- $primary = $this->CI->db->primary($this->current_table);
-
- // Run the query
- $query = $this->CI->db->getwhere($this->current_table, array($primary => $id));
-
- $data = array(
- 'title' => ( ! isset($this->lang['scaff_edit'])) ? 'Edit Data' : $this->lang['scaff_edit'],
- 'fields' => $query->field_data(),
- 'query' => $query->row(),
- 'action' => $this->base_uri.'/update/'.$this->CI->uri->segment(4)
- );
-
- $this->CI->load->view('edit', $data);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Update
- *
- * @access public
- * @return void redirects to the view page
- */
- function update()
- {
- // Fetch the primary key
- $primary = $this->CI->db->primary($this->current_table);
-
- // Now do the query
- $this->CI->db->update($this->current_table, $_POST, array($primary => $this->CI->uri->segment(4)));
-
- redirect($this->base_uri.'/view/');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Delete Confirmation
- *
- * @access public
- * @return string the HTML "delete confirm" page
- */
- function delete()
- {
- if ( ! isset($this->lang['scaff_del_confirm']))
- {
- $message = 'Are you sure you want to delete the following row: '.$this->CI->uri->segment(4);
- }
- else
- {
- $message = $this->lang['scaff_del_confirm'].' '.$this->CI->uri->segment(4);
- }
-
- $data = array(
- 'title' => ( ! isset($this->lang['scaff_delete'])) ? 'Delete Data' : $this->lang['scaff_delete'],
- 'message' => $message,
- 'no' => anchor(array($this->base_uri, 'view'), ( ! isset($this->lang['scaff_no'])) ? 'No' : $this->lang['scaff_no']),
- 'yes' => anchor(array($this->base_uri, 'do_delete', $this->CI->uri->segment(4)), ( ! isset($this->lang['scaff_yes'])) ? 'Yes' : $this->lang['scaff_yes'])
- );
-
- $this->CI->load->view('delete', $data);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Delete
- *
- * @access public
- * @return void redirects to the view page
- */
- function do_delete()
- {
- // Fetch the primary key
- $primary = $this->CI->db->primary($this->current_table);
-
- // Now do the query
- $this->CI->db->where($primary, $this->CI->uri->segment(4));
- $this->CI->db->delete($this->current_table);
-
- header("Refresh:0;url=".site_url(array($this->base_uri, 'view')));
- exit;
- }
-
-}
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, EllisLab, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Scaffolding Class
+ *
+ * Provides the Scaffolding framework
+ *
+ * @package CodeIgniter
+ * @subpackage Scaffolding
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/general/scaffolding.html
+ */
+class Scaffolding {
+
+ var $CI;
+ var $current_table;
+ var $base_url = '';
+ var $lang = array();
+
+ function Scaffolding($db_table)
+ {
+ $this->CI =& get_instance();
+
+ $this->CI->load->database("", FALSE, TRUE);
+ $this->CI->load->library('pagination');
+
+ // Turn off caching
+ $this->CI->db->cache_off();
+
+ /**
+ * Set the current table name
+ * This is done when initializing scaffolding:
+ * $this->load->scaffolding('table_name')
+ *
+ */
+ $this->current_table = $db_table;
+
+ /**
+ * Set the path to the "view" files
+ * We'll manually override the "view" path so that
+ * the load->view function knows where to look.
+ */
+
+ $this->CI->load->_ci_view_path = BASEPATH.'scaffolding/views/';
+
+ // Set the base URL
+ $this->base_url = $this->CI->config->site_url().'/'.$this->CI->uri->segment(1).$this->CI->uri->slash_segment(2, 'both');
+ $this->base_uri = $this->CI->uri->segment(1).$this->CI->uri->slash_segment(2, 'leading');
+
+ // Set a few globals
+ $data = array(
+ 'image_url' => $this->CI->config->system_url().'scaffolding/images/',
+ 'base_uri' => $this->base_uri,
+ 'base_url' => $this->base_url,
+ 'title' => $this->current_table
+ );
+
+ $this->CI->load->vars($data);
+
+ // Load the language file and create variables
+ $this->lang = $this->CI->load->language('scaffolding', '', TRUE);
+ $this->CI->load->vars($this->lang);
+
+ // Load the helper files we plan to use
+ $this->CI->load->helper(array('url', 'form'));
+
+
+ log_message('debug', 'Scaffolding Class Initialized');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * "Add" Page
+ *
+ * Shows a form representing the currently selected DB
+ * so that data can be inserted
+ *
+ * @access public
+ * @return string the HTML "add" page
+ */
+ function add()
+ {
+ $data = array(
+ 'title' => ( ! isset($this->lang['scaff_add'])) ? 'Add Data' : $this->lang['scaff_add'],
+ 'fields' => $this->CI->db->field_data($this->current_table),
+ 'action' => $this->base_uri.'/insert'
+ );
+
+ $this->CI->load->view('add', $data);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Insert the data
+ *
+ * @access public
+ * @return void redirects to the view page
+ */
+ function insert()
+ {
+ if ($this->CI->db->insert($this->current_table, $_POST) === FALSE)
+ {
+ $this->add();
+ }
+ else
+ {
+ redirect($this->base_uri.'/view/');
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * "View" Page
+ *
+ * Shows a table containing the data in the currently
+ * selected DB
+ *
+ * @access public
+ * @return string the HTML "view" page
+ */
+ function view()
+ {
+ // Fetch the total number of DB rows
+ $total_rows = $this->CI->db->count_all($this->current_table);
+
+ if ($total_rows < 1)
+ {
+ return $this->CI->load->view('no_data');
+ }
+
+ // Set the query limit/offset
+ $per_page = 20;
+ $offset = $this->CI->uri->segment(4, 0);
+
+ // Run the query
+ $query = $this->CI->db->get($this->current_table, $per_page, $offset);
+
+ // Now let's get the field names
+ $fields = $this->CI->db->list_fields($this->current_table);
+
+ // We assume that the column in the first position is the primary field.
+ $primary = current($fields);
+
+ // Pagination!
+ $this->CI->pagination->initialize(
+ array(
+ 'base_url' => $this->base_url.'/view',
+ 'total_rows' => $total_rows,
+ 'per_page' => $per_page,
+ 'uri_segment' => 4,
+ 'full_tag_open' => '<p>',
+ 'full_tag_close' => '</p>'
+ )
+ );
+
+ $data = array(
+ 'title' => ( ! isset($this->lang['scaff_view'])) ? 'View Data' : $this->lang['scaff_view'],
+ 'query' => $query,
+ 'fields' => $fields,
+ 'primary' => $primary,
+ 'paginate' => $this->CI->pagination->create_links()
+ );
+
+ $this->CI->load->view('view', $data);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * "Edit" Page
+ *
+ * Shows a form representing the currently selected DB
+ * so that data can be edited
+ *
+ * @access public
+ * @return string the HTML "edit" page
+ */
+ function edit()
+ {
+ if (FALSE === ($id = $this->CI->uri->segment(4)))
+ {
+ return $this->view();
+ }
+
+ // Fetch the primary field name
+ $primary = $this->CI->db->primary($this->current_table);
+
+ // Run the query
+ $query = $this->CI->db->getwhere($this->current_table, array($primary => $id));
+
+ $data = array(
+ 'title' => ( ! isset($this->lang['scaff_edit'])) ? 'Edit Data' : $this->lang['scaff_edit'],
+ 'fields' => $query->field_data(),
+ 'query' => $query->row(),
+ 'action' => $this->base_uri.'/update/'.$this->CI->uri->segment(4)
+ );
+
+ $this->CI->load->view('edit', $data);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Update
+ *
+ * @access public
+ * @return void redirects to the view page
+ */
+ function update()
+ {
+ // Fetch the primary key
+ $primary = $this->CI->db->primary($this->current_table);
+
+ // Now do the query
+ $this->CI->db->update($this->current_table, $_POST, array($primary => $this->CI->uri->segment(4)));
+
+ redirect($this->base_uri.'/view/');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Delete Confirmation
+ *
+ * @access public
+ * @return string the HTML "delete confirm" page
+ */
+ function delete()
+ {
+ if ( ! isset($this->lang['scaff_del_confirm']))
+ {
+ $message = 'Are you sure you want to delete the following row: '.$this->CI->uri->segment(4);
+ }
+ else
+ {
+ $message = $this->lang['scaff_del_confirm'].' '.$this->CI->uri->segment(4);
+ }
+
+ $data = array(
+ 'title' => ( ! isset($this->lang['scaff_delete'])) ? 'Delete Data' : $this->lang['scaff_delete'],
+ 'message' => $message,
+ 'no' => anchor(array($this->base_uri, 'view'), ( ! isset($this->lang['scaff_no'])) ? 'No' : $this->lang['scaff_no']),
+ 'yes' => anchor(array($this->base_uri, 'do_delete', $this->CI->uri->segment(4)), ( ! isset($this->lang['scaff_yes'])) ? 'Yes' : $this->lang['scaff_yes'])
+ );
+
+ $this->CI->load->view('delete', $data);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Delete
+ *
+ * @access public
+ * @return void redirects to the view page
+ */
+ function do_delete()
+ {
+ // Fetch the primary key
+ $primary = $this->CI->db->primary($this->current_table);
+
+ // Now do the query
+ $this->CI->db->where($primary, $this->CI->uri->segment(4));
+ $this->CI->db->delete($this->current_table);
+
+ header("Refresh:0;url=".site_url(array($this->base_uri, 'view')));
+ exit;
+ }
+
+}
?> \ No newline at end of file
diff --git a/system/scaffolding/views/footer.php b/system/scaffolding/views/footer.php
index 36b29d1cd..60b0a53e2 100644
--- a/system/scaffolding/views/footer.php
+++ b/system/scaffolding/views/footer.php
@@ -1,10 +1,10 @@
-
-</div>
-
-<div id="footer">
-<p><a href="http://www.codeigniter.com/">Code Igniter</a>, by <a href="http://www.pmachine.com">pMachine</a> - Version <?php echo APPVER ?></p>
-<p>Page rendered in {elapsed_time}</p>
-</div>
-
-</body>
+
+</div>
+
+<div id="footer">
+<p><a href="http://www.codeigniter.com/">CodeIgniter</a>, by <a href="http://www.EllisLab.com">EllisLab</a> - Version <?php echo APPVER ?></p>
+<p>Page rendered in {elapsed_time}</p>
+</div>
+
+</body>
</html> \ No newline at end of file