first
This commit is contained in:
275
.htaccess
Executable file
275
.htaccess
Executable file
@@ -0,0 +1,275 @@
|
||||
#########################################################################
|
||||
# Pretty URLs (i.e. no /index.php/ in your URLs) #
|
||||
#########################################################################
|
||||
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
|
||||
# Block access to hidden files and directories.
|
||||
RewriteCond %{REQUEST_URI} "!(^|/)\.well-known/([^./]+./?)+$" [NC]
|
||||
RewriteCond %{SCRIPT_FILENAME} -d [OR]
|
||||
RewriteCond %{SCRIPT_FILENAME} -f
|
||||
RewriteRule "(^|/)\." - [F]
|
||||
|
||||
# Store the current location in an environment variable CWD.
|
||||
# This removes the need for RewriteBase to be changed for some hosts.
|
||||
RewriteCond $0#%{REQUEST_URI} ([^#]*)#(.*)\1$
|
||||
RewriteRule ^.*$ - [E=CWD:%2]
|
||||
|
||||
# Go ahead and process files as normal.
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^.*$ %{ENV:CWD}index.php [QSA,L]
|
||||
</IfModule>
|
||||
|
||||
#########################################################################
|
||||
# Everything below is for caching and optimizing Pancake's performance. #
|
||||
#########################################################################
|
||||
|
||||
# Handle 404s
|
||||
Options -MultiViews
|
||||
ErrorDocument 404 /404.html
|
||||
|
||||
# Force IE to use the highest rendering mode it has.
|
||||
<IfModule mod_headers.c>
|
||||
Header set X-UA-Compatible "IE=edge"
|
||||
|
||||
# `mod_headers` cannot match based on the content-type, however,
|
||||
# the `X-UA-Compatible` response header should be sent only for
|
||||
# HTML documents and not for the other resources.
|
||||
|
||||
<FilesMatch "\.(appcache|atom|bbaw|bmp|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|topojson|tt[cf]|txt|vcard|vcf|vtt|webapp|web[mp]|webmanifest|woff2?|xloc|xml|xpi)$">
|
||||
Header unset X-UA-Compatible
|
||||
</FilesMatch>
|
||||
|
||||
</IfModule>
|
||||
|
||||
# Use UTF-8 encoding for anything served as `text/html` or `text/plain`.
|
||||
AddDefaultCharset utf-8
|
||||
|
||||
# Force UTF-8 for certain file formats.
|
||||
<IfModule mod_mime.c>
|
||||
AddCharset utf-8 .atom \
|
||||
.bbaw \
|
||||
.css \
|
||||
.geojson \
|
||||
.js \
|
||||
.json \
|
||||
.jsonld \
|
||||
.manifest \
|
||||
.rdf \
|
||||
.rss \
|
||||
.topojson \
|
||||
.vtt \
|
||||
.webapp \
|
||||
.webmanifest \
|
||||
.xloc \
|
||||
.xml
|
||||
</IfModule>
|
||||
|
||||
# Correct MIME types for all files.
|
||||
<IfModule mod_mime.c>
|
||||
AddType application/atom+xml atom
|
||||
AddType application/json json map topojson
|
||||
AddType application/ld+json jsonld
|
||||
AddType application/rss+xml rss
|
||||
AddType application/vnd.geo+json geojson
|
||||
AddType application/xml rdf xml
|
||||
AddType application/javascript js
|
||||
AddType application/manifest+json webmanifest
|
||||
AddType application/x-web-app-manifest+json webapp
|
||||
AddType text/cache-manifest appcache
|
||||
AddType audio/mp4 f4a f4b m4a
|
||||
AddType audio/ogg oga ogg opus
|
||||
AddType image/bmp bmp
|
||||
AddType image/svg+xml svg svgz
|
||||
AddType image/webp webp
|
||||
AddType video/mp4 f4v f4p m4v mp4
|
||||
AddType video/ogg ogv
|
||||
AddType video/webm webm
|
||||
AddType video/x-flv flv
|
||||
AddType image/x-icon cur ico
|
||||
AddType application/font-woff woff
|
||||
AddType application/font-woff2 woff2
|
||||
AddType application/vnd.ms-fontobject eot
|
||||
AddType application/x-font-ttf ttc ttf
|
||||
AddType font/opentype otf
|
||||
AddType application/octet-stream safariextz
|
||||
AddType application/x-bb-appworld bbaw
|
||||
AddType application/x-chrome-extension crx
|
||||
AddType application/x-opera-extension oex
|
||||
AddType application/x-xpinstall xpi
|
||||
AddType text/vcard vcard vcf
|
||||
AddType text/vnd.rim.location.xloc xloc
|
||||
AddType text/vtt vtt
|
||||
AddType text/x-component htc
|
||||
</IfModule>
|
||||
|
||||
# Block access to directories without an index file.
|
||||
<IfModule mod_autoindex.c>
|
||||
Options -Indexes
|
||||
</IfModule>
|
||||
|
||||
# Prevent some browsers from MIME-sniffing the response.
|
||||
<IfModule mod_headers.c>
|
||||
Header set X-Content-Type-Options "nosniff"
|
||||
</IfModule>
|
||||
|
||||
<IfModule mod_deflate.c>
|
||||
|
||||
# Force compression for mangled `Accept-Encoding` request headers
|
||||
# https://developer.yahoo.com/blogs/ydn/pushing-beyond-gzipping-25601.html
|
||||
|
||||
<IfModule mod_setenvif.c>
|
||||
<IfModule mod_headers.c>
|
||||
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
|
||||
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
|
||||
</IfModule>
|
||||
</IfModule>
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
# Compress all output labeled with one of the following media types.
|
||||
#
|
||||
# (!) For Apache versions below version 2.3.7 you don't need to
|
||||
# enable `mod_filter` and can remove the `<IfModule mod_filter.c>`
|
||||
# and `</IfModule>` lines as `AddOutputFilterByType` is still in
|
||||
# the core directives.
|
||||
#
|
||||
# https://httpd.apache.org/docs/current/mod/mod_filter.html#addoutputfilterbytype
|
||||
|
||||
<IfModule mod_filter.c>
|
||||
AddOutputFilterByType DEFLATE "application/atom+xml" \
|
||||
"application/javascript" \
|
||||
"application/json" \
|
||||
"application/ld+json" \
|
||||
"application/manifest+json" \
|
||||
"application/rdf+xml" \
|
||||
"application/rss+xml" \
|
||||
"application/schema+json" \
|
||||
"application/vnd.geo+json" \
|
||||
"application/vnd.ms-fontobject" \
|
||||
"application/x-font-ttf" \
|
||||
"application/x-javascript" \
|
||||
"application/x-web-app-manifest+json" \
|
||||
"application/xhtml+xml" \
|
||||
"application/xml" \
|
||||
"font/eot" \
|
||||
"font/opentype" \
|
||||
"image/bmp" \
|
||||
"image/svg+xml" \
|
||||
"image/vnd.microsoft.icon" \
|
||||
"image/x-icon" \
|
||||
"text/cache-manifest" \
|
||||
"text/css" \
|
||||
"text/html" \
|
||||
"text/javascript" \
|
||||
"text/plain" \
|
||||
"text/vcard" \
|
||||
"text/vnd.rim.location.xloc" \
|
||||
"text/vtt" \
|
||||
"text/x-component" \
|
||||
"text/x-cross-domain-policy" \
|
||||
"text/xml"
|
||||
|
||||
</IfModule>
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
# Map the following filename extensions to the specified
|
||||
# encoding type in order to make Apache serve the file types
|
||||
# with the appropriate `Content-Encoding` response header
|
||||
# (do note that this will NOT make Apache compress them!).
|
||||
#
|
||||
# If these files types would be served without an appropriate
|
||||
# `Content-Enable` response header, client applications (e.g.:
|
||||
# browsers) wouldn't know that they first need to uncompress
|
||||
# the response, and thus, wouldn't be able to understand the
|
||||
# content.
|
||||
#
|
||||
# https://httpd.apache.org/docs/current/mod/mod_mime.html#addencoding
|
||||
|
||||
<IfModule mod_mime.c>
|
||||
AddEncoding gzip svgz
|
||||
</IfModule>
|
||||
|
||||
</IfModule>
|
||||
|
||||
# Remove `ETags` as resources are sent with far-future expires headers.
|
||||
<IfModule mod_headers.c>
|
||||
Header unset ETag
|
||||
</IfModule>
|
||||
|
||||
FileETag None
|
||||
|
||||
# Expires Headers
|
||||
<IfModule mod_expires.c>
|
||||
ExpiresActive on
|
||||
ExpiresDefault "access plus 1 year"
|
||||
|
||||
# Data interchange
|
||||
ExpiresByType application/json "access plus 0 seconds"
|
||||
ExpiresByType application/ld+json "access plus 0 seconds"
|
||||
ExpiresByType application/xml "access plus 0 seconds"
|
||||
ExpiresByType text/xml "access plus 0 seconds"
|
||||
|
||||
# HTML
|
||||
ExpiresByType text/html "access plus 0 seconds"
|
||||
|
||||
# PDFs of Invoices / Proposals / Estimates
|
||||
ExpiresByType application/pdf "access plus 0 seconds"
|
||||
|
||||
# Manifest files
|
||||
ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds"
|
||||
ExpiresByType text/cache-manifest "access plus 0 seconds"
|
||||
|
||||
# Web feeds
|
||||
ExpiresByType application/atom+xml "access plus 1 hour"
|
||||
ExpiresByType application/rss+xml "access plus 1 hour"
|
||||
</IfModule>
|
||||
|
||||
# Block access to possibly sensitive files
|
||||
<FilesMatch "(^#.*#|\.(bak|conf|dist|fla|in[ci]|log|old|sh|sql|sw[op])|~)$">
|
||||
# Apache < 2.3
|
||||
<IfModule !mod_authz_core.c>
|
||||
Order allow,deny
|
||||
Deny from all
|
||||
Satisfy All
|
||||
</IfModule>
|
||||
|
||||
# Apache ≥ 2.3
|
||||
<IfModule mod_authz_core.c>
|
||||
Require all denied
|
||||
</IfModule>
|
||||
</FilesMatch>
|
||||
|
||||
# Hide PHP information
|
||||
<IfModule mod_headers.c>
|
||||
Header unset X-Powered-By
|
||||
</IfModule>
|
||||
|
||||
ServerSignature Off
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
81
LICENSE
Executable file
81
LICENSE
Executable file
@@ -0,0 +1,81 @@
|
||||
## End User License Agreement
|
||||
|
||||
This End User License Agreement (the “Agreement”) is a binding legal agreement between you and NullApps (the “Author”). By installing or using Pancake Payments (the “Software”), you agree to be bound by the terms of this Agreement. If you do not agree to the Agreement, do not download, install, or use the Software. Installation or use of the Software signifies that you have read, understood, and agreed to be bound by the Agreement.
|
||||
|
||||
### Usage
|
||||
|
||||
This Agreement grants a non-exclusive, non-transferable license to install and use the Software on a single Website. Additional Software licenses must be purchased in order to install and use the Software on additional Websites. You may not provide Pancake to others as a hosted solution or allow companies outside your organization to use the software. The Author reserves the right to determine whether use of the Software qualifies under this Agreement. The Author owns all rights, title and interest to the Software (including all intellectual property rights) and reserves all rights to the Software that are not expressly granted in this Agreement.
|
||||
|
||||
### Software Modification
|
||||
|
||||
You may alter, modify, or extend the Software for your own use, or commission a third-party to perform modifications for you, but you may not resell, redistribute or transfer the modified or derivative version without prior written consent from the Author. The Software may not be extracted and used in other programs without prior written consent from the Author.
|
||||
|
||||
### Backups
|
||||
|
||||
You may make copies of the Software in any machine readable form solely for back-up purposes, provided that you reproduce the Software in its original form and with all proprietary notices on the back-up copy. All rights to the Software not expressly granted herein are reserved by the Author.
|
||||
|
||||
### Display of Copyright Notices
|
||||
|
||||
All copyright and proprietary notices and logos in the Control Panel and within the Software files must remain intact.
|
||||
|
||||
### Restrictions
|
||||
|
||||
You understand and agree that you shall only use the Software in a manner that complies with any and all applicable laws in the jurisdictions in which you use the Software. Your use shall be in accordance with applicable restrictions concerning privacy and intellectual property rights.
|
||||
|
||||
You may not:
|
||||
|
||||
Distribute derivative works based on the Software (the distribution of themes and other add-ons to the Software written using APIs and other programmatic interfaces published by the Author are allowed);
|
||||
Reproduce the Software except as described in this Agreement;
|
||||
Sell, assign, license, disclose, distribute, or otherwise transfer or make available the Software or its Source Code, in whole or in part, in any form to any third parties, except during the course of normal use by users of Pancake, as installed on your server, via browser or other API-enabled applications.
|
||||
Remove or alter any proprietary notices on the Software.
|
||||
|
||||
THE SOFTWARE IS OFFERED ON AN “AS-IS” BASIS AND NO WARRANTY, EITHER EXPRESSED OR IMPLIED, IS GIVEN. THE AUTHOR EXPRESSLY DISCLAIMS ALL WARRANTIES OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. YOU ASSUME ALL RISK ASSOCIATED WITH THE QUALITY, PERFORMANCE, INSTALLATION AND USE OF THE SOFTWARE INCLUDING, BUT NOT LIMITED TO, THE RISKS OF PROGRAM ERRORS, DAMAGE TO EQUIPMENT, LOSS OF DATA OR SOFTWARE PROGRAMS, OR UNAVAILABILITY OR INTERRUPTION OF OPERATIONS. YOU ARE SOLELY RESPONSIBLE FOR DETERMINING THE APPROPRIATENESS OF USE THE SOFTWARE AND ASSUME ALL RISKS ASSOCIATED WITH ITS USE.
|
||||
|
||||
### Term, Termination, and Modification.
|
||||
|
||||
You may use the Software under this Agreement until either party terminates this Agreement as set forth in this paragraph. Either party may terminate the Agreement at any time, upon written notice to the other party. Upon termination, all licenses granted to you will terminate, and you will immediately uninstall and cease all use of the Software. The Sections entitled “No Warranty,” “Indemnification,” and “Limitation of Liability” will survive any termination of this Agreement.
|
||||
|
||||
The Author may modify the Software and this Agreement with notice to you either in email or by publishing content on the Software website, including but not limited to changing the functionality or appearance of the Software, and such modification will become binding on you unless you terminate this Agreement.
|
||||
|
||||
### Indemnification.
|
||||
|
||||
By accepting the Agreement, you agree to indemnify and otherwise hold harmless the Author, its officers, employers, agents, subsidiaries, affiliates and other partners from any direct, indirect, incidental, special, consequential or exemplary damages arising out of, relating to, or resulting from your use of the Software or any other matter relating to the Software.
|
||||
|
||||
### Limitation of Liability.
|
||||
|
||||
YOU EXPRESSLY UNDERSTAND AND AGREE THAT THE AUTHOR SHALL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL OR EXEMPLARY DAMAGES, INCLUDING BUT NOT LIMITED TO, DAMAGES FOR LOSS OF PROFITS, GOODWILL, USE, DATA OR OTHER INTANGIBLE LOSSES (EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES). SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF THE LIMITATION OR EXCLUSION OF LIABILITY FOR INCIDENTAL OR CONSEQUENTIAL DAMAGES. ACCORDINGLY, SOME OF THE ABOVE LIMITATIONS MAY NOT APPLY TO YOU. IN NO EVENT WILL THE AUTHORS’S TOTAL CUMULATIVE DAMAGES EXCEED THE FEES YOU PAID TO THE AUTHOR UNDER THIS AGREEMENT IN THE MOST RECENT TWELVE-MONTH PERIOD.
|
||||
|
||||
### Refund Policy
|
||||
|
||||
Since the Author is offering non-tangible irrevocable, digital goods we do not issue refunds after purchase is made, which you are responsible for understanding upon purchasing the Software. No refunds will be issued, guaranteed or promised. Once we issue a downloadable file, there is no way for us to recall, or rescind a digital item that has already been issued to a customer.
|
||||
|
||||
### Price Changes
|
||||
|
||||
The Author reserves the right at any time and from time to time to modify or discontinue, temporarily or permanently, a product (or any part thereof) with or without notice. Prices of all products are subject to change without notice.
|
||||
|
||||
### Delivery
|
||||
|
||||
After the Author has successfully received your payment, your Software purchase will become activated and you will be emailed instructions to the email address you provided. This may take up to 1 hour but usually happens within minutes. If you do not receive an email after this time period, please email support@pancakeapp.com
|
||||
Please Note: No invoices will be available for your purchases, as sales receipts will be provided online.
|
||||
|
||||
## Definitions
|
||||
|
||||
### Definition of Website
|
||||
|
||||
A “Website” is defined as a single domain including sub-domains that operate as a single entity. What constitutes a single entity shall be at the sole discretion of the Author.
|
||||
|
||||
### Definition of Source Code
|
||||
|
||||
The “Source Code” is defined as the contents of all HTML, CSS, JavaScript, and PHP files provided with the Software and includes all related image files and database schemas.
|
||||
|
||||
### Definition of an Update
|
||||
|
||||
An “Update” of the Software is defined as that which adds minor functionality enhancements or any bug fix to the current version. This class of release is identified by the change of the revision to the right of the decimal point, i.e. X.1 to X.2
|
||||
|
||||
The assignment to the category of Update or Upgrade shall be at the sole discretion of the Author.
|
||||
|
||||
### Definition of an Upgrade
|
||||
|
||||
An “Upgrade” is a major release of the Software and is defined as that which incorporates major new features or enhancement that increase the core functionality of the software. This class of release is identified by the change of the revision to the left of the decimal point, i.e. 4.X to 5.X
|
||||
|
||||
The assignment to the category of Update or Upgrade shall be at the sole discretion of the Author.
|
||||
18
composer.json
Normal file
18
composer.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "bendtstudio/pancake",
|
||||
"description": "Self-hosted invoicing application (Pancake) for bendtstudio homelab",
|
||||
"type": "project",
|
||||
"require": {
|
||||
"php": "^8.3",
|
||||
"ext-gd": "*",
|
||||
"ext-dom": "*",
|
||||
"ext-curl": "*",
|
||||
"ext-mbstring": "*"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"system/",
|
||||
"application/"
|
||||
]
|
||||
}
|
||||
}
|
||||
273
example.htaccess
Executable file
273
example.htaccess
Executable file
@@ -0,0 +1,273 @@
|
||||
#########################################################################
|
||||
# Pretty URLs (i.e. no /index.php/ in your URLs) #
|
||||
#########################################################################
|
||||
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
|
||||
# Block access to hidden files and directories.
|
||||
RewriteCond %{REQUEST_URI} "!(^|/)\.well-known/([^./]+./?)+$" [NC]
|
||||
RewriteCond %{SCRIPT_FILENAME} -d [OR]
|
||||
RewriteCond %{SCRIPT_FILENAME} -f
|
||||
RewriteRule "(^|/)\." - [F]
|
||||
|
||||
# Store the current location in an environment variable CWD.
|
||||
# This removes the need for RewriteBase to be changed for some hosts.
|
||||
RewriteCond $0#%{REQUEST_URI} ([^#]*)#(.*)\1$
|
||||
RewriteRule ^.*$ - [E=CWD:%2]
|
||||
|
||||
# Go ahead and process files as normal.
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^.*$ %{ENV:CWD}index.php [QSA,L]
|
||||
</IfModule>
|
||||
|
||||
#########################################################################
|
||||
# Everything below is for caching and optimizing Pancake's performance. #
|
||||
#########################################################################
|
||||
|
||||
# Handle 404s
|
||||
Options -MultiViews
|
||||
ErrorDocument 404 /404.html
|
||||
|
||||
# Force IE to use the highest rendering mode it has.
|
||||
<IfModule mod_headers.c>
|
||||
Header set X-UA-Compatible "IE=edge"
|
||||
|
||||
# `mod_headers` cannot match based on the content-type, however,
|
||||
# the `X-UA-Compatible` response header should be sent only for
|
||||
# HTML documents and not for the other resources.
|
||||
|
||||
<FilesMatch "\.(appcache|atom|bbaw|bmp|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|topojson|tt[cf]|txt|vcard|vcf|vtt|webapp|web[mp]|webmanifest|woff2?|xloc|xml|xpi)$">
|
||||
Header unset X-UA-Compatible
|
||||
</FilesMatch>
|
||||
|
||||
</IfModule>
|
||||
|
||||
# Use UTF-8 encoding for anything served as `text/html` or `text/plain`.
|
||||
AddDefaultCharset utf-8
|
||||
|
||||
# Force UTF-8 for certain file formats.
|
||||
<IfModule mod_mime.c>
|
||||
AddCharset utf-8 .atom \
|
||||
.bbaw \
|
||||
.css \
|
||||
.geojson \
|
||||
.js \
|
||||
.json \
|
||||
.jsonld \
|
||||
.manifest \
|
||||
.rdf \
|
||||
.rss \
|
||||
.topojson \
|
||||
.vtt \
|
||||
.webapp \
|
||||
.webmanifest \
|
||||
.xloc \
|
||||
.xml
|
||||
</IfModule>
|
||||
|
||||
# Correct MIME types for all files.
|
||||
<IfModule mod_mime.c>
|
||||
AddType application/atom+xml atom
|
||||
AddType application/json json map topojson
|
||||
AddType application/ld+json jsonld
|
||||
AddType application/rss+xml rss
|
||||
AddType application/vnd.geo+json geojson
|
||||
AddType application/xml rdf xml
|
||||
AddType application/javascript js
|
||||
AddType application/manifest+json webmanifest
|
||||
AddType application/x-web-app-manifest+json webapp
|
||||
AddType text/cache-manifest appcache
|
||||
AddType audio/mp4 f4a f4b m4a
|
||||
AddType audio/ogg oga ogg opus
|
||||
AddType image/bmp bmp
|
||||
AddType image/svg+xml svg svgz
|
||||
AddType image/webp webp
|
||||
AddType video/mp4 f4v f4p m4v mp4
|
||||
AddType video/ogg ogv
|
||||
AddType video/webm webm
|
||||
AddType video/x-flv flv
|
||||
AddType image/x-icon cur ico
|
||||
AddType application/font-woff woff
|
||||
AddType application/font-woff2 woff2
|
||||
AddType application/vnd.ms-fontobject eot
|
||||
AddType application/x-font-ttf ttc ttf
|
||||
AddType font/opentype otf
|
||||
AddType application/octet-stream safariextz
|
||||
AddType application/x-bb-appworld bbaw
|
||||
AddType application/x-chrome-extension crx
|
||||
AddType application/x-opera-extension oex
|
||||
AddType application/x-xpinstall xpi
|
||||
AddType text/vcard vcard vcf
|
||||
AddType text/vnd.rim.location.xloc xloc
|
||||
AddType text/vtt vtt
|
||||
AddType text/x-component htc
|
||||
</IfModule>
|
||||
|
||||
# Block access to directories without an index file.
|
||||
<IfModule mod_autoindex.c>
|
||||
Options -Indexes
|
||||
</IfModule>
|
||||
|
||||
# Prevent some browsers from MIME-sniffing the response.
|
||||
<IfModule mod_headers.c>
|
||||
Header set X-Content-Type-Options "nosniff"
|
||||
</IfModule>
|
||||
|
||||
<IfModule mod_deflate.c>
|
||||
|
||||
# Force compression for mangled `Accept-Encoding` request headers
|
||||
# https://developer.yahoo.com/blogs/ydn/pushing-beyond-gzipping-25601.html
|
||||
|
||||
<IfModule mod_setenvif.c>
|
||||
<IfModule mod_headers.c>
|
||||
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
|
||||
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
|
||||
</IfModule>
|
||||
</IfModule>
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
# Compress all output labeled with one of the following media types.
|
||||
#
|
||||
# (!) For Apache versions below version 2.3.7 you don't need to
|
||||
# enable `mod_filter` and can remove the `<IfModule mod_filter.c>`
|
||||
# and `</IfModule>` lines as `AddOutputFilterByType` is still in
|
||||
# the core directives.
|
||||
#
|
||||
# https://httpd.apache.org/docs/current/mod/mod_filter.html#addoutputfilterbytype
|
||||
|
||||
<IfModule mod_filter.c>
|
||||
AddOutputFilterByType DEFLATE "application/atom+xml" \
|
||||
"application/javascript" \
|
||||
"application/json" \
|
||||
"application/ld+json" \
|
||||
"application/manifest+json" \
|
||||
"application/rdf+xml" \
|
||||
"application/rss+xml" \
|
||||
"application/schema+json" \
|
||||
"application/vnd.geo+json" \
|
||||
"application/vnd.ms-fontobject" \
|
||||
"application/x-font-ttf" \
|
||||
"application/x-javascript" \
|
||||
"application/x-web-app-manifest+json" \
|
||||
"application/xhtml+xml" \
|
||||
"application/xml" \
|
||||
"font/eot" \
|
||||
"font/opentype" \
|
||||
"image/bmp" \
|
||||
"image/svg+xml" \
|
||||
"image/vnd.microsoft.icon" \
|
||||
"image/x-icon" \
|
||||
"text/cache-manifest" \
|
||||
"text/css" \
|
||||
"text/html" \
|
||||
"text/javascript" \
|
||||
"text/plain" \
|
||||
"text/vcard" \
|
||||
"text/vnd.rim.location.xloc" \
|
||||
"text/vtt" \
|
||||
"text/x-component" \
|
||||
"text/x-cross-domain-policy" \
|
||||
"text/xml"
|
||||
|
||||
</IfModule>
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
# Map the following filename extensions to the specified
|
||||
# encoding type in order to make Apache serve the file types
|
||||
# with the appropriate `Content-Encoding` response header
|
||||
# (do note that this will NOT make Apache compress them!).
|
||||
#
|
||||
# If these files types would be served without an appropriate
|
||||
# `Content-Enable` response header, client applications (e.g.:
|
||||
# browsers) wouldn't know that they first need to uncompress
|
||||
# the response, and thus, wouldn't be able to understand the
|
||||
# content.
|
||||
#
|
||||
# https://httpd.apache.org/docs/current/mod/mod_mime.html#addencoding
|
||||
|
||||
<IfModule mod_mime.c>
|
||||
AddEncoding gzip svgz
|
||||
</IfModule>
|
||||
|
||||
</IfModule>
|
||||
|
||||
# Remove `ETags` as resources are sent with far-future expires headers.
|
||||
<IfModule mod_headers.c>
|
||||
Header unset ETag
|
||||
</IfModule>
|
||||
|
||||
FileETag None
|
||||
|
||||
# Expires Headers
|
||||
<IfModule mod_expires.c>
|
||||
ExpiresActive on
|
||||
ExpiresDefault "access plus 1 year"
|
||||
|
||||
# Data interchange
|
||||
ExpiresByType application/json "access plus 0 seconds"
|
||||
ExpiresByType application/ld+json "access plus 0 seconds"
|
||||
ExpiresByType application/xml "access plus 0 seconds"
|
||||
ExpiresByType text/xml "access plus 0 seconds"
|
||||
|
||||
# HTML
|
||||
ExpiresByType text/html "access plus 0 seconds"
|
||||
|
||||
# PDFs of Invoices / Proposals / Estimates
|
||||
ExpiresByType application/pdf "access plus 0 seconds"
|
||||
|
||||
# Manifest files
|
||||
ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds"
|
||||
ExpiresByType text/cache-manifest "access plus 0 seconds"
|
||||
|
||||
# Web feeds
|
||||
ExpiresByType application/atom+xml "access plus 1 hour"
|
||||
ExpiresByType application/rss+xml "access plus 1 hour"
|
||||
</IfModule>
|
||||
|
||||
# Block access to possibly sensitive files
|
||||
<FilesMatch "(^#.*#|\.(bak|conf|dist|fla|in[ci]|log|old|sh|sql|sw[op])|~)$">
|
||||
# Apache < 2.3
|
||||
<IfModule !mod_authz_core.c>
|
||||
Order allow,deny
|
||||
Deny from all
|
||||
Satisfy All
|
||||
</IfModule>
|
||||
|
||||
# Apache ≥ 2.3
|
||||
<IfModule mod_authz_core.c>
|
||||
Require all denied
|
||||
</IfModule>
|
||||
</FilesMatch>
|
||||
|
||||
# Hide PHP information
|
||||
<IfModule mod_headers.c>
|
||||
Header unset X-Powered-By
|
||||
</IfModule>
|
||||
|
||||
ServerSignature Off
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
16
index.php
Executable file
16
index.php
Executable file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Pancake
|
||||
*
|
||||
* A simple, fast, self-hosted invoicing application
|
||||
*
|
||||
* @package Pancake
|
||||
* @author Pancake Dev Team
|
||||
* @copyright Copyright (c) 2014, Pancake Payments
|
||||
* @license http://pancakeapp.com/license
|
||||
* @link http://pancakeapp.com
|
||||
*/
|
||||
|
||||
$index_file = __FILE__;
|
||||
require_once 'system/pancake/pancake_index.php';
|
||||
942
installer/assets/css/style.css
Executable file
942
installer/assets/css/style.css
Executable file
@@ -0,0 +1,942 @@
|
||||
/* CSS Reset */
|
||||
html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, code, del, dfn, em, img, q, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {
|
||||
margin:0;
|
||||
padding:0;
|
||||
border:0;
|
||||
font-weight:inherit;
|
||||
font-style:inherit;
|
||||
font-size:100%;
|
||||
font-family:inherit;
|
||||
vertical-align:baseline;
|
||||
}
|
||||
blockquote:before, blockquote:after, q:before, q:after {
|
||||
content:"";
|
||||
}
|
||||
blockquote, q {
|
||||
quotes:"" "";
|
||||
}
|
||||
a img {
|
||||
border:none;
|
||||
}
|
||||
p {
|
||||
margin:0 0 20px;
|
||||
clear:both;
|
||||
line-height:1.6;
|
||||
}
|
||||
/* Headings */
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
font-weight:normal;
|
||||
margin-bottom:10px;
|
||||
}
|
||||
h1 {
|
||||
font-size:24px;
|
||||
font-weight:bold;
|
||||
}
|
||||
h2 {
|
||||
font-size:18px;
|
||||
font-weight:bold;
|
||||
border-bottom:1px solid #ccc;
|
||||
padding-bottom:5px;
|
||||
margin-bottom:25px;
|
||||
}
|
||||
h3 {
|
||||
font-size:14px;
|
||||
font-weight:bold;
|
||||
}
|
||||
h4 {
|
||||
font-weight:bold;
|
||||
}
|
||||
h5 {
|
||||
font-size:12px;
|
||||
}
|
||||
h6 {
|
||||
font-size:11px;
|
||||
}
|
||||
|
||||
/* Base */
|
||||
body {
|
||||
background:#D6E4EE;
|
||||
font-family:"Helvetica Neue", Arial, Helvetica, sans-serif;
|
||||
color:#666;
|
||||
line-height:1.5;
|
||||
font-size:75%;
|
||||
}
|
||||
|
||||
#statusBar {
|
||||
width:780px;
|
||||
margin:0 auto;
|
||||
text-align:right;
|
||||
}
|
||||
#statusBar a {
|
||||
color:#666;
|
||||
text-decoration:none;
|
||||
padding:0 0 0 20px;
|
||||
background:url('../img/warning_16.png') center left no-repeat;
|
||||
}
|
||||
#wrapper {
|
||||
width:960px;
|
||||
margin: 60px auto;
|
||||
}
|
||||
|
||||
#wrapper h1 a.homelink {
|
||||
padding:40px;
|
||||
text-indent:-9999px;
|
||||
display:block;
|
||||
width:260px;
|
||||
}
|
||||
|
||||
|
||||
.home #wrapper {
|
||||
margin:20px auto;
|
||||
}
|
||||
|
||||
#wrapper p.error {
|
||||
color:#990000;
|
||||
padding:10px 20px;
|
||||
}
|
||||
|
||||
#wrapper p.success {
|
||||
color:green;
|
||||
border:1px solid green;
|
||||
padding:5px 20px;
|
||||
background:#f3f3f3;
|
||||
}
|
||||
|
||||
#header {
|
||||
|
||||
}
|
||||
|
||||
|
||||
span.small_instruction {
|
||||
font-size:12px;
|
||||
line-height:10px!important;
|
||||
display:block;
|
||||
margin:0 0 20px 0 ;
|
||||
}
|
||||
|
||||
.col2 {
|
||||
width:200px;
|
||||
}
|
||||
|
||||
td.col3 {
|
||||
font-size:12px;
|
||||
background-color:rgba(255,255,255,0.8);
|
||||
text-indent:20px;
|
||||
color:#777;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#headerInvoice {
|
||||
height:118px;
|
||||
margin:0 auto;
|
||||
background:url('../img/invoice_header.png') no-repeat;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#header ul#navigation {
|
||||
width:400px;
|
||||
float:right;
|
||||
list-style:none;
|
||||
padding:0;
|
||||
margin:20px 0 0 0;
|
||||
}
|
||||
|
||||
#header ul#navigation li {
|
||||
float:left;
|
||||
margin:0 10px 0 0;
|
||||
padding:0;
|
||||
}
|
||||
|
||||
#header ul#navigation li a {
|
||||
padding:5px 10px 3px 10px;
|
||||
background:#f2f2f2;
|
||||
margin:0;
|
||||
text-decoration:none;
|
||||
color:#69D2E7;
|
||||
}
|
||||
|
||||
#header ul#navigation li a:hover, #header ul#navigation li a.active {
|
||||
background:#fff;
|
||||
}
|
||||
|
||||
|
||||
#content {
|
||||
background: #fff;
|
||||
padding:10px 40px 20px;
|
||||
clear:both;
|
||||
margin-bottom:10px;
|
||||
-moz-border-radius:10px 0 10px 10px;
|
||||
-webkit-border-radius:10px 0 10px 10px;
|
||||
}
|
||||
|
||||
#footer {
|
||||
text-align:right;
|
||||
}
|
||||
|
||||
#wrapper h1 {
|
||||
margin:0px 0 50px 0 ;
|
||||
text-indent:-9999px;
|
||||
}
|
||||
|
||||
h2.toggle {
|
||||
line-height:46px;
|
||||
text-indent:60px;
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
|
||||
h1, h3, h4 {
|
||||
color:#69D2E7;
|
||||
}
|
||||
a {
|
||||
color:#69D2E7;
|
||||
}
|
||||
h2 {
|
||||
color:#fa6900;
|
||||
}
|
||||
|
||||
.orangered {
|
||||
color:#fa6900
|
||||
}
|
||||
|
||||
h2.plus {
|
||||
background:url('../img/add_48.png') center left no-repeat;
|
||||
}
|
||||
|
||||
h2.minus {
|
||||
background:url('../img/cancel_48.png') center left no-repeat;
|
||||
}
|
||||
/*
|
||||
input[type="text"], input[type="password"], textarea {
|
||||
-moz-border-radius:5px;
|
||||
-webkit-border-radius:5px;
|
||||
background-color:#F2F2F2;
|
||||
border:1px solid #69D2E7;
|
||||
border-radius:5px;
|
||||
font: inherit;
|
||||
color:#F38630;
|
||||
padding:4px 2px;
|
||||
}
|
||||
*/
|
||||
.col2 input[type="text"] {
|
||||
width:180px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.center {
|
||||
text-align:center;
|
||||
padding:40px 0 10px 0;
|
||||
}
|
||||
|
||||
#addSuccess {
|
||||
height:175px;
|
||||
margin:10px 0;
|
||||
|
||||
}
|
||||
|
||||
#addSuccess h1 {
|
||||
line-height:46px;
|
||||
text-indent:60px;
|
||||
background:url('../img/accepted_48.png') center left no-repeat;
|
||||
margin:0 0 0 0;
|
||||
}
|
||||
|
||||
#addSuccess a {
|
||||
|
||||
}
|
||||
|
||||
#addSuccess span {
|
||||
padding:10px 40px;
|
||||
border:1px solid #69D2E7;
|
||||
color:#F38630;
|
||||
margin:20px auto;
|
||||
font-size:160%;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
.receipt {
|
||||
margin-left: 20px
|
||||
}
|
||||
.receipt th {
|
||||
text-align: right;
|
||||
font-size: 1.3em;
|
||||
}
|
||||
.receipt td {
|
||||
font-size: 1.3em
|
||||
}
|
||||
|
||||
.centered_x {
|
||||
margin-left: auto; margin-right: auto
|
||||
}
|
||||
|
||||
.bordered {
|
||||
padding: 15px;
|
||||
border: 1px solid #ddd;
|
||||
background-color: #ffffff
|
||||
}
|
||||
|
||||
.pad_left {
|
||||
padding: 0 0 0 15px
|
||||
}
|
||||
.pad_right {
|
||||
padding: 0 15px 0 0
|
||||
}
|
||||
|
||||
.tight {
|
||||
line-height:140%;
|
||||
}
|
||||
|
||||
|
||||
p.pancake {
|
||||
text-align:right;
|
||||
font-size:12px;
|
||||
}
|
||||
|
||||
p.pancake a {
|
||||
text-decoration:none;
|
||||
}
|
||||
|
||||
span.small {
|
||||
font-size:10px;
|
||||
}
|
||||
|
||||
span.small a, p.key a {
|
||||
text-decoration:none;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
.paidInv {
|
||||
background:#f1ffbf;
|
||||
border:1px solid #a6d50f;
|
||||
padding:10px 20px 15px;
|
||||
margin-bottom:20px;
|
||||
-moz-border-radius:5px;
|
||||
-webkit-border:5px;
|
||||
border-radius:5px;
|
||||
-moz-box-shadow:1px 1px rgba(255, 255, 255, 0.6) inset;
|
||||
-webkit-box-shadow:1px 1px rgba(255, 255, 255, 0.6) inset;
|
||||
}
|
||||
|
||||
.paidInv span {
|
||||
color:green;
|
||||
font-size:24px;
|
||||
}
|
||||
|
||||
.outstanding {
|
||||
background:#fecdc6;
|
||||
border:1px solid #f45d43;
|
||||
padding:10px 20px 15px;
|
||||
margin-bottom:20px;
|
||||
-moz-border-radius:5px;
|
||||
-webkit-border:5px;
|
||||
border-radius:5px;
|
||||
-moz-box-shadow:1px 1px rgba(255, 255, 255, 0.6) inset;
|
||||
-webkit-box-shadow:1px 1px rgba(255, 255, 255, 0.6) inset;
|
||||
}
|
||||
|
||||
.outstanding span {
|
||||
color:#990000;
|
||||
font-size:24px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.notification {
|
||||
border-width:1px;
|
||||
border-style:solid;
|
||||
padding:17px 17px 17px 17px;
|
||||
margin-bottom:15px;
|
||||
-moz-border-radius:5px;
|
||||
-webkit-border:5px;
|
||||
border-radius:5px;
|
||||
-moz-box-shadow:1px 1px rgba(255, 255, 255, 0.6) inset;
|
||||
-webkit-box-shadow:1px 1px rgba(255, 255, 255, 0.6) inset;
|
||||
}
|
||||
.notification.success {
|
||||
background:#f1ffbf;
|
||||
border-color:#a6d50f;
|
||||
}
|
||||
.notification.error {
|
||||
background:#fecdc6;
|
||||
border-color:#f45d43;
|
||||
}
|
||||
|
||||
div.notification p {
|
||||
margin: 0 0 3px 0;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#logo {
|
||||
float:left;
|
||||
position:relative;
|
||||
top:22px;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse:separate;
|
||||
border-spacing:0px;
|
||||
}
|
||||
caption, th, td {
|
||||
text-align:left;
|
||||
font-weight:normal;
|
||||
}
|
||||
table, td, th {
|
||||
vertical-align:middle;
|
||||
}
|
||||
td {
|
||||
width:230px;
|
||||
}
|
||||
table {
|
||||
width:100%;
|
||||
}
|
||||
thead td, thead th {
|
||||
background-color:#E6E6E6;
|
||||
}
|
||||
tr td, thead th {
|
||||
color:#404040;
|
||||
padding:8px 0;
|
||||
}
|
||||
tr td.first, thead th.first {
|
||||
border-left:0;
|
||||
}
|
||||
tr td {
|
||||
vertical-align:middle;
|
||||
}
|
||||
thead td, thead th {
|
||||
font-weight:bold;
|
||||
padding:8px;
|
||||
color:#333333;
|
||||
}
|
||||
|
||||
tbody th {
|
||||
padding:0 8px;
|
||||
text-align:left;
|
||||
}
|
||||
td.alt {
|
||||
background: #F5FAFA;
|
||||
}
|
||||
|
||||
.listtable {
|
||||
border: 1px solid #999999;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
.listtable thead td, .listtable thead th {
|
||||
background: #394754 url('../img/nav-bg.gif') repeat-x top;
|
||||
color: #FFFFFF;
|
||||
padding: 5px 8px;
|
||||
}
|
||||
|
||||
.listtable tr td {
|
||||
border: 1px solid #999999;
|
||||
padding: 5px 5px 5px 8px;
|
||||
}
|
||||
|
||||
#nav {
|
||||
line-height: 100%;
|
||||
float:right;
|
||||
margin-top:47px;
|
||||
}
|
||||
#nav li {
|
||||
margin: 0 0 0 10px;
|
||||
float: left;
|
||||
position: relative;
|
||||
list-style: none;
|
||||
}
|
||||
/* main level link */
|
||||
#nav a {
|
||||
background: #394754 url('../img/nav-bg.gif') repeat-x top;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
padding: 8px 15px;
|
||||
margin: 0;
|
||||
border: 1px solid #394754;
|
||||
-webkit-border-radius: 5px 5px 0px 0px;
|
||||
-moz-border-radius: 5px 5px 0px 0px;
|
||||
text-shadow: 0 1px 1px rgba(0, 0, 0, .3);
|
||||
}
|
||||
#nav a:hover {
|
||||
background: #525f6d;
|
||||
text-shadow: 0 1px 0 rgba(255, 255, 255, 1);
|
||||
}
|
||||
/* main level link hover */
|
||||
#nav .current a, #nav li:hover > a {
|
||||
background: #525f6d url('../img/nav-hover.gif') repeat-x top;
|
||||
text-shadow: 0 1px 0 #394754;
|
||||
}
|
||||
/* sub levels link hover */
|
||||
#nav ul li:hover a, #nav li:hover li a {
|
||||
background: none;
|
||||
border: none;
|
||||
color: #666;
|
||||
-webkit-box-shadow: none;
|
||||
-moz-box-shadow: none;
|
||||
}
|
||||
#nav ul a:hover {
|
||||
background: #728496 !important;
|
||||
color: #fff !important;
|
||||
-webkit-border-radius: 0;
|
||||
-moz-border-radius: 0;
|
||||
text-shadow: 0 1px 1px rgba(0, 0, 0, .1);
|
||||
}
|
||||
/* dropdown */
|
||||
#nav li:hover > ul {
|
||||
display: block;
|
||||
}
|
||||
/* level 2 list */
|
||||
#nav ul {
|
||||
display: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 120px;
|
||||
position: absolute;
|
||||
top: 30px;
|
||||
left: 0;
|
||||
background: #f2f2f2 url('../img/nav-dd-bg.gif') repeat-x bottom;
|
||||
border: solid 1px #d9d9d9;
|
||||
-webkit-border-radius: 0px 5px 5px 5px;
|
||||
-moz-border-radius: 0px 5px 5px 5px;
|
||||
border-radius: 0px 5px 5px 5px;
|
||||
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
|
||||
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
|
||||
}
|
||||
#nav ul li {
|
||||
float: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
z-index:10;
|
||||
}
|
||||
#nav ul a {
|
||||
font-weight: normal;
|
||||
text-shadow: 0 1px 0 #fff;
|
||||
}
|
||||
/* level 3+ list */
|
||||
#nav ul ul {
|
||||
left: 181px;
|
||||
top: -3px;
|
||||
}
|
||||
/* rounded corners of first and last link */
|
||||
#nav ul li:first-child > a {
|
||||
-webkit-border-top-left-radius: 0;
|
||||
-moz-border-radius-topleft: 0;
|
||||
-webkit-border-top-right-radius: 5px;
|
||||
-moz-border-radius-topright: 5px;
|
||||
}
|
||||
#nav ul li:last-child > a {
|
||||
-webkit-border-bottom-left-radius: 5px;
|
||||
-moz-border-radius-bottomleft: 5px;
|
||||
-webkit-border-bottom-right-radius: 5px;
|
||||
-moz-border-radius-bottomright: 5px;
|
||||
}
|
||||
/* clearfix */
|
||||
#nav:after {
|
||||
content: ".";
|
||||
display: block;
|
||||
clear: both;
|
||||
visibility: hidden;
|
||||
line-height: 0;
|
||||
height: 0;
|
||||
}
|
||||
#nav {
|
||||
display: inline-block;
|
||||
}
|
||||
html[xmlns] #nav {
|
||||
display: block;
|
||||
}
|
||||
* html #nav {
|
||||
height: 1%;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Forms */
|
||||
form label {
|
||||
padding-top:2px;
|
||||
display: block;
|
||||
color:#444;
|
||||
font-size:14px;
|
||||
font-weight:bold;
|
||||
float:left;
|
||||
width:150px;
|
||||
}
|
||||
form p {
|
||||
margin-bottom:10px;
|
||||
padding-bottom:20px;
|
||||
}
|
||||
form div.row {
|
||||
clear:both;
|
||||
margin-bottom:20px;
|
||||
}
|
||||
form .row label {
|
||||
width:130px;
|
||||
}
|
||||
form input[type="radio"], form input[type="checkbox"] {
|
||||
width:auto;
|
||||
}
|
||||
form .row .checkbox, form .row .radio {
|
||||
width:auto;
|
||||
margin-right:10px;
|
||||
}
|
||||
form .row .checkbox {
|
||||
margin-left:10px;
|
||||
}
|
||||
form input, form textarea, form select {
|
||||
background: #FFFFFF url('../img/input-bg.gif') repeat-x top;
|
||||
-moz-border-radius:4px;
|
||||
-webkit-border-radius:4px;
|
||||
border:1px solid #afafaf;
|
||||
outline:medium none;
|
||||
padding:4px 6px;
|
||||
margin:0;
|
||||
color:#555;
|
||||
}
|
||||
|
||||
form input:focus, form textarea:focus {
|
||||
color: #000;
|
||||
background: #FFFEDE;
|
||||
border: 1px solid #aaa;
|
||||
}
|
||||
|
||||
form input.error {
|
||||
border:1px solid #e17984;
|
||||
background:#f8dbdd;
|
||||
color:#b36069;
|
||||
}
|
||||
form input {
|
||||
/* width:150px; */
|
||||
}
|
||||
form input.small {
|
||||
width:50px;
|
||||
}
|
||||
form input.large {
|
||||
width:250px;
|
||||
}
|
||||
form optgroup {
|
||||
background:#f7f7f7;
|
||||
}
|
||||
fieldset {
|
||||
margin-bottom:15px;
|
||||
}
|
||||
form.nocol label {
|
||||
float:none;
|
||||
margin-bottom:5px;
|
||||
}
|
||||
form.nocol div.row {
|
||||
margin-bottom:15px;
|
||||
}
|
||||
.auto {
|
||||
width:100px;
|
||||
}
|
||||
|
||||
.25 {
|
||||
width:25px!important;
|
||||
}
|
||||
|
||||
.50 {
|
||||
width:50px!important;
|
||||
}
|
||||
|
||||
.75 {
|
||||
width:75px!important;
|
||||
}
|
||||
|
||||
.100 {
|
||||
width:100px;
|
||||
}
|
||||
|
||||
.200 {
|
||||
width:200px;
|
||||
}
|
||||
|
||||
.300 {
|
||||
width:300px;
|
||||
}
|
||||
#add-row {
|
||||
margin:10px 0;
|
||||
}
|
||||
form textarea {
|
||||
margin-bottom:20px;
|
||||
}
|
||||
|
||||
ul#file-inputs,
|
||||
ul#file-inputs li {
|
||||
list-style: none;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
.file_remove td {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
.btn_remove {
|
||||
color: #C60D22;
|
||||
padding:5px 0px 5px 26px;
|
||||
border:0;
|
||||
font-size:12px;
|
||||
background:url('../img/cross_24.png') center left no-repeat;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.button, button, .button2, .button:visited, .button2:visited {
|
||||
-webkit-border-radius:5px 5px 5px 5px;
|
||||
-o-border-radius:5px 5px 5px 5px;
|
||||
-moz-border-radius:5px 5px 5px 5px;
|
||||
border-radius:5px 5px 5px 5px;
|
||||
|
||||
background: #6abe18;
|
||||
background: -moz-linear-gradient(top, #cbe951, #9dd254 5%, #5eac11);
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #cbe951), color-stop(.03, #9dd254), to(#5eac11));
|
||||
border-color:#53A40C #53A40C #468F0A;
|
||||
border-style:solid;
|
||||
border-width:1px;
|
||||
color:#FFFFFF;
|
||||
display:inline-block;
|
||||
font-family:Arial,Helvetica,sans-serif;
|
||||
font-size:14px;
|
||||
font-weight:bold;
|
||||
padding:9px 18px;
|
||||
text-align:center;
|
||||
text-decoration:none;
|
||||
text-shadow:0 1px 1px #316903;
|
||||
width:auto;
|
||||
}
|
||||
.button:hover, button:hover, .button2:hover {
|
||||
background: #61b212;
|
||||
background: -moz-linear-gradient(top, #cbe951, #98ca53 5%, #55a10b);
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #cbe951), color-stop(.03, #98ca53), to(#55a10b));
|
||||
border-bottom:1px solid #468F0A;
|
||||
color:#FFFFFF;
|
||||
}
|
||||
.button:focus, button:focus, .button2:focus {
|
||||
-moz-box-shadow:0 2px 5px #346C13 inset, 0 1px 0 #D0E0C7;
|
||||
background: #61b212;
|
||||
background: -moz-linear-gradient(top, #cbe951, #98ca53 5%, #55a10b);
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #cbe951), color-stop(.03, #98ca53), to(#55a10b));
|
||||
border:medium none;
|
||||
color:#FFFFFF;
|
||||
padding:10px 19px;
|
||||
text-shadow:0 -1px 1px #316903;
|
||||
}
|
||||
|
||||
|
||||
.btn_grey{
|
||||
|
||||
/* GENERAL */
|
||||
padding:5px 10px;
|
||||
text-decoration: none;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
font-size: 11px;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
display:inline-block;
|
||||
margin-top:-10px;
|
||||
|
||||
|
||||
/* BACKGROUND GRADIENTS */
|
||||
background: #E6E6E6;
|
||||
background: -moz-linear-gradient(top, #FFF, #f5f5f5 5%, #e2e2e2 100%);
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #FFF), color-stop(.03, #f5f5f5), to(#e2e2e2));
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#f5f5f5', EndColorStr='#e2e2e2'); /* IE6,IE7 only */
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#f5f5f5', EndColorStr='#e2e2e2')"; /* IE8 only */
|
||||
|
||||
/* BORDER RADIUS */
|
||||
-moz-border-radius: 4px;
|
||||
-webkit-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
|
||||
/* BORDERS */
|
||||
border:1px solid #d0d0d0;
|
||||
border-bottom:1px solid #b5b5b5;
|
||||
|
||||
/* TEXT COLOR & SHADOW */
|
||||
color:#5e5e5e;
|
||||
text-shadow: 1px 1px 1px #FFF;
|
||||
}
|
||||
|
||||
.btn_grey:hover {
|
||||
|
||||
/* BACKGROUND GRADIENTS */
|
||||
background: #EEE;
|
||||
background: -moz-linear-gradient(top, #FFF, #e5e5e5 100%);
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #FFF), to(#e5e5e5));
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#FFFFFF', EndColorStr='#e5e5e5'); /* IE6,IE7 only */
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#FFFFFF', EndColorStr='#e5e5e5')"; /* IE8 only */
|
||||
}
|
||||
|
||||
.btn_grey:focus {
|
||||
|
||||
/* GENERAL */
|
||||
padding:5px 10px 4px 10px;
|
||||
|
||||
/* TEXT COLOR & SHADOW */
|
||||
color:#FFF;
|
||||
text-shadow: -1px -1px 1px #888;
|
||||
|
||||
/* BORDERS */
|
||||
border:none;
|
||||
|
||||
/* BACKGROUND GRADIENTS */
|
||||
background:#999;
|
||||
background: -moz-linear-gradient(top, #999, #777 5%, #AFAFAF);
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #999), color-stop(.05, #777), to(#AFAFAF));
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#777777', EndColorStr='#AFAFAF'); /* IE6,IE7 only */
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#777777', EndColorStr='#AFAFAF')"; /* IE8 only */
|
||||
|
||||
/* INNER SHADOW & OUTER SHADOW */
|
||||
box-shadow: inset 0px 2px 5px #444, 0 1px 0px #DDD;
|
||||
-webkit-box-shadow: inset 0px 2px 5px #444, 0 1px 0px #DDD;
|
||||
-moz-box-shadow: inset 0px 2px 7px #444, 0 1px 0px #DDD;
|
||||
}
|
||||
|
||||
/* ========================== */
|
||||
/* = Big notification boxes = */
|
||||
/* ========================== */
|
||||
|
||||
.no_object_notification {
|
||||
min-height:800px;
|
||||
border:8px solid #ccc;
|
||||
background:#f2f2f2 url('../../../third_party/themes/admin/pancake/img/good_stack.png') 650px 560px no-repeat!important;
|
||||
margin:20px 0 20px 40px;
|
||||
overflow:hidden;
|
||||
}
|
||||
|
||||
.super-warning {
|
||||
border:8px solid #DF0B24!important;
|
||||
}
|
||||
|
||||
span.bad-news {
|
||||
color:red;
|
||||
display:block;
|
||||
clear:both;
|
||||
}
|
||||
|
||||
.no_object_notification h2, .no_object_notification h4 {
|
||||
color:#666;
|
||||
font-size:36px!important;
|
||||
margin: 20px 0 0 0px!important;
|
||||
font-family: 'Paytone One', arial, serif!important;
|
||||
text-shadow:0 2px #fff!important;
|
||||
}
|
||||
|
||||
.no_object_notification p {
|
||||
margin:20px 0 0 0px;
|
||||
font-size:18px;
|
||||
}
|
||||
|
||||
.no_object_notification p.call_to_action {
|
||||
clear:both;
|
||||
width:450px;
|
||||
}
|
||||
|
||||
|
||||
.no_object_notification p.call_to_action a.blue-btn {
|
||||
float:right;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* ==================== */
|
||||
/* = Installer Styles = */
|
||||
/* ==================== */
|
||||
|
||||
ul.requirements {
|
||||
list-style:none;
|
||||
margin:20px 0 20px 20px ;
|
||||
}
|
||||
|
||||
ul.requirements {
|
||||
/*color:#4ECDC4;*/
|
||||
color:#999;
|
||||
}
|
||||
|
||||
ul.requirements li {
|
||||
height:26px;
|
||||
padding:2px 0 0 30px;
|
||||
background:url('../../../third_party/themes/pancake/img/ui_icons/arrow_right_small.png') top left no-repeat;
|
||||
}
|
||||
|
||||
.success {
|
||||
color:#6abe18;
|
||||
}
|
||||
|
||||
.col1 {
|
||||
width:140px;
|
||||
text-align:right;
|
||||
padding-right:4px;
|
||||
}
|
||||
|
||||
.col3 {
|
||||
font-size:12px;
|
||||
color:#69D2E7;
|
||||
}
|
||||
|
||||
.pass {
|
||||
color: #3EA224;
|
||||
font-weight: bold;
|
||||
font-size: 200%;
|
||||
}
|
||||
.fail {
|
||||
color: #FF3000;
|
||||
font-weight: bold;
|
||||
font-size: 200%;
|
||||
}
|
||||
|
||||
|
||||
.focus {
|
||||
background:#C5D4D9;
|
||||
}
|
||||
|
||||
hr {
|
||||
margin-top: 20px;
|
||||
margin-left: 0px;
|
||||
border: 0;
|
||||
border-bottom: 1px solid #ccc;
|
||||
}
|
||||
|
||||
.checks-table {
|
||||
margin-top: 30px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.checks-table td {
|
||||
background-color: rgba(242, 242, 242, 0.75);
|
||||
}
|
||||
|
||||
p.notification {
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
code {
|
||||
white-space: pre;
|
||||
font-family: monospace;
|
||||
background: #ddd;
|
||||
padding: 4px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
BIN
installer/assets/img/good_stack.png
Executable file
BIN
installer/assets/img/good_stack.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 118 KiB |
BIN
installer/assets/img/logo.png
Executable file
BIN
installer/assets/img/logo.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
BIN
installer/assets/img/nav-bg.gif
Executable file
BIN
installer/assets/img/nav-bg.gif
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 264 B |
4
installer/assets/js/jquery-1.11.2.min.js
vendored
Executable file
4
installer/assets/js/jquery-1.11.2.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
10
installer/assets/js/main.js
Executable file
10
installer/assets/js/main.js
Executable file
@@ -0,0 +1,10 @@
|
||||
$('input, select, textarea').bind({
|
||||
focusin: function () {
|
||||
var wrapper = $(this).closest('tr');
|
||||
$(wrapper).addClass('focus');
|
||||
},
|
||||
focusout: function () {
|
||||
var wrapper = $(this).closest('tr');
|
||||
$(wrapper).removeClass('focus');
|
||||
}
|
||||
});
|
||||
103
installer/config/autoload.php
Executable file
103
installer/config/autoload.php
Executable file
@@ -0,0 +1,103 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
| AUTO-LOADER
|
||||
| -------------------------------------------------------------------
|
||||
| This file specifies which systems should be loaded by default.
|
||||
|
|
||||
| In order to keep the framework as light-weight as possible only the
|
||||
| absolute minimal resources are loaded by default. For example,
|
||||
| the database is not connected to automatically since no assumption
|
||||
| is made regarding whether you intend to use it. This file lets
|
||||
| you globally define which systems you would like loaded with every
|
||||
| request.
|
||||
|
|
||||
| -------------------------------------------------------------------
|
||||
| Instructions
|
||||
| -------------------------------------------------------------------
|
||||
|
|
||||
| These are the things you can load automatically:
|
||||
|
|
||||
| 1. Libraries
|
||||
| 2. Helper files
|
||||
| 3. Custom config files
|
||||
| 4. Language files
|
||||
| 5. Models
|
||||
|
|
||||
*/
|
||||
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
| Auto-load Libraries
|
||||
| -------------------------------------------------------------------
|
||||
| These are the classes located in the system/libraries folder
|
||||
| or in your application/libraries folder.
|
||||
|
|
||||
| Prototype:
|
||||
|
|
||||
| $autoload['libraries'] = array('database', 'session', 'xmlrpc');
|
||||
*/
|
||||
|
||||
$autoload['libraries'] = array('session');
|
||||
|
||||
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
| Auto-load Helper Files
|
||||
| -------------------------------------------------------------------
|
||||
| Prototype:
|
||||
|
|
||||
| $autoload['helper'] = array('url', 'file');
|
||||
*/
|
||||
|
||||
$autoload['helper'] = array('url', 'form', 'language');
|
||||
|
||||
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
| Auto-load Config files
|
||||
| -------------------------------------------------------------------
|
||||
| Prototype:
|
||||
|
|
||||
| $autoload['config'] = array('config1', 'config2');
|
||||
|
|
||||
| NOTE: This item is intended for use ONLY if you have created custom
|
||||
| config files. Otherwise, leave it blank.
|
||||
|
|
||||
*/
|
||||
|
||||
$autoload['config'] = array();
|
||||
|
||||
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
| Auto-load Language files
|
||||
| -------------------------------------------------------------------
|
||||
| Prototype:
|
||||
|
|
||||
| $autoload['language'] = array('lang1', 'lang2');
|
||||
|
|
||||
| NOTE: Do not include the "_lang" part of your file. For example
|
||||
| "codeigniter_lang.php" would be referenced as array('codeigniter');
|
||||
|
|
||||
*/
|
||||
|
||||
$autoload['language'] = array();
|
||||
|
||||
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
| Auto-load Models
|
||||
| -------------------------------------------------------------------
|
||||
| Prototype:
|
||||
|
|
||||
| $autoload['model'] = array('model1', 'model2');
|
||||
|
|
||||
*/
|
||||
|
||||
$autoload['model'] = array();
|
||||
|
||||
|
||||
|
||||
/* End of file autoload.php */
|
||||
/* Location: ./application/config/autoload.php */
|
||||
3
installer/config/config.php
Executable file
3
installer/config/config.php
Executable file
@@ -0,0 +1,3 @@
|
||||
<?php include FCPATH.'system/pancake/config/config.php';
|
||||
|
||||
$config['sess_use_database'] = FALSE;
|
||||
1
installer/config/constants.php
Executable file
1
installer/config/constants.php
Executable file
@@ -0,0 +1 @@
|
||||
<?php include FCPATH.'system/pancake/config/constants.php';
|
||||
62
installer/config/database.php
Executable file
62
installer/config/database.php
Executable file
@@ -0,0 +1,62 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
| DATABASE CONNECTIVITY SETTINGS
|
||||
| -------------------------------------------------------------------
|
||||
| This file will contain the settings needed to access your database.
|
||||
|
|
||||
| For complete instructions please consult the "Database Connection"
|
||||
| page of the User Guide.
|
||||
|
|
||||
| -------------------------------------------------------------------
|
||||
| EXPLANATION OF VARIABLES
|
||||
| -------------------------------------------------------------------
|
||||
|
|
||||
| ['hostname'] The hostname of your database server.
|
||||
| ['username'] The username used to connect to the database
|
||||
| ['password'] The password used to connect to the database
|
||||
| ['database'] The name of the database you want to connect to
|
||||
| ['dbdriver'] The database type. ie: mysql. Currently supported:
|
||||
mysql, mysqli, postgre, odbc, mssql, sqlite, oci8
|
||||
| ['dbprefix'] You can add an optional prefix, which will be added
|
||||
| to the table name when using the Active Record class
|
||||
| ['pconnect'] TRUE/FALSE - Whether to use a persistent connection
|
||||
| ['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
|
||||
| ['cache_on'] TRUE/FALSE - Enables/disables query caching
|
||||
| ['cachedir'] The path to the folder where cache files should be stored
|
||||
| ['char_set'] The character set used in communicating with the database
|
||||
| ['dbcollat'] The character collation used in communicating with the database
|
||||
| ['swap_pre'] A default table prefix that should be swapped with the dbprefix
|
||||
| ['autoinit'] Whether or not to automatically initialize the database.
|
||||
| ['stricton'] TRUE/FALSE - forces "Strict Mode" connections
|
||||
| - good for ensuring strict SQL while developing
|
||||
|
|
||||
| The $active_group variable lets you choose which connection group to
|
||||
| make active. By default there is only one group (the "default" group).
|
||||
|
|
||||
| The $active_record variables lets you determine whether or not to load
|
||||
| the active record class
|
||||
*/
|
||||
|
||||
$active_group = "default";
|
||||
$active_record = TRUE;
|
||||
|
||||
$db['default']['hostname'] = "localhost";
|
||||
$db['default']['username'] = "";
|
||||
$db['default']['password'] = "";
|
||||
$db['default']['database'] = "";
|
||||
$db['default']['dbdriver'] = "mysql";
|
||||
$db['default']['dbprefix'] = "";
|
||||
$db['default']['pconnect'] = TRUE;
|
||||
$db['default']['db_debug'] = TRUE;
|
||||
$db['default']['cache_on'] = FALSE;
|
||||
$db['default']['cachedir'] = "";
|
||||
$db['default']['char_set'] = "utf8";
|
||||
$db['default']['dbcollat'] = "utf8_general_ci";
|
||||
$db['default']['swap_pre'] = "";
|
||||
$db['default']['autoinit'] = TRUE;
|
||||
$db['default']['stricton'] = FALSE;
|
||||
|
||||
|
||||
/* End of file database.php */
|
||||
/* Location: ./application/config/database.php */
|
||||
15
installer/config/doctypes.php
Executable file
15
installer/config/doctypes.php
Executable file
@@ -0,0 +1,15 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
$_doctypes = array(
|
||||
'xhtml11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
|
||||
'xhtml1-strict' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
|
||||
'xhtml1-trans' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
|
||||
'xhtml1-frame' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
|
||||
'html5' => '<!DOCTYPE html>',
|
||||
'html4-strict' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
|
||||
'html4-trans' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
|
||||
'html4-frame' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">'
|
||||
);
|
||||
|
||||
/* End of file doctypes.php */
|
||||
/* Location: ./application/config/doctypes.php */
|
||||
64
installer/config/foreign_chars.php
Executable file
64
installer/config/foreign_chars.php
Executable file
@@ -0,0 +1,64 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
| Foreign Characters
|
||||
| -------------------------------------------------------------------
|
||||
| This file contains an array of foreign characters for transliteration
|
||||
| conversion used by the Text helper
|
||||
|
|
||||
*/
|
||||
$foreign_characters = array('223' => "ss", // ß
|
||||
'224' => "a",
|
||||
'225' => "a",
|
||||
'226' => "a",
|
||||
'229' => "a",
|
||||
'227' => "ae",
|
||||
'230' => "ae",
|
||||
'228' => "ae",
|
||||
'231' => "c",
|
||||
'232' => "e", // è
|
||||
'233' => "e", // é
|
||||
'234' => "e", // ê
|
||||
'235' => "e", // ë
|
||||
'236' => "i",
|
||||
'237' => "i",
|
||||
'238' => "i",
|
||||
'239' => "i",
|
||||
'241' => "n",
|
||||
'242' => "o",
|
||||
'243' => "o",
|
||||
'244' => "o",
|
||||
'245' => "o",
|
||||
'246' => "oe", // ö
|
||||
'249' => "u",
|
||||
'250' => "u",
|
||||
'251' => "u",
|
||||
'252' => "ue", // ü
|
||||
'255' => "y",
|
||||
'257' => "aa",
|
||||
'269' => "ch",
|
||||
'275' => "ee",
|
||||
'291' => "gj",
|
||||
'299' => "ii",
|
||||
'311' => "kj",
|
||||
'316' => "lj",
|
||||
'326' => "nj",
|
||||
'353' => "sh",
|
||||
'363' => "uu",
|
||||
'382' => "zh",
|
||||
'256' => "aa",
|
||||
'268' => "ch",
|
||||
'274' => "ee",
|
||||
'290' => "gj",
|
||||
'298' => "ii",
|
||||
'310' => "kj",
|
||||
'315' => "lj",
|
||||
'325' => "nj",
|
||||
'352' => "sh",
|
||||
'362' => "uu",
|
||||
'381' => "zh",
|
||||
);
|
||||
|
||||
|
||||
/* End of file foreign_chars.php */
|
||||
/* Location: ./application/config/foreign_chars.php */
|
||||
16
installer/config/hooks.php
Executable file
16
installer/config/hooks.php
Executable file
@@ -0,0 +1,16 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/*
|
||||
| -------------------------------------------------------------------------
|
||||
| Hooks
|
||||
| -------------------------------------------------------------------------
|
||||
| This file lets you define "hooks" to extend CI without hacking the core
|
||||
| files. Please see the user guide for info:
|
||||
|
|
||||
| http://codeigniter.com/user_guide/general/hooks.html
|
||||
|
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* End of file hooks.php */
|
||||
/* Location: ./application/config/hooks.php */
|
||||
10
installer/config/index.html
Executable file
10
installer/config/index.html
Executable file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
11
installer/config/license.php
Executable file
11
installer/config/license.php
Executable file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
if (!defined('BASEPATH')) {
|
||||
exit('No direct script access allowed');
|
||||
}
|
||||
|
||||
$config = [];
|
||||
$config["first_name"] = "Timothy";
|
||||
$config["last_name"] = "Bendt";
|
||||
$config["license_key"] = "PAN-B144B7ZGZ1J8QPMK";
|
||||
$config["email"] = "sirtimbly@gmail.com";
|
||||
105
installer/config/mimes.php
Executable file
105
installer/config/mimes.php
Executable file
@@ -0,0 +1,105 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
| MIME TYPES
|
||||
| -------------------------------------------------------------------
|
||||
| This file contains an array of mime types. It is used by the
|
||||
| Upload class to help identify allowed file types.
|
||||
|
|
||||
*/
|
||||
|
||||
$mimes = array( 'hqx' => 'application/mac-binhex40',
|
||||
'cpt' => 'application/mac-compactpro',
|
||||
'csv' => array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel'),
|
||||
'bin' => 'application/macbinary',
|
||||
'dms' => 'application/octet-stream',
|
||||
'lha' => 'application/octet-stream',
|
||||
'lzh' => 'application/octet-stream',
|
||||
'exe' => array('application/octet-stream', 'application/x-msdownload'),
|
||||
'class' => 'application/octet-stream',
|
||||
'psd' => 'application/x-photoshop',
|
||||
'so' => 'application/octet-stream',
|
||||
'sea' => 'application/octet-stream',
|
||||
'dll' => 'application/octet-stream',
|
||||
'oda' => 'application/oda',
|
||||
'pdf' => array('application/pdf', 'application/x-download'),
|
||||
'ai' => 'application/postscript',
|
||||
'eps' => 'application/postscript',
|
||||
'ps' => 'application/postscript',
|
||||
'smi' => 'application/smil',
|
||||
'smil' => 'application/smil',
|
||||
'mif' => 'application/vnd.mif',
|
||||
'xls' => array('application/excel', 'application/vnd.ms-excel', 'application/msexcel'),
|
||||
'ppt' => array('application/powerpoint', 'application/vnd.ms-powerpoint'),
|
||||
'wbxml' => 'application/wbxml',
|
||||
'wmlc' => 'application/wmlc',
|
||||
'dcr' => 'application/x-director',
|
||||
'dir' => 'application/x-director',
|
||||
'dxr' => 'application/x-director',
|
||||
'dvi' => 'application/x-dvi',
|
||||
'gtar' => 'application/x-gtar',
|
||||
'gz' => 'application/x-gzip',
|
||||
'php' => 'application/x-httpd-php',
|
||||
'php4' => 'application/x-httpd-php',
|
||||
'php3' => 'application/x-httpd-php',
|
||||
'phtml' => 'application/x-httpd-php',
|
||||
'phps' => 'application/x-httpd-php-source',
|
||||
'js' => 'application/x-javascript',
|
||||
'swf' => 'application/x-shockwave-flash',
|
||||
'sit' => 'application/x-stuffit',
|
||||
'tar' => 'application/x-tar',
|
||||
'tgz' => array('application/x-tar', 'application/x-gzip-compressed'),
|
||||
'xhtml' => 'application/xhtml+xml',
|
||||
'xht' => 'application/xhtml+xml',
|
||||
'zip' => array('application/x-zip', 'application/zip', 'application/x-zip-compressed'),
|
||||
'mid' => 'audio/midi',
|
||||
'midi' => 'audio/midi',
|
||||
'mpga' => 'audio/mpeg',
|
||||
'mp2' => 'audio/mpeg',
|
||||
'mp3' => array('audio/mpeg', 'audio/mpg'),
|
||||
'aif' => 'audio/x-aiff',
|
||||
'aiff' => 'audio/x-aiff',
|
||||
'aifc' => 'audio/x-aiff',
|
||||
'ram' => 'audio/x-pn-realaudio',
|
||||
'rm' => 'audio/x-pn-realaudio',
|
||||
'rpm' => 'audio/x-pn-realaudio-plugin',
|
||||
'ra' => 'audio/x-realaudio',
|
||||
'rv' => 'video/vnd.rn-realvideo',
|
||||
'wav' => 'audio/x-wav',
|
||||
'bmp' => 'image/bmp',
|
||||
'gif' => 'image/gif',
|
||||
'jpeg' => array('image/jpeg', 'image/pjpeg'),
|
||||
'jpg' => array('image/jpeg', 'image/pjpeg'),
|
||||
'jpe' => array('image/jpeg', 'image/pjpeg'),
|
||||
'png' => array('image/png', 'image/x-png'),
|
||||
'tiff' => 'image/tiff',
|
||||
'tif' => 'image/tiff',
|
||||
'css' => 'text/css',
|
||||
'html' => 'text/html',
|
||||
'htm' => 'text/html',
|
||||
'shtml' => 'text/html',
|
||||
'txt' => 'text/plain',
|
||||
'text' => 'text/plain',
|
||||
'log' => array('text/plain', 'text/x-log'),
|
||||
'rtx' => 'text/richtext',
|
||||
'rtf' => 'text/rtf',
|
||||
'xml' => 'text/xml',
|
||||
'xsl' => 'text/xml',
|
||||
'mpeg' => 'video/mpeg',
|
||||
'mpg' => 'video/mpeg',
|
||||
'mpe' => 'video/mpeg',
|
||||
'qt' => 'video/quicktime',
|
||||
'mov' => 'video/quicktime',
|
||||
'avi' => 'video/x-msvideo',
|
||||
'movie' => 'video/x-sgi-movie',
|
||||
'doc' => 'application/msword',
|
||||
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'word' => array('application/msword', 'application/octet-stream'),
|
||||
'xl' => 'application/excel',
|
||||
'eml' => 'message/rfc822'
|
||||
);
|
||||
|
||||
|
||||
/* End of file mimes.php */
|
||||
/* Location: ./application/config/mimes.php */
|
||||
17
installer/config/profiler.php
Executable file
17
installer/config/profiler.php
Executable file
@@ -0,0 +1,17 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/*
|
||||
| -------------------------------------------------------------------------
|
||||
| Profiler Sections
|
||||
| -------------------------------------------------------------------------
|
||||
| This file lets you determine whether or not various sections of Profiler
|
||||
| data are displayed when the Profiler is enabled.
|
||||
| Please see the user guide for info:
|
||||
|
|
||||
| http://codeigniter.com/user_guide/general/profiling.html
|
||||
|
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* End of file profiler.php */
|
||||
/* Location: ./application/config/profiler.php */
|
||||
43
installer/config/routes.php
Executable file
43
installer/config/routes.php
Executable file
@@ -0,0 +1,43 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/*
|
||||
| -------------------------------------------------------------------------
|
||||
| URI ROUTING
|
||||
| -------------------------------------------------------------------------
|
||||
| This file lets you re-map URI requests to specific controller functions.
|
||||
|
|
||||
| Typically there is a one-to-one relationship between a URL string
|
||||
| and its corresponding controller class/method. The segments in a
|
||||
| URL normally follow this pattern:
|
||||
|
|
||||
| example.com/class/method/id/
|
||||
|
|
||||
| In some instances, however, you may want to remap this relationship
|
||||
| so that a different class/function is called than the one
|
||||
| corresponding to the URL.
|
||||
|
|
||||
| Please see the user guide for complete details:
|
||||
|
|
||||
| http://codeigniter.com/user_guide/general/routing.html
|
||||
|
|
||||
| -------------------------------------------------------------------------
|
||||
| RESERVED ROUTES
|
||||
| -------------------------------------------------------------------------
|
||||
|
|
||||
| There is one reserved routes:
|
||||
|
|
||||
| $route['default_controller'] = 'welcome';
|
||||
|
|
||||
| This route indicates which controller class should be loaded if the
|
||||
| URI contains no data. In the above example, the "welcome" class
|
||||
| would be loaded.
|
||||
*/
|
||||
|
||||
$route['default_controller'] = "wizard";
|
||||
|
||||
$route['wizard(:any)'] = "wizard$1";
|
||||
|
||||
$route['(:any)'] = "wizard/error";
|
||||
|
||||
|
||||
/* End of file routes.php */
|
||||
/* Location: ./application/config/routes.php */
|
||||
66
installer/config/smileys.php
Executable file
66
installer/config/smileys.php
Executable file
@@ -0,0 +1,66 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
| SMILEYS
|
||||
| -------------------------------------------------------------------
|
||||
| This file contains an array of smileys for use with the emoticon helper.
|
||||
| Individual images can be used to replace multiple simileys. For example:
|
||||
| :-) and :) use the same image replacement.
|
||||
|
|
||||
| Please see user guide for more info:
|
||||
| http://codeigniter.com/user_guide/helpers/smiley_helper.html
|
||||
|
|
||||
*/
|
||||
|
||||
$smileys = array(
|
||||
|
||||
// smiley image name width height alt
|
||||
|
||||
':-)' => array('grin.gif', '19', '19', 'grin'),
|
||||
':lol:' => array('lol.gif', '19', '19', 'LOL'),
|
||||
':cheese:' => array('cheese.gif', '19', '19', 'cheese'),
|
||||
':)' => array('smile.gif', '19', '19', 'smile'),
|
||||
';-)' => array('wink.gif', '19', '19', 'wink'),
|
||||
';)' => array('wink.gif', '19', '19', 'wink'),
|
||||
':smirk:' => array('smirk.gif', '19', '19', 'smirk'),
|
||||
':roll:' => array('rolleyes.gif', '19', '19', 'rolleyes'),
|
||||
':-S' => array('confused.gif', '19', '19', 'confused'),
|
||||
':wow:' => array('surprise.gif', '19', '19', 'surprised'),
|
||||
':bug:' => array('bigsurprise.gif', '19', '19', 'big surprise'),
|
||||
':-P' => array('tongue_laugh.gif', '19', '19', 'tongue laugh'),
|
||||
'%-P' => array('tongue_rolleye.gif', '19', '19', 'tongue rolleye'),
|
||||
';-P' => array('tongue_wink.gif', '19', '19', 'tongue wink'),
|
||||
':P' => array('raspberry.gif', '19', '19', 'raspberry'),
|
||||
':blank:' => array('blank.gif', '19', '19', 'blank stare'),
|
||||
':long:' => array('longface.gif', '19', '19', 'long face'),
|
||||
':ohh:' => array('ohh.gif', '19', '19', 'ohh'),
|
||||
':grrr:' => array('grrr.gif', '19', '19', 'grrr'),
|
||||
':gulp:' => array('gulp.gif', '19', '19', 'gulp'),
|
||||
'8-/' => array('ohoh.gif', '19', '19', 'oh oh'),
|
||||
':down:' => array('downer.gif', '19', '19', 'downer'),
|
||||
':red:' => array('embarrassed.gif', '19', '19', 'red face'),
|
||||
':sick:' => array('sick.gif', '19', '19', 'sick'),
|
||||
':shut:' => array('shuteye.gif', '19', '19', 'shut eye'),
|
||||
':-/' => array('hmm.gif', '19', '19', 'hmmm'),
|
||||
'>:(' => array('mad.gif', '19', '19', 'mad'),
|
||||
':mad:' => array('mad.gif', '19', '19', 'mad'),
|
||||
'>:-(' => array('angry.gif', '19', '19', 'angry'),
|
||||
':angry:' => array('angry.gif', '19', '19', 'angry'),
|
||||
':zip:' => array('zip.gif', '19', '19', 'zipper'),
|
||||
':kiss:' => array('kiss.gif', '19', '19', 'kiss'),
|
||||
':ahhh:' => array('shock.gif', '19', '19', 'shock'),
|
||||
':coolsmile:' => array('shade_smile.gif', '19', '19', 'cool smile'),
|
||||
':coolsmirk:' => array('shade_smirk.gif', '19', '19', 'cool smirk'),
|
||||
':coolgrin:' => array('shade_grin.gif', '19', '19', 'cool grin'),
|
||||
':coolhmm:' => array('shade_hmm.gif', '19', '19', 'cool hmm'),
|
||||
':coolmad:' => array('shade_mad.gif', '19', '19', 'cool mad'),
|
||||
':coolcheese:' => array('shade_cheese.gif', '19', '19', 'cool cheese'),
|
||||
':vampire:' => array('vampire.gif', '19', '19', 'vampire'),
|
||||
':snake:' => array('snake.gif', '19', '19', 'snake'),
|
||||
':exclaim:' => array('exclaim.gif', '19', '19', 'excaim'),
|
||||
':question:' => array('question.gif', '19', '19', 'question') // no comma after last item
|
||||
|
||||
);
|
||||
|
||||
/* End of file smileys.php */
|
||||
/* Location: ./application/config/smileys.php */
|
||||
177
installer/config/user_agents.php
Executable file
177
installer/config/user_agents.php
Executable file
@@ -0,0 +1,177 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
| USER AGENT TYPES
|
||||
| -------------------------------------------------------------------
|
||||
| This file contains four arrays of user agent data. It is used by the
|
||||
| User Agent Class to help identify browser, platform, robot, and
|
||||
| mobile device data. The array keys are used to identify the device
|
||||
| and the array values are used to set the actual name of the item.
|
||||
|
|
||||
*/
|
||||
|
||||
$platforms = array (
|
||||
'windows nt 6.0' => 'Windows Longhorn',
|
||||
'windows nt 5.2' => 'Windows 2003',
|
||||
'windows nt 5.0' => 'Windows 2000',
|
||||
'windows nt 5.1' => 'Windows XP',
|
||||
'windows nt 4.0' => 'Windows NT 4.0',
|
||||
'winnt4.0' => 'Windows NT 4.0',
|
||||
'winnt 4.0' => 'Windows NT',
|
||||
'winnt' => 'Windows NT',
|
||||
'windows 98' => 'Windows 98',
|
||||
'win98' => 'Windows 98',
|
||||
'windows 95' => 'Windows 95',
|
||||
'win95' => 'Windows 95',
|
||||
'windows' => 'Unknown Windows OS',
|
||||
'os x' => 'Mac OS X',
|
||||
'ppc mac' => 'Power PC Mac',
|
||||
'freebsd' => 'FreeBSD',
|
||||
'ppc' => 'Macintosh',
|
||||
'linux' => 'Linux',
|
||||
'debian' => 'Debian',
|
||||
'sunos' => 'Sun Solaris',
|
||||
'beos' => 'BeOS',
|
||||
'apachebench' => 'ApacheBench',
|
||||
'aix' => 'AIX',
|
||||
'irix' => 'Irix',
|
||||
'osf' => 'DEC OSF',
|
||||
'hp-ux' => 'HP-UX',
|
||||
'netbsd' => 'NetBSD',
|
||||
'bsdi' => 'BSDi',
|
||||
'openbsd' => 'OpenBSD',
|
||||
'gnu' => 'GNU/Linux',
|
||||
'unix' => 'Unknown Unix OS'
|
||||
);
|
||||
|
||||
|
||||
// The order of this array should NOT be changed. Many browsers return
|
||||
// multiple browser types so we want to identify the sub-type first.
|
||||
$browsers = array(
|
||||
'Flock' => 'Flock',
|
||||
'Chrome' => 'Chrome',
|
||||
'Opera' => 'Opera',
|
||||
'MSIE' => 'Internet Explorer',
|
||||
'Internet Explorer' => 'Internet Explorer',
|
||||
'Shiira' => 'Shiira',
|
||||
'Firefox' => 'Firefox',
|
||||
'Chimera' => 'Chimera',
|
||||
'Phoenix' => 'Phoenix',
|
||||
'Firebird' => 'Firebird',
|
||||
'Camino' => 'Camino',
|
||||
'Netscape' => 'Netscape',
|
||||
'OmniWeb' => 'OmniWeb',
|
||||
'Safari' => 'Safari',
|
||||
'Mozilla' => 'Mozilla',
|
||||
'Konqueror' => 'Konqueror',
|
||||
'icab' => 'iCab',
|
||||
'Lynx' => 'Lynx',
|
||||
'Links' => 'Links',
|
||||
'hotjava' => 'HotJava',
|
||||
'amaya' => 'Amaya',
|
||||
'IBrowse' => 'IBrowse'
|
||||
);
|
||||
|
||||
$mobiles = array(
|
||||
// legacy array, old values commented out
|
||||
'mobileexplorer' => 'Mobile Explorer',
|
||||
// 'openwave' => 'Open Wave',
|
||||
// 'opera mini' => 'Opera Mini',
|
||||
// 'operamini' => 'Opera Mini',
|
||||
// 'elaine' => 'Palm',
|
||||
'palmsource' => 'Palm',
|
||||
// 'digital paths' => 'Palm',
|
||||
// 'avantgo' => 'Avantgo',
|
||||
// 'xiino' => 'Xiino',
|
||||
'palmscape' => 'Palmscape',
|
||||
// 'nokia' => 'Nokia',
|
||||
// 'ericsson' => 'Ericsson',
|
||||
// 'blackberry' => 'BlackBerry',
|
||||
// 'motorola' => 'Motorola'
|
||||
|
||||
// Phones and Manufacturers
|
||||
'motorola' => "Motorola",
|
||||
'nokia' => "Nokia",
|
||||
'palm' => "Palm",
|
||||
'iphone' => "Apple iPhone",
|
||||
'ipod' => "Apple iPod Touch",
|
||||
'sony' => "Sony Ericsson",
|
||||
'ericsson' => "Sony Ericsson",
|
||||
'blackberry' => "BlackBerry",
|
||||
'cocoon' => "O2 Cocoon",
|
||||
'blazer' => "Treo",
|
||||
'lg' => "LG",
|
||||
'amoi' => "Amoi",
|
||||
'xda' => "XDA",
|
||||
'mda' => "MDA",
|
||||
'vario' => "Vario",
|
||||
'htc' => "HTC",
|
||||
'samsung' => "Samsung",
|
||||
'sharp' => "Sharp",
|
||||
'sie-' => "Siemens",
|
||||
'alcatel' => "Alcatel",
|
||||
'benq' => "BenQ",
|
||||
'ipaq' => "HP iPaq",
|
||||
'mot-' => "Motorola",
|
||||
'playstation portable' => "PlayStation Portable",
|
||||
'hiptop' => "Danger Hiptop",
|
||||
'nec-' => "NEC",
|
||||
'panasonic' => "Panasonic",
|
||||
'philips' => "Philips",
|
||||
'sagem' => "Sagem",
|
||||
'sanyo' => "Sanyo",
|
||||
'spv' => "SPV",
|
||||
'zte' => "ZTE",
|
||||
'sendo' => "Sendo",
|
||||
|
||||
// Operating Systems
|
||||
'symbian' => "Symbian",
|
||||
'SymbianOS' => "SymbianOS",
|
||||
'elaine' => "Palm",
|
||||
'palm' => "Palm",
|
||||
'series60' => "Symbian S60",
|
||||
'windows ce' => "Windows CE",
|
||||
|
||||
// Browsers
|
||||
'obigo' => "Obigo",
|
||||
'netfront' => "Netfront Browser",
|
||||
'openwave' => "Openwave Browser",
|
||||
'mobilexplorer' => "Mobile Explorer",
|
||||
'operamini' => "Opera Mini",
|
||||
'opera mini' => "Opera Mini",
|
||||
|
||||
// Other
|
||||
'digital paths' => "Digital Paths",
|
||||
'avantgo' => "AvantGo",
|
||||
'xiino' => "Xiino",
|
||||
'novarra' => "Novarra Transcoder",
|
||||
'vodafone' => "Vodafone",
|
||||
'docomo' => "NTT DoCoMo",
|
||||
'o2' => "O2",
|
||||
|
||||
// Fallback
|
||||
'mobile' => "Generic Mobile",
|
||||
'wireless' => "Generic Mobile",
|
||||
'j2me' => "Generic Mobile",
|
||||
'midp' => "Generic Mobile",
|
||||
'cldc' => "Generic Mobile",
|
||||
'up.link' => "Generic Mobile",
|
||||
'up.browser' => "Generic Mobile",
|
||||
'smartphone' => "Generic Mobile",
|
||||
'cellphone' => "Generic Mobile"
|
||||
);
|
||||
|
||||
// There are hundreds of bots but these are the most common.
|
||||
$robots = array(
|
||||
'googlebot' => 'Googlebot',
|
||||
'msnbot' => 'MSNBot',
|
||||
'slurp' => 'Inktomi Slurp',
|
||||
'yahoo' => 'Yahoo',
|
||||
'askjeeves' => 'AskJeeves',
|
||||
'fastcrawler' => 'FastCrawler',
|
||||
'infoseek' => 'InfoSeek Robot 1.0',
|
||||
'lycos' => 'Lycos'
|
||||
);
|
||||
|
||||
/* End of file user_agents.php */
|
||||
/* Location: ./application/config/user_agents.php */
|
||||
10
installer/controllers/index.html
Executable file
10
installer/controllers/index.html
Executable file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
332
installer/controllers/wizard.php
Executable file
332
installer/controllers/wizard.php
Executable file
@@ -0,0 +1,332 @@
|
||||
<?php
|
||||
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
/**
|
||||
* Pancake
|
||||
* A simple, fast, self-hosted invoicing application
|
||||
*
|
||||
* @package Pancake
|
||||
* @author Pancake Dev Team
|
||||
* @copyright Copyright (c) 2014, Pancake Payments
|
||||
* @license http://pancakeapp.com/license
|
||||
* @link http://pancakeapp.com
|
||||
* @since Version 1.0
|
||||
*/
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The install wizard controller
|
||||
*
|
||||
* @subpackage Controllers
|
||||
* @category Wizard
|
||||
* @property Installer $installer
|
||||
*/
|
||||
class Wizard extends CI_Controller {
|
||||
|
||||
/**
|
||||
* @var string The path to the config folder
|
||||
*/
|
||||
private $config_path;
|
||||
|
||||
/**
|
||||
* @var string The path to the config.php file
|
||||
*/
|
||||
private $config_file;
|
||||
|
||||
/**
|
||||
* @var string The path to the stripe.php config file
|
||||
*/
|
||||
private $stripe_config_file;
|
||||
|
||||
/**
|
||||
* @var string The path to the uploads folder
|
||||
*/
|
||||
private $upload_path;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
|
||||
# Disable all caching for Varnish.
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
||||
header("Cache-Control: private");
|
||||
header("Pragma: no-cache");
|
||||
|
||||
$this->config_path = FCPATH . 'system/pancake/config';
|
||||
$this->config_file = $this->config_path . "/config.php";
|
||||
$this->stripe_config_file = $this->config_path . "/stripe.php";
|
||||
$this->upload_path = FCPATH . 'uploads/';
|
||||
require_once FCPATH . 'system/pancake/helpers/pancake_helper.php';
|
||||
include_once FCPATH . 'system/pancake/libraries/Asset.php';
|
||||
Asset::add_path(APPPATH . 'assets/');
|
||||
Asset::set_asset_url(BASE_URL);
|
||||
}
|
||||
|
||||
public function _detect_url_rewriting() {
|
||||
include_once APPPATH . 'libraries/HTTP_Request.php';
|
||||
$http = new HTTP_Request();
|
||||
try {
|
||||
$url_without_index_php = BASE_URL . "admin";
|
||||
$contents = $http->request($url_without_index_php);
|
||||
if (stristr($contents, "run the installer") === false) {
|
||||
$contents = $http->request(BASE_URL . "index.php/admin");
|
||||
if (stristr($contents, "run the installer") === false) {
|
||||
$contents = $http->request(BASE_URL . "index.php?/admin");
|
||||
if (stristr($contents, "run the installer") === false) {
|
||||
# Could not detect any valid way to access Pancake, so assume it works if there's a .htaccess and it's Apache, otherwise default to "index.php".
|
||||
|
||||
$htaccess_servers = array(
|
||||
"Apache",
|
||||
"LiteSpeed",
|
||||
"WebServerX",
|
||||
"1984",
|
||||
);
|
||||
|
||||
$use_index_php = "index.php";
|
||||
foreach ($htaccess_servers as $server) {
|
||||
if (strpos($_SERVER["SERVER_SOFTWARE"], $server) !== false) {
|
||||
$use_index_php = is_file(FCPATH . '.htaccess') ? '' : 'index.php';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
# Found "run the installer", works with index.php?.
|
||||
$use_index_php = "index.php?";
|
||||
}
|
||||
|
||||
} else {
|
||||
# Found "run the installer", works with index.php.
|
||||
$use_index_php = "index.php";
|
||||
}
|
||||
} else {
|
||||
# Found "run the installer", works without index.php.
|
||||
$use_index_php = "";
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
# Could not detect URL Rewriting correctly; defaulting to "index.php?".
|
||||
$use_index_php = "index.php?";
|
||||
}
|
||||
|
||||
if ($use_index_php !== $this->config->item("index_page")) {
|
||||
if (is_really_writable($this->config_file)) {
|
||||
file_put_contents($this->config_file, str_replace("\$config['index_page'] = \$config['index_page'];", "\$config['index_page'] = '$use_index_php'; #CORRECTED", file_get_contents($this->config_file)));
|
||||
if (strstr(file_get_contents($this->config_file), "#CORRECTED") !== false) {
|
||||
# Everything is OK; the file was corrected.
|
||||
return true;
|
||||
} else {
|
||||
# Something went wrong while updating the file.
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
# The file can't be corrected.
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
# Everything is OK; detection was correct.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function _detect_tls12() {
|
||||
\Stripe\Stripe::setApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
|
||||
\Stripe\Stripe::$apiBase = "https://api-tls12.stripe.com";
|
||||
$curl = new \Stripe\HttpClient\CurlClient([CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1_2]);
|
||||
\Stripe\ApiRequestor::setHttpClient($curl);
|
||||
|
||||
try {
|
||||
\Stripe\Charge::all();
|
||||
return true;
|
||||
} catch (\Stripe\Error\ApiConnection $e) {
|
||||
# Try without the CURLOPT.
|
||||
$curl = new \Stripe\HttpClient\CurlClient();
|
||||
\Stripe\ApiRequestor::setHttpClient($curl);
|
||||
try {
|
||||
\Stripe\Charge::all();
|
||||
|
||||
# Fix stripe.php config file.
|
||||
if (is_really_writable($this->stripe_config_file)) {
|
||||
file_put_contents($this->stripe_config_file, str_replace("[CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1_2]", "[]", file_get_contents($this->stripe_config_file)));
|
||||
if (strstr(file_get_contents($this->stripe_config_file), "\$config['stripe_curlopts'] = [];") !== false) {
|
||||
# Everything is OK; the file was corrected.
|
||||
return true;
|
||||
} else {
|
||||
# Something went wrong while updating the file.
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
# The file can't be corrected.
|
||||
return false;
|
||||
}
|
||||
} catch (\Stripe\Error\ApiConnection $e) {
|
||||
# Cannot work with or without the CURLOPT trickery.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function index() {
|
||||
if ($_POST) {
|
||||
$this->load->library('form_validation');
|
||||
$data = [];
|
||||
|
||||
$this->form_validation->set_rules('db_host', 'Database Host', 'required');
|
||||
$this->form_validation->set_rules('db_user', 'Database Username', 'required');
|
||||
$this->form_validation->set_rules('db_pass', 'Database Password', 'required');
|
||||
$this->form_validation->set_rules('db_name', 'Database Name', 'required');
|
||||
$this->form_validation->set_rules('db_port', 'Database Port', 'required');
|
||||
$this->form_validation->set_rules('username', 'Username', 'required|xss_clean');
|
||||
$this->form_validation->set_rules('password', 'Password', 'required|min_length[5]|matches[password_confirm]');
|
||||
$this->form_validation->set_rules('password_confirm', 'Password Confirmation', 'required');
|
||||
|
||||
if ($this->form_validation->run()) {
|
||||
$data['hostname'] = $this->input->post('db_host');
|
||||
$data['database'] = $this->input->post('db_name');
|
||||
$data['dbprefix'] = 'pancake_';
|
||||
$data['username'] = $this->input->post('db_user');
|
||||
$data['password'] = $this->input->post('db_pass');
|
||||
$data['port'] = $this->input->post('db_port');
|
||||
$data['port'] = (!$data['port']) ? '3306' : $data['port'];
|
||||
$db = $this->_check_db($data["hostname"], $data["username"], $data["password"], $data["database"], $data["port"]);
|
||||
|
||||
if ($db["success"]) {
|
||||
if ($db["is_installed"]) {
|
||||
$this->_output_step("steps/stop");
|
||||
return;
|
||||
} else {
|
||||
$this->load->library('installer');
|
||||
if ($this->installer->install($data, $this->input->post("username"), $this->input->post("password"))) {
|
||||
# Redirect to Pancake, showing successful install modal.
|
||||
redirect("admin");
|
||||
} else {
|
||||
$data['error'] = "The installer could not store the database configurations. Make sure that system/pancake/config is writable.";
|
||||
$this->_output_step('steps/single_step', $data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$data['error'] = 'Database Error: ' . $db["error"];
|
||||
$this->_output_step('steps/single_step', $data);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
$this->_output_step('steps/single_step', $data);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
$this->config->load("license");
|
||||
$checks = $this->_run_checks();
|
||||
if ($checks['can_continue']) {
|
||||
$this->_output_step('steps/single_step');
|
||||
} else {
|
||||
$this->_output_step('steps/checks', $checks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function error() {
|
||||
$this->_output_step('error');
|
||||
}
|
||||
|
||||
protected function _run_checks() {
|
||||
$data = array();
|
||||
$data['is_url_rewriting_working'] = $this->_detect_url_rewriting();
|
||||
$data['config_writable'] = is_really_writable($this->config_path) ? true : false;
|
||||
$data['upload_writable'] = is_really_writable($this->upload_path) ? true : false;
|
||||
$data['license_valid'] = $this->_check_license($this->config->item("license_key"));
|
||||
$data['curl_installed'] = function_exists('curl_init');
|
||||
$data['tls12'] = $this->_detect_tls12();
|
||||
|
||||
$data['installed'] = array(
|
||||
'gd' => (extension_loaded('gd') && function_exists('gd_info')),
|
||||
'json' => (extension_loaded('json') && function_exists('json_encode')),
|
||||
'dom' => (extension_loaded('dom')),
|
||||
'xml' => (extension_loaded('xml')),
|
||||
'mysql' => (extension_loaded('mysqli') || extension_loaded('mysql')),
|
||||
);
|
||||
|
||||
include_once APPPATH . 'libraries/HTTP_Request.php';
|
||||
$http = new HTTP_Request();
|
||||
try {
|
||||
$http->request(MANAGE_PANCAKE_BASE_URL);
|
||||
$data['manage_pancakeapp'] = true;
|
||||
} catch (Exception $e) {
|
||||
$data['manage_pancakeapp'] = false;
|
||||
}
|
||||
|
||||
$can_continue = true;
|
||||
foreach ($data as $value) {
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $subvalue) {
|
||||
if (!$subvalue) {
|
||||
$can_continue = false;
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!$value) {
|
||||
$can_continue = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$data['can_continue'] = $can_continue;
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function _check_db($host, $user, $pass, $name, $port, $prefix = "pancake_") {
|
||||
$is_installed = false;
|
||||
|
||||
if (function_exists("mysqli_connect")) {
|
||||
$mysqli = @new mysqli($host, $user, $pass, $name, $port);
|
||||
$success = !$mysqli->connect_error;
|
||||
$error = $mysqli->connect_error;
|
||||
if ($success) {
|
||||
$is_installed = $mysqli->query("show tables like '" . $mysqli->real_escape_string($prefix) . "%'")->num_rows > 0;
|
||||
}
|
||||
} else {
|
||||
$link = @mysql_connect($host . ':' . $port, $user, $pass, true);
|
||||
|
||||
if ($link) {
|
||||
// If the database is not there create it
|
||||
mysql_query('CREATE DATABASE IF NOT EXISTS ' . $name, $link);
|
||||
}
|
||||
|
||||
$success = ($link && @ mysql_select_db($name, $link));
|
||||
$error = mysql_error();
|
||||
|
||||
if ($success) {
|
||||
$result = mysql_query("show tables like '" . mysql_real_escape_string($prefix, $link) . "%'", $link);
|
||||
$is_installed = mysql_num_rows($result) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
"success" => $success,
|
||||
"error" => $error,
|
||||
"is_installed" => $is_installed,
|
||||
];
|
||||
}
|
||||
|
||||
private function _check_license($key) {
|
||||
$key = trim($key);
|
||||
|
||||
$result = get_url_contents(MANAGE_PANCAKE_BASE_URL . 'verify/key/' . $key, false);
|
||||
if (empty($result)) {
|
||||
show_error('Pancake could not verify if the key "' . $key . '" is valid.');
|
||||
}
|
||||
|
||||
return ($result === 'valid');
|
||||
}
|
||||
|
||||
private function _output_step($view, $data = array()) {
|
||||
$content = $this->load->view($view, $data, true);
|
||||
|
||||
$this->load->view('template', array('content' => $content));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* End of file wizard.php */
|
||||
1
installer/core/Pancake_Exceptions.php
Executable file
1
installer/core/Pancake_Exceptions.php
Executable file
@@ -0,0 +1 @@
|
||||
<?php include FCPATH.'system/pancake/core/Pancake_Exceptions.php';
|
||||
1
installer/core/Pancake_URI.php
Executable file
1
installer/core/Pancake_URI.php
Executable file
@@ -0,0 +1 @@
|
||||
<?php include FCPATH.'system/pancake/core/Pancake_URI.php';
|
||||
10
installer/core/index.html
Executable file
10
installer/core/index.html
Executable file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
34
installer/errors/error_404.php
Executable file
34
installer/errors/error_404.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>404 Page Not Found</title>
|
||||
<style type="text/css">
|
||||
|
||||
body {
|
||||
background-color: #fff;
|
||||
margin: 40px;
|
||||
font-family: Lucida Grande, Verdana, Sans-serif;
|
||||
font-size: 12px;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
#content {
|
||||
border: #999 1px solid;
|
||||
background-color: #fff;
|
||||
padding: 20px 20px 12px 20px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-weight: normal;
|
||||
font-size: 14px;
|
||||
color: #990000;
|
||||
margin: 0 0 4px 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="content">
|
||||
<h1><?php echo $heading; ?></h1>
|
||||
<?php echo $message; ?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
34
installer/errors/error_db.php
Executable file
34
installer/errors/error_db.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Database Error</title>
|
||||
<style type="text/css">
|
||||
|
||||
body {
|
||||
background-color: #fff;
|
||||
margin: 40px;
|
||||
font-family: Lucida Grande, Verdana, Sans-serif;
|
||||
font-size: 12px;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
#content {
|
||||
border: #999 1px solid;
|
||||
background-color: #fff;
|
||||
padding: 20px 20px 12px 20px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-weight: normal;
|
||||
font-size: 14px;
|
||||
color: #990000;
|
||||
margin: 0 0 4px 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="content">
|
||||
<h1><?php echo $heading; ?></h1>
|
||||
<?php echo $message; ?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
34
installer/errors/error_general.php
Executable file
34
installer/errors/error_general.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Error</title>
|
||||
<style type="text/css">
|
||||
|
||||
body {
|
||||
background-color: #fff;
|
||||
margin: 40px;
|
||||
font-family: Lucida Grande, Verdana, Sans-serif;
|
||||
font-size: 12px;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
#content {
|
||||
border: #999 1px solid;
|
||||
background-color: #fff;
|
||||
padding: 20px 20px 12px 20px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-weight: normal;
|
||||
font-size: 14px;
|
||||
color: #990000;
|
||||
margin: 0 0 4px 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="content">
|
||||
<h1><?php echo $heading; ?></h1>
|
||||
<?php echo $message; ?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
10
installer/errors/error_php.php
Executable file
10
installer/errors/error_php.php
Executable file
@@ -0,0 +1,10 @@
|
||||
<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
|
||||
|
||||
<h4>A PHP Error was encountered</h4>
|
||||
|
||||
<p>Severity: <?php echo $severity; ?></p>
|
||||
<p>Message: <?php echo $message; ?></p>
|
||||
<p>Filename: <?php echo $filepath; ?></p>
|
||||
<p>Line Number: <?php echo $line; ?></p>
|
||||
|
||||
</div>
|
||||
1
installer/errors/error_php_custom.php
Executable file
1
installer/errors/error_php_custom.php
Executable file
@@ -0,0 +1 @@
|
||||
<?php include FCPATH.'system/pancake/errors/error_php_custom.php';
|
||||
1
installer/errors/error_php_enduser.php
Executable file
1
installer/errors/error_php_enduser.php
Executable file
@@ -0,0 +1 @@
|
||||
<?php include FCPATH.'system/pancake/errors/error_php_custom.php';
|
||||
10
installer/errors/index.html
Executable file
10
installer/errors/index.html
Executable file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
19
installer/helpers/MY_form_helper.php
Executable file
19
installer/helpers/MY_form_helper.php
Executable file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Set Value
|
||||
*
|
||||
* We have removed the part using form validation.
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return mixed
|
||||
*/
|
||||
function set_value($field = '', $default = '')
|
||||
{
|
||||
if ( ! isset($_POST[$field]))
|
||||
{
|
||||
return $default;
|
||||
}
|
||||
return form_prep($_POST[$field], $field);
|
||||
}
|
||||
10
installer/helpers/index.html
Executable file
10
installer/helpers/index.html
Executable file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
10
installer/hooks/index.html
Executable file
10
installer/hooks/index.html
Executable file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
10
installer/index.html
Executable file
10
installer/index.html
Executable file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
10
installer/language/english/index.html
Executable file
10
installer/language/english/index.html
Executable file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
1
installer/libraries/HTTP_Request.php
Executable file
1
installer/libraries/HTTP_Request.php
Executable file
@@ -0,0 +1 @@
|
||||
<?php include FCPATH.'system/pancake/libraries/HTTP_Request.php';
|
||||
10
installer/libraries/index.html
Executable file
10
installer/libraries/index.html
Executable file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
239
installer/libraries/installer.php
Executable file
239
installer/libraries/installer.php
Executable file
@@ -0,0 +1,239 @@
|
||||
<?php defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
/**
|
||||
* Pancake
|
||||
* A simple, fast, self-hosted invoicing application
|
||||
*
|
||||
* @package Pancake
|
||||
* @author Pancake Dev Team
|
||||
* @copyright Copyright (c) 2010, Pancake Payments
|
||||
* @license http://pancakeapp.com/license
|
||||
* @link http://pancakeapp.com
|
||||
* @since Version 1.0
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Installer Library
|
||||
*
|
||||
* @subpackage Libraries
|
||||
* @category Installer
|
||||
*/
|
||||
class Installer {
|
||||
|
||||
/**
|
||||
* @var object The global CI object
|
||||
*/
|
||||
private $_ci;
|
||||
|
||||
public $dbdriver = 'mysqli';
|
||||
|
||||
/**
|
||||
* Loads in the CI super object
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->_ci = &get_instance();
|
||||
|
||||
if (!function_exists('mysqli_connect')) {
|
||||
$this->dbdriver = 'mysql';
|
||||
}
|
||||
}
|
||||
|
||||
public function install($config, $username, $password) {
|
||||
$config['dbdriver'] = $this->dbdriver;
|
||||
$config['db_debug'] = true;
|
||||
$config['char_set'] = "utf8";
|
||||
$config['dbcollat'] = "utf8_general_ci";
|
||||
$config['autoinit'] = true;
|
||||
|
||||
$this->_ci->load->database($config);
|
||||
$this->_ci->load->dbforge();
|
||||
$has_utf8mb4 = (version_compare($this->_ci->db->version(), "5.5") == 1);
|
||||
|
||||
if ($has_utf8mb4) {
|
||||
$config['char_set'] = "utf8mb4";
|
||||
$config['dbcollat'] = "utf8mb4_general_ci";
|
||||
}
|
||||
|
||||
$schema = file_get_contents(APPPATH . 'schema/pancake.sql');
|
||||
|
||||
if (!$this->_write_db_config($config, $has_utf8mb4)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$data["username"] = $username;
|
||||
$data["password"] = $password;
|
||||
|
||||
$data['salt'] = substr(md5(uniqid(rand(), true)), 0, 10);
|
||||
$data['password'] = sha1($data['password'] . $data['salt']);
|
||||
|
||||
$data['dbprefix'] = $config['dbprefix'];
|
||||
$data['version'] = file_get_contents(FCPATH . 'system/pancake/VERSION');
|
||||
$data['rss_password'] = random_string('alnum', 12);
|
||||
$data['timezone'] = @date_default_timezone_get();
|
||||
|
||||
// Include migration config to know which migration to start from
|
||||
include './system/pancake/config/migration.php';
|
||||
|
||||
$data['migration'] = $config['migration_version'];
|
||||
$data['now'] = time();
|
||||
$data['now_datetime'] = date("Y-m-d H:i:s");
|
||||
|
||||
$this->_ci->config->load("license");
|
||||
|
||||
$data["site_name"] = "Pancake";
|
||||
$data["first_name"] = $this->_ci->config->item("first_name");
|
||||
$data["notify_email"] = $this->_ci->config->item("email");
|
||||
$data["last_name"] = $this->_ci->config->item("last_name");
|
||||
$data["license_key"] = $this->_ci->config->item("license_key");
|
||||
$data["currency"] = "USD";
|
||||
$data["tax_rate"] = "0";
|
||||
$data["theme"] = "flat-pancake";
|
||||
$data["mailing_address"] = "";
|
||||
|
||||
foreach ($data as $key => $val) {
|
||||
|
||||
if (strtoupper($key) == "TAX_RATE") {
|
||||
// Fixes an issue with MySQL in Strict Mode if the tax was empty.
|
||||
$val = (float) $val;
|
||||
}
|
||||
|
||||
$escaped_val = $this->_ci->db->escape_str($val);
|
||||
$schema = str_replace('{' . strtoupper($key) . '}', $escaped_val, $schema);
|
||||
}
|
||||
|
||||
$schema = explode('-- split --', $schema);
|
||||
|
||||
foreach ($schema as $query) {
|
||||
if (stristr($query, "charset = utf8") !== false && $has_utf8mb4) {
|
||||
$query = str_ireplace("charset = utf8", "charset = utf8mb4", $query);
|
||||
}
|
||||
|
||||
if (!$this->_ci->db->query(rtrim(trim($query), "\n;"))) {
|
||||
|
||||
switch ($this->dbdriver) {
|
||||
case 'mysql':
|
||||
$error = mysql_error();
|
||||
break;
|
||||
case 'mysqli':
|
||||
$error = mysqli_error($this->_ci->db->conn_id);
|
||||
break;
|
||||
}
|
||||
|
||||
show_error(strtoupper($this->dbdriver) . ' ERROR: ' . $error);
|
||||
}
|
||||
}
|
||||
|
||||
$this->_ci->load->helper("cookie");
|
||||
|
||||
set_cookie(array(
|
||||
'name' => 'identity',
|
||||
'value' => $username,
|
||||
'expire' => 60 * 60 * 24 * 365 * 2,
|
||||
));
|
||||
|
||||
$salt = sha1($password);
|
||||
$this->_ci->db->update("users", ['remember_code' => $salt]);
|
||||
|
||||
set_cookie(array(
|
||||
'name' => 'remember_code',
|
||||
'value' => $salt,
|
||||
'expire' => 60 * 60 * 24 * 365 * 2,
|
||||
));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function _write_db_config($config, $has_utf8mb4) {
|
||||
$replace = array(
|
||||
'{HOSTNAME}' => $config['hostname'],
|
||||
'{USERNAME}' => $config['username'],
|
||||
'{PASSWORD}' => $config['password'],
|
||||
'{DATABASE}' => $config['database'],
|
||||
'{PORT}' => $config['port'],
|
||||
'{DBPREFIX}' => $config['dbprefix'],
|
||||
);
|
||||
|
||||
$charset = $has_utf8mb4 ? "utf8mb4" : "utf8";
|
||||
|
||||
$template = <<<TEMP
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
| DATABASE CONNECTIVITY SETTINGS
|
||||
| -------------------------------------------------------------------
|
||||
| This file will contain the settings needed to access your database.
|
||||
|
|
||||
| For complete instructions please consult the 'Database Connection'
|
||||
| page of the User Guide.
|
||||
|
|
||||
| -------------------------------------------------------------------
|
||||
| EXPLANATION OF VARIABLES
|
||||
| -------------------------------------------------------------------
|
||||
|
|
||||
| ['hostname'] The hostname of your database server.
|
||||
| ['username'] The username used to connect to the database
|
||||
| ['password'] The password used to connect to the database
|
||||
| ['database'] The name of the database you want to connect to
|
||||
| ['dbdriver'] The database type. ie: mysql. Currently supported:
|
||||
mysql, mysqli, postgre, odbc, mssql, sqlite, oci8
|
||||
| ['dbprefix'] You can add an optional prefix, which will be added
|
||||
| to the table name when using the Active Record class
|
||||
| ['pconnect'] TRUE/FALSE - Whether to use a persistent connection
|
||||
| ['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
|
||||
| ['cache_on'] TRUE/FALSE - Enables/disables query caching
|
||||
| ['cachedir'] The path to the folder where cache files should be stored
|
||||
| ['char_set'] The character set used in communicating with the database
|
||||
| ['dbcollat'] The character collation used in communicating with the database
|
||||
| ['swap_pre'] A default table prefix that should be swapped with the dbprefix
|
||||
| ['autoinit'] Whether or not to automatically initialize the database.
|
||||
| ['stricton'] TRUE/FALSE - forces 'Strict Mode' connections
|
||||
| - good for ensuring strict SQL while developing
|
||||
|
|
||||
| The \$active_group variable lets you choose which connection group to
|
||||
| make active. By default there is only one group (the 'default' group).
|
||||
|
|
||||
| The \$active_record variables lets you determine whether or not to load
|
||||
| the active record class
|
||||
*/
|
||||
|
||||
\$active_group = 'default';
|
||||
\$active_record = TRUE;
|
||||
|
||||
\$db['default']['hostname'] = '{HOSTNAME}';
|
||||
\$db['default']['username'] = '{USERNAME}';
|
||||
\$db['default']['password'] = '{PASSWORD}';
|
||||
\$db['default']['database'] = '{DATABASE}';
|
||||
\$db['default']['dbdriver'] = '{$this->dbdriver}';
|
||||
\$db['default']['dbprefix'] = '{DBPREFIX}';
|
||||
\$db['default']['pconnect'] = FALSE;
|
||||
\$db['default']['db_debug'] = TRUE;
|
||||
\$db['default']['cache_on'] = FALSE;
|
||||
\$db['default']['cachedir'] = '';
|
||||
\$db['default']['char_set'] = '$charset';
|
||||
\$db['default']['dbcollat'] = '{$charset}_general_ci';
|
||||
\$db['default']['swap_pre'] = '';
|
||||
\$db['default']['autoinit'] = TRUE;
|
||||
\$db['default']['stricton'] = TRUE;
|
||||
\$db['default']['port'] = {PORT};
|
||||
|
||||
/* End of file database.php */
|
||||
/* Location: ./application/config/database.php */
|
||||
TEMP;
|
||||
|
||||
$new_file = str_replace(array_keys($replace), $replace, $template);
|
||||
|
||||
$handle = @fopen(FCPATH . 'system/pancake/config/database.php', 'w+');
|
||||
|
||||
if ($handle !== false) {
|
||||
return @fwrite($handle, $new_file);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* End of file installer.php */
|
||||
10
installer/models/index.html
Executable file
10
installer/models/index.html
Executable file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
1362
installer/schema/pancake.sql
Executable file
1362
installer/schema/pancake.sql
Executable file
File diff suppressed because it is too large
Load Diff
14
installer/views/error.php
Executable file
14
installer/views/error.php
Executable file
@@ -0,0 +1,14 @@
|
||||
<h2>Error</h2>
|
||||
|
||||
<p>
|
||||
It looks like Pancake has not been installed. <strong>To run the installer, <?php echo anchor('', 'click here'); ?></strong>.
|
||||
</p>
|
||||
<p>Pancake thinks that the URL to your Pancake is:<br /><strong><?php echo BASE_URL;?></strong></p><p>Pancake thinks that you were trying to load the following page:<br /><strong><?php echo $this->uri->uri_string();?></strong></p>
|
||||
<p>If you haven't installed, and the above information is incorrect, that means that Pancake is having problems making sense of your server's configurations. <a href="<?php echo PANCAKEAPP_COM_BASE_URL; ?>account/support/ticket/new">Start a <strong>free</strong> support ticket</a>, and we'll help you sort it out.</p>
|
||||
|
||||
<p class="fail">
|
||||
If you have any difficulty installing Pancake, don't forget:<br/>
|
||||
<strong>We can install Pancake for you, for free.</strong><br/>Just
|
||||
<a href="<?php echo PANCAKEAPP_COM_BASE_URL; ?>account/support/ticket/new">start a
|
||||
<strong>free</strong> support ticket</a>.
|
||||
</p>
|
||||
10
installer/views/index.html
Executable file
10
installer/views/index.html
Executable file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
96
installer/views/steps/checks.php
Executable file
96
installer/views/steps/checks.php
Executable file
@@ -0,0 +1,96 @@
|
||||
<h2>Your server is missing a couple of things.</h2>
|
||||
<p class="fail">
|
||||
If you have any difficulty installing Pancake, don't forget:<br/>
|
||||
<strong>We can install Pancake for you, for free.</strong><br/>Just
|
||||
<a href="<?php echo PANCAKEAPP_COM_BASE_URL; ?>account/support/ticket/new">start a
|
||||
<strong>free</strong> support ticket</a>.
|
||||
</p>
|
||||
<p>Please fix the below errors and refresh to re-check.</p>
|
||||
|
||||
<table cellspacing="0" class="listtable checks-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="10%">Status</th>
|
||||
<th>Requirement</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="<?php echo $is_url_rewriting_working ? 'pass' : 'fail'; ?>"><?php echo $is_url_rewriting_working ? 'PASS' : 'FAIL'; ?></span>
|
||||
</td>
|
||||
<td>Pancake must be able to reliably detect whether URL rewriting is on or off.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="<?php echo $manage_pancakeapp ? 'pass' : 'fail'; ?>"><?php echo $manage_pancakeapp ? 'PASS' : 'FAIL'; ?></span>
|
||||
</td>
|
||||
<td>Your server must be able to communicate with pancakeapp.com (otherwise you won't be able to receive updates).</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="<?php echo $license_valid ? 'pass' : 'fail'; ?>"><?php echo $license_valid ? 'PASS' : 'FAIL'; ?></span>
|
||||
</td>
|
||||
<td>
|
||||
<?php if ($license_valid): ?>
|
||||
Your license key is valid.
|
||||
<?php else: ?>
|
||||
Your license key is not valid.
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="<?php echo $curl_installed ? 'pass' : 'fail'; ?>"><?php echo $curl_installed ? 'PASS' : 'FAIL'; ?></span>
|
||||
</td>
|
||||
<td>The Curl PHP extension must be installed.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="<?php echo $installed['gd'] ? 'pass' : 'fail'; ?>"><?php echo $installed['gd'] ? 'PASS' : 'FAIL'; ?></span>
|
||||
</td>
|
||||
<td>The GD PHP extension must be installed.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="<?php echo $installed['json'] ? 'pass' : 'fail'; ?>"><?php echo $installed['json'] ? 'PASS' : 'FAIL'; ?></span>
|
||||
</td>
|
||||
<td>The JSON PHP extension must be installed.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="<?php echo $installed['dom'] ? 'pass' : 'fail'; ?>"><?php echo $installed['dom'] ? 'PASS' : 'FAIL'; ?></span>
|
||||
</td>
|
||||
<td>The DOM PHP extension must be installed.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="<?php echo $installed['mysql'] ? 'pass' : 'fail'; ?>"><?php echo $installed['mysql'] ? 'PASS' : 'FAIL'; ?></span>
|
||||
</td>
|
||||
<td>The MySQL (or MySQLi) PHP extension must be installed.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="<?php echo $installed['xml'] ? 'pass' : 'fail'; ?>"><?php echo $installed['xml'] ? 'PASS' : 'FAIL'; ?></span>
|
||||
</td>
|
||||
<td>The XML PHP extension must be installed.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="<?php echo $tls12 ? 'pass' : 'fail'; ?>"><?php echo $tls12 ? 'PASS' : 'FAIL'; ?></span>
|
||||
</td>
|
||||
<td>Your server must be able to make TLS 1.2 connections to other servers.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="<?php echo $config_writable ? 'pass' : 'fail'; ?>"><?php echo $config_writable ? 'PASS' : 'FAIL</span>'; ?></span>
|
||||
</td>
|
||||
<td>The system/pancake/config folder must be writable.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="<?php echo $upload_writable ? 'pass' : 'fail'; ?>"><?php echo $upload_writable ? 'PASS' : 'FAIL'; ?></span>
|
||||
</td>
|
||||
<td>The uploads directory must be writable.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
8
installer/views/steps/complete.php
Executable file
8
installer/views/steps/complete.php
Executable file
@@ -0,0 +1,8 @@
|
||||
<h2 class="installed">Congratulations!</h2>
|
||||
<p>Pancake has been successfully installed on your server!</p>
|
||||
|
||||
<p>If you have a couple seconds would you mind telling your friends about us? A quick <a href="http://twitter.com/home?status=I%20just%20installed%20@pancakeapp%20and%20it%20looks%20awesome!%20http://pancakeapp.com">tweet</a> or mention on <a href="http://facebook.com">Facebook</a> is awesome!</p>
|
||||
|
||||
<h4>You rule! Now go collect stacks!</h4>
|
||||
|
||||
<p class="center"><a href="<?php echo site_url('admin/users/login'); ?>" class="button">Login!</a></p>
|
||||
89
installer/views/steps/single_step.php
Executable file
89
installer/views/steps/single_step.php
Executable file
@@ -0,0 +1,89 @@
|
||||
<h2>Let's make some Pancakes!</h2>
|
||||
<?php
|
||||
$errors = validation_errors(' ', '<br />');
|
||||
$has_errors = ($errors || isset($error));
|
||||
?>
|
||||
<p class="<?php echo $has_errors ? "fail" : ""; ?>">
|
||||
If you have any difficulty installing Pancake, don't forget:<br/>
|
||||
<strong>We can install Pancake for you, for free.</strong><br/>Just
|
||||
<a href="<?php echo PANCAKEAPP_COM_BASE_URL; ?>account/support/ticket/new">start a
|
||||
<strong>free</strong> support ticket</a>.
|
||||
</p>
|
||||
<hr>
|
||||
|
||||
<?php if (isset($error)): ?>
|
||||
<p class="notification error"><?php echo $error; ?></p>
|
||||
<?php endif; ?>
|
||||
<?php if ($errors): ?>
|
||||
<p class="notification error"><?php echo $errors; ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<form method="post" action="" id="form" name="form">
|
||||
<p>Enter your database connection settings.</p>
|
||||
<table style="width: 100%;">
|
||||
<tr>
|
||||
<th class="col1"><label for="db_host">Database Host:</label></th>
|
||||
<td class="col2">
|
||||
<input id="db_host" name="db_host" type="text" size="20" value="<?php echo set_value("db_host", "localhost"); ?>"/>
|
||||
</td>
|
||||
<td class="col3">localhost or an ip (192.168.0.1)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="col1"><label for="db_port">Database Port:</label></th>
|
||||
<td class="col2">
|
||||
<input id="db_port" name="db_port" type="text" size="20" value="<?php echo set_value("db_port", "3306"); ?>"/>
|
||||
</td>
|
||||
<td class="col3">Which port is MySQL running on? Usually 3306.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="col1"><label for="db_name">Database Name:</label></th>
|
||||
<td class="col2">
|
||||
<input id="db_name" name="db_name" type="text" size="20" value="<?php echo set_value("db_name"); ?>"/>
|
||||
</td>
|
||||
<td class="col3">The name of the database to use.</td>
|
||||
</tr>
|
||||
<input name="dbprefix" type="hidden" value="pancake_"/>
|
||||
<tr>
|
||||
<th class="col1"><label for="db_user">Username:</label></th>
|
||||
<td class="col2">
|
||||
<input id="db_user" name="db_user" type="text" size="20" value="<?php echo set_value("db_user"); ?>"/>
|
||||
</td>
|
||||
<td class="col3">Your MySQL username.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="col1"><label for="db_pass">Password:</label></th>
|
||||
<td class="col2"><input id="db_pass" name="db_pass" type="password" size="20" value=""/>
|
||||
</td>
|
||||
<td class="col3">Your MySQL password.</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br/>
|
||||
<p>Enter the login details you want to use for Pancake.</p>
|
||||
<table style="width: 100%;">
|
||||
<tr>
|
||||
<th class="col1"><label for="username">Admin Username</label></th>
|
||||
<td class="col2">
|
||||
<input id="username" name="username" type="text" size="20" value="<?php echo set_value('username', 'admin'); ?>"/>
|
||||
</td>
|
||||
<td class="col3">What you want to login with.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th class="col1"><label for="password">Password</label></th>
|
||||
<td class="col2"><input id="password" name="password" type="password" size="20"/></td>
|
||||
<td class="col3">Choose a password.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th class="col1"><label for="password_confirm">Confirm Password</label></th>
|
||||
<td class="col2"><input id="password_confirm" name="password_confirm" type="password" size="20"/></td>
|
||||
<td class="col3">Confirm the password.</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
<br/>
|
||||
|
||||
<p class="center">
|
||||
<button type="submit" class="button">Mmmm... Let's Eat!</button>
|
||||
</p>
|
||||
</form>
|
||||
13
installer/views/steps/stop.php
Executable file
13
installer/views/steps/stop.php
Executable file
@@ -0,0 +1,13 @@
|
||||
<h2>Stop!</h2>
|
||||
<p>You have already installed Pancake!<br/>You almost certainly don't want to overwrite all the data you had.</p>
|
||||
<p>
|
||||
If you are just updating your Pancake's files manually, you should find the file that was in
|
||||
<code>system/pancake/config/database.php</code> before the update, and put it back there.
|
||||
</p>
|
||||
<p>You cannot use the installer because you've already installed Pancake.</p>
|
||||
<p class="fail">
|
||||
If you have any difficulty installing Pancake, don't forget:<br/>
|
||||
<strong>We can install Pancake for you, for free.</strong><br/>Just
|
||||
<a href="<?php echo PANCAKEAPP_COM_BASE_URL; ?>account/support/ticket/new">start a
|
||||
<strong>free</strong> support ticket</a>.
|
||||
</p>
|
||||
13
installer/views/steps/welcome.php
Executable file
13
installer/views/steps/welcome.php
Executable file
@@ -0,0 +1,13 @@
|
||||
<h2>Let's make some Pancakes!</h2>
|
||||
<p>Ingredient list, make sure you have these to hand:</p>
|
||||
<ul class="requirements">
|
||||
<li>License key (in receipt email)</li>
|
||||
<li>Database name</li>
|
||||
<li>Database username</li>
|
||||
<li>Database password</li>
|
||||
<li>Database host</li>
|
||||
</ul>
|
||||
<p>If you have all the information ready yourself, then you're ready to go. Hit the "Install Pancake!" link below to continue.</p>
|
||||
<p>If for any reason this recipe fails and the file creation doesn't work please try again then <a href="<?php echo PANCAKEAPP_COM_BASE_URL; ?>account/support/ticket/new">open a <strong>free</strong> support ticket</a> if it still does not work.</p>
|
||||
|
||||
<p class="center"><a href="<?php echo BASE_URL."index.php?/wizard/step1"; ?>" class="button">Install Pancake!</a></p>
|
||||
27
installer/views/template.php
Executable file
27
installer/views/template.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Pancake Payments Install Wizard</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<link rel="stylesheet" href="<?php echo Asset::get_src('style.css', 'css'); ?>" media="screen">
|
||||
<link rel='stylesheet' href='//fonts.googleapis.com/css?family=Paytone+One&v1' media="screen">
|
||||
</head>
|
||||
<body>
|
||||
<div id="wrapper">
|
||||
|
||||
<div id="content" class="no_object_notification">
|
||||
<?php echo $content; ?>
|
||||
</div>
|
||||
<!-- /content -->
|
||||
|
||||
<div id="footer">
|
||||
</div>
|
||||
<!-- /footer -->
|
||||
|
||||
</div>
|
||||
<!-- /wrapper -->
|
||||
|
||||
<script src="<?php echo Asset::get_src('jquery-1.11.2.min.js', 'js'); ?>"></script>
|
||||
<script src="<?php echo Asset::get_src('main.js', 'js'); ?>"></script>
|
||||
</body>
|
||||
</html>
|
||||
2
robots.txt
Executable file
2
robots.txt
Executable file
@@ -0,0 +1,2 @@
|
||||
User-agent: *
|
||||
Disallow: /
|
||||
1
system/codeigniter/.htaccess
Executable file
1
system/codeigniter/.htaccess
Executable file
@@ -0,0 +1 @@
|
||||
Deny from all
|
||||
118
system/codeigniter/core/Benchmark.php
Executable file
118
system/codeigniter/core/Benchmark.php
Executable file
@@ -0,0 +1,118 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 5.1.6 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* CodeIgniter Benchmark Class
|
||||
*
|
||||
* This class enables you to mark points and calculate the time difference
|
||||
* between them. Memory consumption can also be displayed.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Libraries
|
||||
* @category Libraries
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/libraries/benchmark.html
|
||||
*/
|
||||
class CI_Benchmark {
|
||||
|
||||
/**
|
||||
* List of all benchmark markers and when they were added
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $marker = array();
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set a benchmark marker
|
||||
*
|
||||
* Multiple calls to this function can be made so that several
|
||||
* execution points can be timed
|
||||
*
|
||||
* @access public
|
||||
* @param string $name name of the marker
|
||||
* @return void
|
||||
*/
|
||||
function mark($name)
|
||||
{
|
||||
$this->marker[$name] = microtime();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Calculates the time difference between two marked points.
|
||||
*
|
||||
* If the first parameter is empty this function instead returns the
|
||||
* {elapsed_time} pseudo-variable. This permits the full system
|
||||
* execution time to be shown in a template. The output class will
|
||||
* swap the real value for this variable.
|
||||
*
|
||||
* @access public
|
||||
* @param string a particular marked point
|
||||
* @param string a particular marked point
|
||||
* @param integer the number of decimal places
|
||||
* @return mixed
|
||||
*/
|
||||
function elapsed_time($point1 = '', $point2 = '', $decimals = 4)
|
||||
{
|
||||
if ($point1 == '')
|
||||
{
|
||||
return '{elapsed_time}';
|
||||
}
|
||||
|
||||
if ( ! isset($this->marker[$point1]))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
if ( ! isset($this->marker[$point2]))
|
||||
{
|
||||
$this->marker[$point2] = microtime();
|
||||
}
|
||||
|
||||
list($sm, $ss) = explode(' ', $this->marker[$point1]);
|
||||
list($em, $es) = explode(' ', $this->marker[$point2]);
|
||||
|
||||
return number_format(($em + $es) - ($sm + $ss), $decimals);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Memory Usage
|
||||
*
|
||||
* This function returns the {memory_usage} pseudo-variable.
|
||||
* This permits it to be put it anywhere in a template
|
||||
* without the memory being calculated until the end.
|
||||
* The output class will swap the real value for this variable.
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
function memory_usage()
|
||||
{
|
||||
return '{memory_usage}';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// END CI_Benchmark class
|
||||
|
||||
/* End of file Benchmark.php */
|
||||
/* Location: ./system/core/Benchmark.php */
|
||||
405
system/codeigniter/core/CodeIgniter.php
Executable file
405
system/codeigniter/core/CodeIgniter.php
Executable file
@@ -0,0 +1,405 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 5.1.6 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* System Initialization File
|
||||
*
|
||||
* Loads the base classes and executes the request.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage codeigniter
|
||||
* @category Front-controller
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/
|
||||
*/
|
||||
|
||||
/**
|
||||
* CodeIgniter Version
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
*/
|
||||
define('CI_VERSION', '2.1.4');
|
||||
|
||||
/**
|
||||
* CodeIgniter Branch (Core = TRUE, Reactor = FALSE)
|
||||
*
|
||||
* @var boolean
|
||||
*
|
||||
*/
|
||||
define('CI_CORE', FALSE);
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Load the global functions
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
require(BASEPATH.'core/Common.php');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Load the framework constants
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/constants.php'))
|
||||
{
|
||||
require(APPPATH.'config/'.ENVIRONMENT.'/constants.php');
|
||||
}
|
||||
else
|
||||
{
|
||||
require(APPPATH.'config/constants.php');
|
||||
}
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Define a custom error handler so we can log PHP errors
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
set_error_handler('_exception_handler');
|
||||
|
||||
if ( ! is_php('5.3'))
|
||||
{
|
||||
@set_magic_quotes_runtime(0); // Kill magic quotes
|
||||
}
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Set the subclass_prefix
|
||||
* ------------------------------------------------------
|
||||
*
|
||||
* Normally the "subclass_prefix" is set in the config file.
|
||||
* The subclass prefix allows CI to know if a core class is
|
||||
* being extended via a library in the local application
|
||||
* "libraries" folder. Since CI allows config items to be
|
||||
* overriden via data set in the main index. php file,
|
||||
* before proceeding we need to know if a subclass_prefix
|
||||
* override exists. If so, we will set this value now,
|
||||
* before any classes are loaded
|
||||
* Note: Since the config file data is cached it doesn't
|
||||
* hurt to load it here.
|
||||
*/
|
||||
if (isset($assign_to_config['subclass_prefix']) AND $assign_to_config['subclass_prefix'] != '')
|
||||
{
|
||||
get_config(array('subclass_prefix' => $assign_to_config['subclass_prefix']));
|
||||
}
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Set a liberal script execution time limit
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
if (function_exists("set_time_limit") == TRUE AND @ini_get("safe_mode") == 0)
|
||||
{
|
||||
@set_time_limit(300);
|
||||
}
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Start the timer... tick tock tick tock...
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
$BM =& load_class('Benchmark', 'core');
|
||||
$BM->mark('total_execution_time_start');
|
||||
$BM->mark('loading_time:_base_classes_start');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Instantiate the hooks class
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
$EXT =& load_class('Hooks', 'core');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Is there a "pre_system" hook?
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
$EXT->_call_hook('pre_system');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Instantiate the config class
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
$CFG =& load_class('Config', 'core');
|
||||
|
||||
// Do we have any manually set config items in the index.php file?
|
||||
if (isset($assign_to_config))
|
||||
{
|
||||
$CFG->_assign_to_config($assign_to_config);
|
||||
}
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Instantiate the UTF-8 class
|
||||
* ------------------------------------------------------
|
||||
*
|
||||
* Note: Order here is rather important as the UTF-8
|
||||
* class needs to be used very early on, but it cannot
|
||||
* properly determine if UTf-8 can be supported until
|
||||
* after the Config class is instantiated.
|
||||
*
|
||||
*/
|
||||
|
||||
$UNI =& load_class('Utf8', 'core');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Instantiate the URI class
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
$URI =& load_class('URI', 'core');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Instantiate the routing class and set the routing
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
$RTR =& load_class('Router', 'core');
|
||||
$RTR->_set_routing();
|
||||
|
||||
// Set any routing overrides that may exist in the main index file
|
||||
if (isset($routing))
|
||||
{
|
||||
$RTR->_set_overrides($routing);
|
||||
}
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Instantiate the output class
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
$OUT =& load_class('Output', 'core');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Is there a valid cache file? If so, we're done...
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
if ($EXT->_call_hook('cache_override') === FALSE)
|
||||
{
|
||||
if ($OUT->_display_cache($CFG, $URI) == TRUE)
|
||||
{
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------
|
||||
* Load the security class for xss and csrf support
|
||||
* -----------------------------------------------------
|
||||
*/
|
||||
$SEC =& load_class('Security', 'core');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Load the Input class and sanitize globals
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
$IN =& load_class('Input', 'core');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Load the Language class
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
$LANG =& load_class('Lang', 'core');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Load the app controller and local controller
|
||||
* ------------------------------------------------------
|
||||
*
|
||||
*/
|
||||
// Load the base controller class
|
||||
require BASEPATH.'core/Controller.php';
|
||||
|
||||
/**
|
||||
* @return Pancake_Controller
|
||||
*/
|
||||
function &get_instance()
|
||||
{
|
||||
return CI_Controller::get_instance();
|
||||
}
|
||||
|
||||
|
||||
if (file_exists(APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php'))
|
||||
{
|
||||
require APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php';
|
||||
}
|
||||
|
||||
// Load the local application controller
|
||||
// Note: The Router class automatically validates the controller path using the router->_validate_request().
|
||||
// If this include fails it means that the default controller in the Routes.php file is not resolving to something valid.
|
||||
if ( ! file_exists(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().'.php'))
|
||||
{
|
||||
show_error('Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.');
|
||||
}
|
||||
|
||||
include(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().'.php');
|
||||
|
||||
// Set a mark point for benchmarking
|
||||
$BM->mark('loading_time:_base_classes_end');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Security check
|
||||
* ------------------------------------------------------
|
||||
*
|
||||
* None of the functions in the app controller or the
|
||||
* loader class can be called via the URI, nor can
|
||||
* controller functions that begin with an underscore
|
||||
*/
|
||||
$class = $RTR->fetch_class();
|
||||
$method = $RTR->fetch_method();
|
||||
|
||||
if ( ! class_exists($class)
|
||||
OR strncmp($method, '_', 1) == 0
|
||||
OR in_array(strtolower($method), array_map('strtolower', get_class_methods('CI_Controller')))
|
||||
)
|
||||
{
|
||||
if ( ! empty($RTR->routes['404_override']))
|
||||
{
|
||||
$x = explode('/', $RTR->routes['404_override']);
|
||||
$class = $x[0];
|
||||
$method = (isset($x[1]) ? $x[1] : 'index');
|
||||
if ( ! class_exists($class))
|
||||
{
|
||||
if ( ! file_exists(APPPATH.'controllers/'.$class.'.php'))
|
||||
{
|
||||
show_404("{$class}/{$method}");
|
||||
}
|
||||
|
||||
include_once(APPPATH.'controllers/'.$class.'.php');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
show_404("{$class}/{$method}");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Is there a "pre_controller" hook?
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
$EXT->_call_hook('pre_controller');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Instantiate the requested controller
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
// Mark a start point so we can benchmark the controller
|
||||
$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_start');
|
||||
|
||||
$CI = new $class();
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Is there a "post_controller_constructor" hook?
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
$EXT->_call_hook('post_controller_constructor');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Call the requested method
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
// Is there a "remap" function? If so, we call it instead
|
||||
if (method_exists($CI, '_remap'))
|
||||
{
|
||||
$CI->_remap($method, array_slice($URI->rsegments, 2));
|
||||
}
|
||||
else
|
||||
{
|
||||
// is_callable() returns TRUE on some versions of PHP 5 for private and protected
|
||||
// methods, so we'll use this workaround for consistent behavior
|
||||
if ( ! in_array(strtolower($method), array_map('strtolower', get_class_methods($CI))))
|
||||
{
|
||||
// Check and see if we are using a 404 override and use it.
|
||||
if ( ! empty($RTR->routes['404_override']))
|
||||
{
|
||||
$x = explode('/', $RTR->routes['404_override']);
|
||||
$class = $x[0];
|
||||
$method = (isset($x[1]) ? $x[1] : 'index');
|
||||
if ( ! class_exists($class))
|
||||
{
|
||||
if ( ! file_exists(APPPATH.'controllers/'.$class.'.php'))
|
||||
{
|
||||
show_404("{$class}/{$method}");
|
||||
}
|
||||
|
||||
include_once(APPPATH.'controllers/'.$class.'.php');
|
||||
unset($CI);
|
||||
$CI = new $class();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
show_404("{$class}/{$method}");
|
||||
}
|
||||
}
|
||||
|
||||
// Call the requested method.
|
||||
// Any URI segments present (besides the class/function) will be passed to the method for convenience
|
||||
call_user_func_array(array(&$CI, $method), array_slice($URI->rsegments, 2));
|
||||
}
|
||||
|
||||
|
||||
// Mark a benchmark end point
|
||||
$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_end');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Is there a "post_controller" hook?
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
$EXT->_call_hook('post_controller');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Send the final rendered output to the browser
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
if ($EXT->_call_hook('display_override') === FALSE)
|
||||
{
|
||||
$OUT->_display();
|
||||
}
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Is there a "post_system" hook?
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
$EXT->_call_hook('post_system');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Close the DB connection if one exists
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
if (class_exists('CI_DB') AND isset($CI->db))
|
||||
{
|
||||
$CI->db->close();
|
||||
}
|
||||
|
||||
|
||||
/* End of file CodeIgniter.php */
|
||||
/* Location: ./system/core/CodeIgniter.php */
|
||||
565
system/codeigniter/core/Common.php
Executable file
565
system/codeigniter/core/Common.php
Executable file
@@ -0,0 +1,565 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 5.1.6 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Common Functions
|
||||
*
|
||||
* Loads the base classes and executes the request.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage codeigniter
|
||||
* @category Common Functions
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Determines if the current version of PHP is greater then the supplied value
|
||||
*
|
||||
* Since there are a few places where we conditionally test for PHP > 5
|
||||
* we'll set a static variable.
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return bool TRUE if the current version is $version or higher
|
||||
*/
|
||||
if ( ! function_exists('is_php'))
|
||||
{
|
||||
function is_php($version = '5.0.0')
|
||||
{
|
||||
static $_is_php;
|
||||
$version = (string)$version;
|
||||
|
||||
if ( ! isset($_is_php[$version]))
|
||||
{
|
||||
$_is_php[$version] = (version_compare(PHP_VERSION, $version) < 0) ? FALSE : TRUE;
|
||||
}
|
||||
|
||||
return $_is_php[$version];
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Tests for file writability
|
||||
*
|
||||
* is_writable() returns TRUE on Windows servers when you really can't write to
|
||||
* the file, based on the read-only attribute. is_writable() is also unreliable
|
||||
* on Unix servers if safe_mode is on.
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
if ( ! function_exists('is_really_writable'))
|
||||
{
|
||||
function is_really_writable($file)
|
||||
{
|
||||
// If we're on a Unix server with safe_mode off we call is_writable
|
||||
if (DIRECTORY_SEPARATOR == '/' AND @ini_get("safe_mode") == FALSE)
|
||||
{
|
||||
return is_writable($file);
|
||||
}
|
||||
|
||||
// For windows servers and safe_mode "on" installations we'll actually
|
||||
// write a file then read it. Bah...
|
||||
if (is_dir($file))
|
||||
{
|
||||
$file = rtrim($file, '/').'/'.md5(mt_rand(1,100).mt_rand(1,100));
|
||||
|
||||
if (($fp = @fopen($file, FOPEN_WRITE_CREATE)) === FALSE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
fclose($fp);
|
||||
@chmod($file, DIR_WRITE_MODE);
|
||||
@unlink($file);
|
||||
return TRUE;
|
||||
}
|
||||
elseif ( ! is_file($file) OR ($fp = @fopen($file, FOPEN_WRITE_CREATE)) === FALSE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
fclose($fp);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Class registry
|
||||
*
|
||||
* This function acts as a singleton. If the requested class does not
|
||||
* exist it is instantiated and set to a static variable. If it has
|
||||
* previously been instantiated the variable is returned.
|
||||
*
|
||||
* @access public
|
||||
* @param string the class name being requested
|
||||
* @param string the directory where the class should be found
|
||||
* @param string the class name prefix
|
||||
* @return object
|
||||
*/
|
||||
if ( ! function_exists('load_class'))
|
||||
{
|
||||
function &load_class($class, $directory = 'libraries', $prefix = 'CI_')
|
||||
{
|
||||
static $_classes = array();
|
||||
|
||||
// Does the class exist? If so, we're done...
|
||||
if (isset($_classes[$class]))
|
||||
{
|
||||
return $_classes[$class];
|
||||
}
|
||||
|
||||
$name = FALSE;
|
||||
|
||||
// Look for the class first in the local application/libraries folder
|
||||
// then in the native system/libraries folder
|
||||
foreach (array(APPPATH, BASEPATH) as $path)
|
||||
{
|
||||
if (file_exists($path.$directory.'/'.$class.'.php'))
|
||||
{
|
||||
$name = $prefix.$class;
|
||||
|
||||
if (class_exists($name) === FALSE)
|
||||
{
|
||||
require($path.$directory.'/'.$class.'.php');
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Is the request a class extension? If so we load it too
|
||||
if (file_exists(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.'.php'))
|
||||
{
|
||||
$name = config_item('subclass_prefix').$class;
|
||||
|
||||
if (class_exists($name) === FALSE)
|
||||
{
|
||||
require(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.'.php');
|
||||
}
|
||||
}
|
||||
|
||||
// Did we find the class?
|
||||
if ($name === FALSE)
|
||||
{
|
||||
// Note: We use exit() rather then show_error() in order to avoid a
|
||||
// self-referencing loop with the Excptions class
|
||||
exit('Unable to locate the specified class: '.$class.'.php');
|
||||
}
|
||||
|
||||
// Keep track of what we just loaded
|
||||
is_loaded($class);
|
||||
|
||||
$_classes[$class] = new $name();
|
||||
return $_classes[$class];
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Keeps track of which libraries have been loaded. This function is
|
||||
* called by the load_class() function above
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
if ( ! function_exists('is_loaded'))
|
||||
{
|
||||
function &is_loaded($class = '')
|
||||
{
|
||||
static $_is_loaded = array();
|
||||
|
||||
if ($class != '')
|
||||
{
|
||||
$_is_loaded[strtolower($class)] = $class;
|
||||
}
|
||||
|
||||
return $_is_loaded;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Loads the main config.php file
|
||||
*
|
||||
* This function lets us grab the config file even if the Config class
|
||||
* hasn't been instantiated yet
|
||||
*
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
if ( ! function_exists('get_config'))
|
||||
{
|
||||
function &get_config($replace = array())
|
||||
{
|
||||
static $_config;
|
||||
|
||||
if (isset($_config))
|
||||
{
|
||||
return $_config[0];
|
||||
}
|
||||
|
||||
// Is the config file in the environment folder?
|
||||
if ( ! defined('ENVIRONMENT') OR ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config.php'))
|
||||
{
|
||||
$file_path = APPPATH.'config/config.php';
|
||||
}
|
||||
|
||||
// Fetch the config file
|
||||
if ( ! file_exists($file_path))
|
||||
{
|
||||
exit('The configuration file does not exist.');
|
||||
}
|
||||
|
||||
require($file_path);
|
||||
|
||||
// Does the $config array exist in the file?
|
||||
if ( ! isset($config) OR ! is_array($config))
|
||||
{
|
||||
exit('Your config file does not appear to be formatted correctly.');
|
||||
}
|
||||
|
||||
// Are any values being dynamically replaced?
|
||||
if (count($replace) > 0)
|
||||
{
|
||||
foreach ($replace as $key => $val)
|
||||
{
|
||||
if (isset($config[$key]))
|
||||
{
|
||||
$config[$key] = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$_config[0] = &$config;
|
||||
return $_config[0];
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the specified config item
|
||||
*
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
if ( ! function_exists('config_item'))
|
||||
{
|
||||
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
|
||||
*/
|
||||
if ( ! function_exists('show_error'))
|
||||
{
|
||||
function show_error($message, $status_code = 500, $heading = 'An Error Was Encountered')
|
||||
{
|
||||
$_error =& load_class('Exceptions', 'core');
|
||||
echo $_error->show_error($heading, $message, 'error_general', $status_code);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* 404 Page Handler
|
||||
*
|
||||
* This function is similar to the show_error() function above
|
||||
* However, instead of the standard error template it displays
|
||||
* 404 errors.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
if ( ! function_exists('show_404'))
|
||||
{
|
||||
function show_404($page = '', $log_error = TRUE)
|
||||
{
|
||||
$_error =& load_class('Exceptions', 'core');
|
||||
$_error->show_404($page, $log_error);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Error Logging Interface
|
||||
*
|
||||
* We use this as a simple mechanism to access the logging
|
||||
* class and send messages to be logged.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
if ( ! function_exists('log_message'))
|
||||
{
|
||||
function log_message($level, $message, $php_error = FALSE)
|
||||
{
|
||||
static $_log;
|
||||
|
||||
if (config_item('log_threshold') == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$_log =& load_class('Log');
|
||||
$_log->write_log($level, $message, $php_error);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set HTTP Status Header
|
||||
*
|
||||
* @access public
|
||||
* @param int the status code
|
||||
* @param string
|
||||
* @return void
|
||||
*/
|
||||
if ( ! function_exists('set_status_header'))
|
||||
{
|
||||
function set_status_header($code = 200, $text = '')
|
||||
{
|
||||
$stati = array(
|
||||
200 => 'OK',
|
||||
201 => 'Created',
|
||||
202 => 'Accepted',
|
||||
203 => 'Non-Authoritative Information',
|
||||
204 => 'No Content',
|
||||
205 => 'Reset Content',
|
||||
206 => 'Partial Content',
|
||||
|
||||
300 => 'Multiple Choices',
|
||||
301 => 'Moved Permanently',
|
||||
302 => 'Found',
|
||||
304 => 'Not Modified',
|
||||
305 => 'Use Proxy',
|
||||
307 => 'Temporary Redirect',
|
||||
|
||||
400 => 'Bad Request',
|
||||
401 => 'Unauthorized',
|
||||
403 => 'Forbidden',
|
||||
404 => 'Not Found',
|
||||
405 => 'Method Not Allowed',
|
||||
406 => 'Not Acceptable',
|
||||
407 => 'Proxy Authentication Required',
|
||||
408 => 'Request Timeout',
|
||||
409 => 'Conflict',
|
||||
410 => 'Gone',
|
||||
411 => 'Length Required',
|
||||
412 => 'Precondition Failed',
|
||||
413 => 'Request Entity Too Large',
|
||||
414 => 'Request-URI Too Long',
|
||||
415 => 'Unsupported Media Type',
|
||||
416 => 'Requested Range Not Satisfiable',
|
||||
417 => 'Expectation Failed',
|
||||
|
||||
500 => 'Internal Server Error',
|
||||
501 => 'Not Implemented',
|
||||
502 => 'Bad Gateway',
|
||||
503 => 'Service Unavailable',
|
||||
504 => 'Gateway Timeout',
|
||||
505 => 'HTTP Version Not Supported'
|
||||
);
|
||||
|
||||
if ($code == '' OR ! is_numeric($code))
|
||||
{
|
||||
show_error('Status codes must be numeric', 500);
|
||||
}
|
||||
|
||||
if (isset($stati[$code]) AND $text == '')
|
||||
{
|
||||
$text = $stati[$code];
|
||||
}
|
||||
|
||||
if ($text == '')
|
||||
{
|
||||
show_error('No status text available. Please check your status code number or supply your own message text.', 500);
|
||||
}
|
||||
|
||||
$server_protocol = (isset($_SERVER['SERVER_PROTOCOL'])) ? $_SERVER['SERVER_PROTOCOL'] : FALSE;
|
||||
|
||||
if (substr(php_sapi_name(), 0, 3) == 'cgi')
|
||||
{
|
||||
header("Status: {$code} {$text}", TRUE);
|
||||
}
|
||||
elseif ($server_protocol == 'HTTP/1.1' OR $server_protocol == 'HTTP/1.0')
|
||||
{
|
||||
header($server_protocol." {$code} {$text}", TRUE, $code);
|
||||
}
|
||||
else
|
||||
{
|
||||
header("HTTP/1.1 {$code} {$text}", TRUE, $code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Exception Handler
|
||||
*
|
||||
* This is the custom exception handler that is declaired at the top
|
||||
* of Codeigniter.php. The main reason we use this is to permit
|
||||
* PHP errors to be logged in our own log files since the user may
|
||||
* not have access to server logs. Since this function
|
||||
* effectively intercepts PHP errors, however, we also need
|
||||
* to display errors based on the current error_reporting level.
|
||||
* We do that with the use of a PHP error template.
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
if ( ! function_exists('_exception_handler'))
|
||||
{
|
||||
function _exception_handler($severity, $message, $filepath, $line)
|
||||
{
|
||||
// We don't bother with "strict" notices since they tend to fill up
|
||||
// the log file with excess information that isn't normally very helpful.
|
||||
// For example, if you are running PHP 5 and you use version 4 style
|
||||
// class functions (without prefixes like "public", "private", etc.)
|
||||
// you'll get notices telling you that these have been deprecated.
|
||||
if ($severity == E_STRICT)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$_error =& load_class('Exceptions', 'core');
|
||||
|
||||
// Should we display the error? We'll get the current error_reporting
|
||||
// level and add its bits with the severity bits to find out.
|
||||
if (($severity & error_reporting()) == $severity)
|
||||
{
|
||||
$_error->show_php_error($severity, $message, $filepath, $line);
|
||||
}
|
||||
|
||||
// Should we log the error? No? We're done...
|
||||
if (config_item('log_threshold') == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$_error->log_exception($severity, $message, $filepath, $line);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Remove Invisible Characters
|
||||
*
|
||||
* This prevents sandwiching null characters
|
||||
* between ascii characters, like Java\0script.
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
if ( ! function_exists('remove_invisible_characters'))
|
||||
{
|
||||
function remove_invisible_characters($str, $url_encoded = TRUE)
|
||||
{
|
||||
$non_displayables = array();
|
||||
|
||||
// every control character except newline (dec 10)
|
||||
// carriage return (dec 13), and horizontal tab (dec 09)
|
||||
|
||||
if ($url_encoded)
|
||||
{
|
||||
$non_displayables[] = '/%0[0-8bcef]/'; // url encoded 00-08, 11, 12, 14, 15
|
||||
$non_displayables[] = '/%1[0-9a-f]/'; // url encoded 16-31
|
||||
}
|
||||
|
||||
$non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S'; // 00-08, 11, 12, 14-31, 127
|
||||
|
||||
do
|
||||
{
|
||||
$str = preg_replace($non_displayables, '', $str, -1, $count);
|
||||
}
|
||||
while ($count);
|
||||
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns HTML escaped variable
|
||||
*
|
||||
* @access public
|
||||
* @param mixed
|
||||
* @return mixed
|
||||
*/
|
||||
if ( ! function_exists('html_escape'))
|
||||
{
|
||||
function html_escape($var)
|
||||
{
|
||||
if (is_array($var))
|
||||
{
|
||||
return array_map('html_escape', $var);
|
||||
}
|
||||
else
|
||||
{
|
||||
return htmlspecialchars($var, ENT_QUOTES, config_item('charset'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* End of file Common.php */
|
||||
/* Location: ./system/core/Common.php */
|
||||
379
system/codeigniter/core/Config.php
Executable file
379
system/codeigniter/core/Config.php
Executable file
@@ -0,0 +1,379 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 5.1.6 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* CodeIgniter Config Class
|
||||
*
|
||||
* This class contains functions that enable config files to be managed
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Libraries
|
||||
* @category Libraries
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/libraries/config.html
|
||||
*/
|
||||
class CI_Config {
|
||||
|
||||
/**
|
||||
* List of all loaded config values
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $config = array();
|
||||
/**
|
||||
* List of all loaded config files
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $is_loaded = array();
|
||||
/**
|
||||
* List of paths to search when trying to load a config file
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $_config_paths = array(APPPATH);
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Sets the $config data from the primary config.php file as a class variable
|
||||
*
|
||||
* @access public
|
||||
* @param string the config file name
|
||||
* @param boolean if configuration values should be loaded into their own section
|
||||
* @param boolean true if errors should just return false, false if an error message should be displayed
|
||||
* @return boolean if the file was successfully loaded or not
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
$this->config =& get_config();
|
||||
log_message('debug', "Config Class Initialized");
|
||||
|
||||
// Set the base_url automatically if none was provided
|
||||
if ($this->config['base_url'] == '')
|
||||
{
|
||||
if (isset($_SERVER['HTTP_HOST']))
|
||||
{
|
||||
$base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http';
|
||||
$base_url .= '://'. $_SERVER['HTTP_HOST'];
|
||||
$base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$base_url = 'http://localhost/';
|
||||
}
|
||||
|
||||
$this->set_item('base_url', $base_url);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Load Config File
|
||||
*
|
||||
* @access public
|
||||
* @param string the config file name
|
||||
* @param boolean if configuration values should be loaded into their own section
|
||||
* @param boolean true if errors should just return false, false if an error message should be displayed
|
||||
* @return boolean if the file was loaded correctly
|
||||
*/
|
||||
function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
|
||||
{
|
||||
$file = ($file == '') ? 'config' : str_replace('.php', '', $file);
|
||||
$found = FALSE;
|
||||
$loaded = FALSE;
|
||||
|
||||
$check_locations = defined('ENVIRONMENT')
|
||||
? array(ENVIRONMENT.'/'.$file, $file)
|
||||
: array($file);
|
||||
|
||||
foreach ($this->_config_paths as $path)
|
||||
{
|
||||
foreach ($check_locations as $location)
|
||||
{
|
||||
$file_path = $path.'config/'.$location.'.php';
|
||||
|
||||
if (in_array($file_path, $this->is_loaded, TRUE))
|
||||
{
|
||||
$loaded = TRUE;
|
||||
continue 2;
|
||||
}
|
||||
|
||||
if (file_exists($file_path))
|
||||
{
|
||||
$found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($found === FALSE)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
include($file_path);
|
||||
|
||||
if ( ! isset($config) OR ! is_array($config))
|
||||
{
|
||||
if ($fail_gracefully === TRUE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
show_error('Your '.$file_path.' file does not appear to contain a valid configuration array.');
|
||||
}
|
||||
|
||||
if ($use_sections === TRUE)
|
||||
{
|
||||
if (isset($this->config[$file]))
|
||||
{
|
||||
$this->config[$file] = array_merge($this->config[$file], $config);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->config[$file] = $config;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->config = array_merge($this->config, $config);
|
||||
}
|
||||
|
||||
$this->is_loaded[] = $file_path;
|
||||
unset($config);
|
||||
|
||||
$loaded = TRUE;
|
||||
log_message('debug', 'Config file loaded: '.$file_path);
|
||||
break;
|
||||
}
|
||||
|
||||
if ($loaded === FALSE)
|
||||
{
|
||||
if ($fail_gracefully === TRUE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
show_error('The configuration file '.$file.'.php does not exist.');
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fetch a config file item
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @param string the config item name
|
||||
* @param string the index name
|
||||
* @param bool
|
||||
* @return string
|
||||
*/
|
||||
function item($item, $index = '')
|
||||
{
|
||||
if ($index == '')
|
||||
{
|
||||
if ( ! isset($this->config[$item]))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$pref = $this->config[$item];
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ! isset($this->config[$index]))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( ! isset($this->config[$index][$item]))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$pref = $this->config[$index][$item];
|
||||
}
|
||||
|
||||
return $pref;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fetch a config file item - adds slash after item (if item is not empty)
|
||||
*
|
||||
* @access public
|
||||
* @param string the config item name
|
||||
* @param bool
|
||||
* @return string
|
||||
*/
|
||||
function slash_item($item)
|
||||
{
|
||||
if ( ! isset($this->config[$item]))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if( trim($this->config[$item]) == '')
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
return rtrim($this->config[$item], '/').'/';
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Site URL
|
||||
* Returns base_url . index_page [. uri_string]
|
||||
*
|
||||
* @access public
|
||||
* @param string the URI string
|
||||
* @return string
|
||||
*/
|
||||
function site_url($uri = '')
|
||||
{
|
||||
if ($uri == '')
|
||||
{
|
||||
return $this->slash_item('base_url').$this->item('index_page');
|
||||
}
|
||||
|
||||
if ($this->item('enable_query_strings') == FALSE)
|
||||
{
|
||||
$suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix');
|
||||
return $this->slash_item('base_url').$this->slash_item('index_page').$this->_uri_string($uri).$suffix;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->slash_item('base_url').$this->item('index_page').'?'.$this->_uri_string($uri);
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Base URL
|
||||
* Returns base_url [. uri_string]
|
||||
*
|
||||
* @access public
|
||||
* @param string $uri
|
||||
* @return string
|
||||
*/
|
||||
function base_url($uri = '')
|
||||
{
|
||||
return $this->slash_item('base_url').ltrim($this->_uri_string($uri), '/');
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Build URI string for use in Config::site_url() and Config::base_url()
|
||||
*
|
||||
* @access protected
|
||||
* @param $uri
|
||||
* @return string
|
||||
*/
|
||||
protected function _uri_string($uri)
|
||||
{
|
||||
if ($this->item('enable_query_strings') == FALSE)
|
||||
{
|
||||
if (is_array($uri))
|
||||
{
|
||||
$uri = implode('/', $uri);
|
||||
}
|
||||
$uri = trim($uri, '/');
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_array($uri))
|
||||
{
|
||||
$i = 0;
|
||||
$str = '';
|
||||
foreach ($uri as $key => $val)
|
||||
{
|
||||
$prefix = ($i == 0) ? '' : '&';
|
||||
$str .= $prefix.$key.'='.$val;
|
||||
$i++;
|
||||
}
|
||||
$uri = $str;
|
||||
}
|
||||
}
|
||||
return $uri;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* System URL
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
function system_url()
|
||||
{
|
||||
$x = explode("/", preg_replace("|/*(.+?)/*$|", "\\1", BASEPATH));
|
||||
return $this->slash_item('base_url').end($x).'/';
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set a config file item
|
||||
*
|
||||
* @access public
|
||||
* @param string the config item key
|
||||
* @param string the config item value
|
||||
* @return void
|
||||
*/
|
||||
function set_item($item, $value)
|
||||
{
|
||||
$this->config[$item] = $value;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Assign to Config
|
||||
*
|
||||
* This function is called by the front controller (CodeIgniter.php)
|
||||
* after the Config class is instantiated. It permits config items
|
||||
* to be assigned or overriden by variables contained in the index.php file
|
||||
*
|
||||
* @access private
|
||||
* @param array
|
||||
* @return void
|
||||
*/
|
||||
function _assign_to_config($items = array())
|
||||
{
|
||||
if (is_array($items))
|
||||
{
|
||||
foreach ($items as $key => $val)
|
||||
{
|
||||
$this->set_item($key, $val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// END CI_Config class
|
||||
|
||||
/* End of file Config.php */
|
||||
/* Location: ./system/core/Config.php */
|
||||
64
system/codeigniter/core/Controller.php
Executable file
64
system/codeigniter/core/Controller.php
Executable file
@@ -0,0 +1,64 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 5.1.6 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* CodeIgniter Application Controller Class
|
||||
*
|
||||
* This class object is the super class that every library in
|
||||
* CodeIgniter will be assigned to.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Libraries
|
||||
* @category Libraries
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/general/controllers.html
|
||||
*/
|
||||
class CI_Controller {
|
||||
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
self::$instance =& $this;
|
||||
|
||||
// Assign all the class objects that were instantiated by the
|
||||
// bootstrap file (CodeIgniter.php) to local class variables
|
||||
// so that CI can run as one big super object.
|
||||
foreach (is_loaded() as $var => $class)
|
||||
{
|
||||
$this->$var =& load_class($class);
|
||||
}
|
||||
|
||||
$this->load =& load_class('Loader', 'core');
|
||||
|
||||
$this->load->initialize();
|
||||
|
||||
log_message('debug', "Controller Class Initialized");
|
||||
}
|
||||
|
||||
public static function &get_instance()
|
||||
{
|
||||
return self::$instance;
|
||||
}
|
||||
}
|
||||
// END Controller class
|
||||
|
||||
/* End of file Controller.php */
|
||||
/* Location: ./system/core/Controller.php */
|
||||
193
system/codeigniter/core/Exceptions.php
Executable file
193
system/codeigniter/core/Exceptions.php
Executable file
@@ -0,0 +1,193 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 5.1.6 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Exceptions Class
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Libraries
|
||||
* @category Exceptions
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/libraries/exceptions.html
|
||||
*/
|
||||
class CI_Exceptions {
|
||||
var $action;
|
||||
var $severity;
|
||||
var $message;
|
||||
var $filename;
|
||||
var $line;
|
||||
|
||||
/**
|
||||
* Nesting level of the output buffering mechanism
|
||||
*
|
||||
* @var int
|
||||
* @access public
|
||||
*/
|
||||
var $ob_level;
|
||||
|
||||
/**
|
||||
* List if available error levels
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $levels = array(
|
||||
E_ERROR => 'Error',
|
||||
E_WARNING => 'Warning',
|
||||
E_PARSE => 'Parsing Error',
|
||||
E_NOTICE => 'Notice',
|
||||
E_CORE_ERROR => 'Core Error',
|
||||
E_CORE_WARNING => 'Core Warning',
|
||||
E_COMPILE_ERROR => 'Compile Error',
|
||||
E_COMPILE_WARNING => 'Compile Warning',
|
||||
E_USER_ERROR => 'User Error',
|
||||
E_USER_WARNING => 'User Warning',
|
||||
E_USER_NOTICE => 'User Notice',
|
||||
E_STRICT => 'Runtime Notice'
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->ob_level = ob_get_level();
|
||||
// Note: Do not log messages from this constructor.
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Exception Logger
|
||||
*
|
||||
* This function logs PHP generated error messages
|
||||
*
|
||||
* @access private
|
||||
* @param string the error severity
|
||||
* @param string the error string
|
||||
* @param string the error filepath
|
||||
* @param string the error line number
|
||||
* @return string
|
||||
*/
|
||||
function log_exception($severity, $message, $filepath, $line)
|
||||
{
|
||||
$severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];
|
||||
|
||||
log_message('error', 'Severity: '.$severity.' --> '.$message. ' '.$filepath.' '.$line, TRUE);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* 404 Page Not Found Handler
|
||||
*
|
||||
* @access private
|
||||
* @param string the page
|
||||
* @param bool log error yes/no
|
||||
* @return string
|
||||
*/
|
||||
function show_404($page = '', $log_error = TRUE)
|
||||
{
|
||||
$heading = "404 Page Not Found";
|
||||
$message = "The page you requested was not found.";
|
||||
|
||||
// By default we log this, but allow a dev to skip it
|
||||
if ($log_error)
|
||||
{
|
||||
log_message('error', '404 Page Not Found --> '.$page);
|
||||
}
|
||||
|
||||
echo $this->show_error($heading, $message, 'error_404', 404);
|
||||
exit;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* General Error Page
|
||||
*
|
||||
* This function takes an error message as input
|
||||
* (either as a string or an array) and displays
|
||||
* it using the specified template.
|
||||
*
|
||||
* @access private
|
||||
* @param string the heading
|
||||
* @param string the message
|
||||
* @param string the template name
|
||||
* @param int the status code
|
||||
* @return string
|
||||
*/
|
||||
function show_error($heading, $message, $template = 'error_general', $status_code = 500)
|
||||
{
|
||||
set_status_header($status_code);
|
||||
|
||||
$message = '<p>'.implode('</p><p>', ( ! is_array($message)) ? array($message) : $message).'</p>';
|
||||
|
||||
if (ob_get_level() > $this->ob_level + 1)
|
||||
{
|
||||
ob_end_flush();
|
||||
}
|
||||
ob_start();
|
||||
include(APPPATH.'errors/'.$template.'.php');
|
||||
$buffer = ob_get_contents();
|
||||
ob_end_clean();
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Native PHP error handler
|
||||
*
|
||||
* @access private
|
||||
* @param string the error severity
|
||||
* @param string the error string
|
||||
* @param string the error filepath
|
||||
* @param string the error line number
|
||||
* @return string
|
||||
*/
|
||||
function show_php_error($severity, $message, $filepath, $line)
|
||||
{
|
||||
$severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];
|
||||
|
||||
$filepath = str_replace("\\", "/", $filepath);
|
||||
|
||||
// For safety reasons we do not show the full file path
|
||||
if (FALSE !== strpos($filepath, '/'))
|
||||
{
|
||||
$x = explode('/', $filepath);
|
||||
$filepath = $x[count($x)-2].'/'.end($x);
|
||||
}
|
||||
|
||||
if (ob_get_level() > $this->ob_level + 1)
|
||||
{
|
||||
ob_end_flush();
|
||||
}
|
||||
ob_start();
|
||||
include(APPPATH.'errors/error_php.php');
|
||||
$buffer = ob_get_contents();
|
||||
ob_end_clean();
|
||||
echo $buffer;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// END Exceptions Class
|
||||
|
||||
/* End of file Exceptions.php */
|
||||
/* Location: ./system/core/Exceptions.php */
|
||||
248
system/codeigniter/core/Hooks.php
Executable file
248
system/codeigniter/core/Hooks.php
Executable file
@@ -0,0 +1,248 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 5.1.6 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* CodeIgniter Hooks Class
|
||||
*
|
||||
* Provides a mechanism to extend the base system without hacking.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Libraries
|
||||
* @category Libraries
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/libraries/encryption.html
|
||||
*/
|
||||
class CI_Hooks {
|
||||
|
||||
/**
|
||||
* Determines wether hooks are enabled
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
var $enabled = FALSE;
|
||||
/**
|
||||
* List of all hooks set in config/hooks.php
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $hooks = array();
|
||||
/**
|
||||
* Determines wether hook is in progress, used to prevent infinte loops
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
var $in_progress = FALSE;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
$this->_initialize();
|
||||
log_message('debug', "Hooks Class Initialized");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Initialize the Hooks Preferences
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
function _initialize()
|
||||
{
|
||||
$CFG =& load_class('Config', 'core');
|
||||
|
||||
// If hooks are not enabled in the config file
|
||||
// there is nothing else to do
|
||||
|
||||
if ($CFG->item('enable_hooks') == FALSE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Grab the "hooks" definition file.
|
||||
// If there are no hooks, we're done.
|
||||
|
||||
if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/hooks.php'))
|
||||
{
|
||||
include(APPPATH.'config/'.ENVIRONMENT.'/hooks.php');
|
||||
}
|
||||
elseif (is_file(APPPATH.'config/hooks.php'))
|
||||
{
|
||||
include(APPPATH.'config/hooks.php');
|
||||
}
|
||||
|
||||
|
||||
if ( ! isset($hook) OR ! is_array($hook))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->hooks =& $hook;
|
||||
$this->enabled = TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Call Hook
|
||||
*
|
||||
* Calls a particular hook
|
||||
*
|
||||
* @access private
|
||||
* @param string the hook name
|
||||
* @return mixed
|
||||
*/
|
||||
function _call_hook($which = '')
|
||||
{
|
||||
if ( ! $this->enabled OR ! isset($this->hooks[$which]))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (isset($this->hooks[$which][0]) AND is_array($this->hooks[$which][0]))
|
||||
{
|
||||
foreach ($this->hooks[$which] as $val)
|
||||
{
|
||||
$this->_run_hook($val);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_run_hook($this->hooks[$which]);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Run Hook
|
||||
*
|
||||
* Runs a particular hook
|
||||
*
|
||||
* @access private
|
||||
* @param array the hook details
|
||||
* @return bool
|
||||
*/
|
||||
function _run_hook($data)
|
||||
{
|
||||
if ( ! is_array($data))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// -----------------------------------
|
||||
// Safety - Prevents run-away loops
|
||||
// -----------------------------------
|
||||
|
||||
// If the script being called happens to have the same
|
||||
// hook call within it a loop can happen
|
||||
|
||||
if ($this->in_progress == TRUE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// -----------------------------------
|
||||
// Set file path
|
||||
// -----------------------------------
|
||||
|
||||
if ( ! isset($data['filepath']) OR ! isset($data['filename']))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$filepath = APPPATH.$data['filepath'].'/'.$data['filename'];
|
||||
|
||||
if ( ! file_exists($filepath))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// -----------------------------------
|
||||
// Set class/function name
|
||||
// -----------------------------------
|
||||
|
||||
$class = FALSE;
|
||||
$function = FALSE;
|
||||
$params = '';
|
||||
|
||||
if (isset($data['class']) AND $data['class'] != '')
|
||||
{
|
||||
$class = $data['class'];
|
||||
}
|
||||
|
||||
if (isset($data['function']))
|
||||
{
|
||||
$function = $data['function'];
|
||||
}
|
||||
|
||||
if (isset($data['params']))
|
||||
{
|
||||
$params = $data['params'];
|
||||
}
|
||||
|
||||
if ($class === FALSE AND $function === FALSE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// -----------------------------------
|
||||
// Set the in_progress flag
|
||||
// -----------------------------------
|
||||
|
||||
$this->in_progress = TRUE;
|
||||
|
||||
// -----------------------------------
|
||||
// Call the requested class and/or function
|
||||
// -----------------------------------
|
||||
|
||||
if ($class !== FALSE)
|
||||
{
|
||||
if ( ! class_exists($class))
|
||||
{
|
||||
require($filepath);
|
||||
}
|
||||
|
||||
$HOOK = new $class;
|
||||
$HOOK->$function($params);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ! function_exists($function))
|
||||
{
|
||||
require($filepath);
|
||||
}
|
||||
|
||||
$function($params);
|
||||
}
|
||||
|
||||
$this->in_progress = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// END CI_Hooks class
|
||||
|
||||
/* End of file Hooks.php */
|
||||
/* Location: ./system/core/Hooks.php */
|
||||
861
system/codeigniter/core/Input.php
Executable file
861
system/codeigniter/core/Input.php
Executable file
@@ -0,0 +1,861 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 5.1.6 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Input Class
|
||||
*
|
||||
* Pre-processes global input data for security
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Libraries
|
||||
* @category Input
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/libraries/input.html
|
||||
*/
|
||||
class CI_Input {
|
||||
|
||||
/**
|
||||
* IP address of the current user
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
var $ip_address = FALSE;
|
||||
/**
|
||||
* user agent (web browser) being used by the current user
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
var $user_agent = FALSE;
|
||||
/**
|
||||
* If FALSE, then $_GET will be set to an empty array
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
var $_allow_get_array = TRUE;
|
||||
/**
|
||||
* If TRUE, then newlines are standardized
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
var $_standardize_newlines = TRUE;
|
||||
/**
|
||||
* Determines whether the XSS filter is always active when GET, POST or COOKIE data is encountered
|
||||
* Set automatically based on config setting
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
var $_enable_xss = FALSE;
|
||||
/**
|
||||
* Enables a CSRF cookie token to be set.
|
||||
* Set automatically based on config setting
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
var $_enable_csrf = FALSE;
|
||||
/**
|
||||
* List of all HTTP request headers
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $headers = array();
|
||||
|
||||
/**
|
||||
* CI_Security instance
|
||||
*
|
||||
* Used for the optional $xss_filter parameter that most
|
||||
* getter methods have here.
|
||||
*
|
||||
* @var CI_Security
|
||||
*/
|
||||
protected $security;
|
||||
|
||||
public CI_Utf8 $uni;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Sets whether to globally enable the XSS processing
|
||||
* and whether to allow the $_GET array
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
log_message('debug', "Input Class Initialized");
|
||||
|
||||
$this->_allow_get_array = (config_item('allow_get_array') === TRUE);
|
||||
$this->_enable_xss = (config_item('global_xss_filtering') === TRUE);
|
||||
$this->_enable_csrf = (config_item('csrf_protection') === TRUE);
|
||||
|
||||
global $SEC;
|
||||
$this->security =& $SEC;
|
||||
|
||||
// Do we need the UTF-8 class?
|
||||
if (UTF8_ENABLED === TRUE)
|
||||
{
|
||||
global $UNI;
|
||||
$this->uni =& $UNI;
|
||||
}
|
||||
|
||||
// Sanitize global arrays
|
||||
$this->_sanitize_globals();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fetch from array
|
||||
*
|
||||
* This is a helper function to retrieve values from global arrays
|
||||
*
|
||||
* @access private
|
||||
* @param array
|
||||
* @param string
|
||||
* @param bool
|
||||
* @return string
|
||||
*/
|
||||
function _fetch_from_array(&$array, $index = '', $xss_clean = FALSE)
|
||||
{
|
||||
if ( ! isset($array[$index]))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ($xss_clean === TRUE)
|
||||
{
|
||||
return $this->security->xss_clean($array[$index]);
|
||||
}
|
||||
|
||||
return $array[$index];
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fetch an item from the GET array
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param bool
|
||||
* @return string
|
||||
*/
|
||||
function get($index = NULL, $xss_clean = FALSE)
|
||||
{
|
||||
// Check if a field has been provided
|
||||
if ($index === NULL AND ! empty($_GET))
|
||||
{
|
||||
$get = array();
|
||||
|
||||
// loop through the full _GET array
|
||||
foreach (array_keys($_GET) as $key)
|
||||
{
|
||||
$get[$key] = $this->_fetch_from_array($_GET, $key, $xss_clean);
|
||||
}
|
||||
return $get;
|
||||
}
|
||||
|
||||
return $this->_fetch_from_array($_GET, $index, $xss_clean);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fetch an item from the POST array
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param bool
|
||||
* @return string
|
||||
*/
|
||||
function post($index = NULL, $xss_clean = FALSE)
|
||||
{
|
||||
// Check if a field has been provided
|
||||
if ($index === NULL AND ! empty($_POST))
|
||||
{
|
||||
$post = array();
|
||||
|
||||
// Loop through the full _POST array and return it
|
||||
foreach (array_keys($_POST) as $key)
|
||||
{
|
||||
$post[$key] = $this->_fetch_from_array($_POST, $key, $xss_clean);
|
||||
}
|
||||
return $post;
|
||||
}
|
||||
|
||||
return $this->_fetch_from_array($_POST, $index, $xss_clean);
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fetch an item from either the GET array or the POST
|
||||
*
|
||||
* @access public
|
||||
* @param string The index key
|
||||
* @param bool XSS cleaning
|
||||
* @return string
|
||||
*/
|
||||
function get_post($index = '', $xss_clean = FALSE)
|
||||
{
|
||||
if ( ! isset($_POST[$index]) )
|
||||
{
|
||||
return $this->get($index, $xss_clean);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->post($index, $xss_clean);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fetch an item from the COOKIE array
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param bool
|
||||
* @return string
|
||||
*/
|
||||
function cookie($index = '', $xss_clean = FALSE)
|
||||
{
|
||||
return $this->_fetch_from_array($_COOKIE, $index, $xss_clean);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set cookie
|
||||
*
|
||||
* Accepts six parameter, or you can submit an associative
|
||||
* array in the first parameter containing all the values.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed
|
||||
* @param string the value of the cookie
|
||||
* @param string the number of seconds until expiration
|
||||
* @param string the cookie domain. Usually: .yourdomain.com
|
||||
* @param string the cookie path
|
||||
* @param string the cookie prefix
|
||||
* @param bool true makes the cookie secure
|
||||
* @return void
|
||||
*/
|
||||
function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE)
|
||||
{
|
||||
if (is_array($name))
|
||||
{
|
||||
// always leave 'name' in last place, as the loop will break otherwise, due to $$item
|
||||
foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'secure', 'name') as $item)
|
||||
{
|
||||
if (isset($name[$item]))
|
||||
{
|
||||
$$item = $name[$item];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($prefix == '' AND config_item('cookie_prefix') != '')
|
||||
{
|
||||
$prefix = config_item('cookie_prefix');
|
||||
}
|
||||
if ($domain == '' AND config_item('cookie_domain') != '')
|
||||
{
|
||||
$domain = config_item('cookie_domain');
|
||||
}
|
||||
if ($path == '/' AND config_item('cookie_path') != '/')
|
||||
{
|
||||
$path = config_item('cookie_path');
|
||||
}
|
||||
if ($secure == FALSE AND config_item('cookie_secure') != FALSE)
|
||||
{
|
||||
$secure = config_item('cookie_secure');
|
||||
}
|
||||
|
||||
if ( ! is_numeric($expire))
|
||||
{
|
||||
$expire = time() - 86500;
|
||||
}
|
||||
else
|
||||
{
|
||||
$expire = ($expire > 0) ? time() + $expire : 0;
|
||||
}
|
||||
|
||||
setcookie($prefix.$name, $value, $expire, $path, $domain, $secure, true);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fetch an item from the SERVER array
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param bool
|
||||
* @return string
|
||||
*/
|
||||
function server($index = '', $xss_clean = FALSE)
|
||||
{
|
||||
return $this->_fetch_from_array($_SERVER, $index, $xss_clean);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fetch the IP Address
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function ip_address()
|
||||
{
|
||||
if ($this->ip_address !== FALSE)
|
||||
{
|
||||
return $this->ip_address;
|
||||
}
|
||||
|
||||
$proxy_ips = config_item('proxy_ips');
|
||||
if ( ! empty($proxy_ips))
|
||||
{
|
||||
$proxy_ips = explode(',', str_replace(' ', '', $proxy_ips));
|
||||
foreach (array('HTTP_X_FORWARDED_FOR', 'HTTP_CLIENT_IP', 'HTTP_X_CLIENT_IP', 'HTTP_X_CLUSTER_CLIENT_IP') as $header)
|
||||
{
|
||||
if (($spoof = $this->server($header)) !== FALSE)
|
||||
{
|
||||
// Some proxies typically list the whole chain of IP
|
||||
// addresses through which the client has reached us.
|
||||
// e.g. client_ip, proxy_ip1, proxy_ip2, etc.
|
||||
if (strpos($spoof, ',') !== FALSE)
|
||||
{
|
||||
$spoof = explode(',', $spoof, 2);
|
||||
$spoof = $spoof[0];
|
||||
}
|
||||
|
||||
if ( ! $this->valid_ip($spoof))
|
||||
{
|
||||
$spoof = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->ip_address = ($spoof !== FALSE && in_array($_SERVER['REMOTE_ADDR'], $proxy_ips, TRUE))
|
||||
? $spoof : $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->ip_address = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
|
||||
if ( ! $this->valid_ip($this->ip_address))
|
||||
{
|
||||
$this->ip_address = '0.0.0.0';
|
||||
}
|
||||
|
||||
return $this->ip_address;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Validate IP Address
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param string ipv4 or ipv6
|
||||
* @return bool
|
||||
*/
|
||||
public function valid_ip($ip, $which = '')
|
||||
{
|
||||
$which = strtolower($which);
|
||||
|
||||
// First check if filter_var is available
|
||||
if (is_callable('filter_var'))
|
||||
{
|
||||
switch ($which) {
|
||||
case 'ipv4':
|
||||
$flag = FILTER_FLAG_IPV4;
|
||||
break;
|
||||
case 'ipv6':
|
||||
$flag = FILTER_FLAG_IPV6;
|
||||
break;
|
||||
default:
|
||||
$flag = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return (bool) filter_var($ip, FILTER_VALIDATE_IP, $flag);
|
||||
}
|
||||
|
||||
if ($which !== 'ipv6' && $which !== 'ipv4')
|
||||
{
|
||||
if (strpos($ip, ':') !== FALSE)
|
||||
{
|
||||
$which = 'ipv6';
|
||||
}
|
||||
elseif (strpos($ip, '.') !== FALSE)
|
||||
{
|
||||
$which = 'ipv4';
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
$func = '_valid_'.$which;
|
||||
return $this->$func($ip);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Validate IPv4 Address
|
||||
*
|
||||
* Updated version suggested by Geert De Deckere
|
||||
*
|
||||
* @access protected
|
||||
* @param string
|
||||
* @return bool
|
||||
*/
|
||||
protected function _valid_ipv4($ip)
|
||||
{
|
||||
$ip_segments = explode('.', $ip);
|
||||
|
||||
// Always 4 segments needed
|
||||
if (count($ip_segments) !== 4)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
// IP can not start with 0
|
||||
if ($ip_segments[0][0] == '0')
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Check each segment
|
||||
foreach ($ip_segments as $segment)
|
||||
{
|
||||
// IP segments must be digits and can not be
|
||||
// longer than 3 digits or greater then 255
|
||||
if ($segment == '' OR preg_match("/[^0-9]/", $segment) OR $segment > 255 OR strlen($segment) > 3)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Validate IPv6 Address
|
||||
*
|
||||
* @access protected
|
||||
* @param string
|
||||
* @return bool
|
||||
*/
|
||||
protected function _valid_ipv6($str)
|
||||
{
|
||||
// 8 groups, separated by :
|
||||
// 0-ffff per group
|
||||
// one set of consecutive 0 groups can be collapsed to ::
|
||||
|
||||
$groups = 8;
|
||||
$collapsed = FALSE;
|
||||
|
||||
$chunks = array_filter(
|
||||
preg_split('/(:{1,2})/', $str, NULL, PREG_SPLIT_DELIM_CAPTURE)
|
||||
);
|
||||
|
||||
// Rule out easy nonsense
|
||||
if (current($chunks) == ':' OR end($chunks) == ':')
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// PHP supports IPv4-mapped IPv6 addresses, so we'll expect those as well
|
||||
if (strpos(end($chunks), '.') !== FALSE)
|
||||
{
|
||||
$ipv4 = array_pop($chunks);
|
||||
|
||||
if ( ! $this->_valid_ipv4($ipv4))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$groups--;
|
||||
}
|
||||
|
||||
while ($seg = array_pop($chunks))
|
||||
{
|
||||
if ($seg[0] == ':')
|
||||
{
|
||||
if (--$groups == 0)
|
||||
{
|
||||
return FALSE; // too many groups
|
||||
}
|
||||
|
||||
if (strlen($seg) > 2)
|
||||
{
|
||||
return FALSE; // long separator
|
||||
}
|
||||
|
||||
if ($seg == '::')
|
||||
{
|
||||
if ($collapsed)
|
||||
{
|
||||
return FALSE; // multiple collapsed
|
||||
}
|
||||
|
||||
$collapsed = TRUE;
|
||||
}
|
||||
}
|
||||
elseif (preg_match("/[^0-9a-f]/i", $seg) OR strlen($seg) > 4)
|
||||
{
|
||||
return FALSE; // invalid segment
|
||||
}
|
||||
}
|
||||
|
||||
return $collapsed OR $groups == 1;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* User Agent
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
function user_agent()
|
||||
{
|
||||
if ($this->user_agent !== FALSE)
|
||||
{
|
||||
return $this->user_agent;
|
||||
}
|
||||
|
||||
$this->user_agent = ( ! isset($_SERVER['HTTP_USER_AGENT'])) ? FALSE : $_SERVER['HTTP_USER_AGENT'];
|
||||
|
||||
return $this->user_agent;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Sanitize Globals
|
||||
*
|
||||
* This function does the following:
|
||||
*
|
||||
* Unsets $_GET data (if query strings are not enabled)
|
||||
*
|
||||
* Unsets all globals if register_globals is enabled
|
||||
*
|
||||
* Standardizes newline characters to \n
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
function _sanitize_globals()
|
||||
{
|
||||
// It would be "wrong" to unset any of these GLOBALS.
|
||||
$protected = array('_SERVER', '_GET', '_POST', '_FILES', '_REQUEST',
|
||||
'_SESSION', '_ENV', 'GLOBALS', 'HTTP_RAW_POST_DATA',
|
||||
'system_folder', 'application_folder', 'BM', 'EXT',
|
||||
'CFG', 'URI', 'RTR', 'OUT', 'IN');
|
||||
|
||||
// Unset globals for securiy.
|
||||
// This is effectively the same as register_globals = off
|
||||
foreach (array($_GET, $_POST, $_COOKIE) as $global)
|
||||
{
|
||||
if ( ! is_array($global))
|
||||
{
|
||||
if ( ! in_array($global, $protected))
|
||||
{
|
||||
global $$global;
|
||||
$$global = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ($global as $key => $val)
|
||||
{
|
||||
if ( ! in_array($key, $protected))
|
||||
{
|
||||
global $$key;
|
||||
$$key = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Is $_GET data allowed? If not we'll set the $_GET to an empty array
|
||||
if ($this->_allow_get_array == FALSE)
|
||||
{
|
||||
$_GET = array();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_array($_GET) AND count($_GET) > 0)
|
||||
{
|
||||
foreach ($_GET as $key => $val)
|
||||
{
|
||||
$_GET[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Clean $_POST Data
|
||||
if (is_array($_POST) AND count($_POST) > 0)
|
||||
{
|
||||
foreach ($_POST as $key => $val)
|
||||
{
|
||||
$_POST[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
|
||||
}
|
||||
}
|
||||
|
||||
// Clean $_COOKIE Data
|
||||
if (is_array($_COOKIE) AND count($_COOKIE) > 0)
|
||||
{
|
||||
// Also get rid of specially treated cookies that might be set by a server
|
||||
// or silly application, that are of no use to a CI application anyway
|
||||
// but that when present will trip our 'Disallowed Key Characters' alarm
|
||||
// http://www.ietf.org/rfc/rfc2109.txt
|
||||
// note that the key names below are single quoted strings, and are not PHP variables
|
||||
unset($_COOKIE['$Version']);
|
||||
unset($_COOKIE['$Path']);
|
||||
unset($_COOKIE['$Domain']);
|
||||
|
||||
foreach ($_COOKIE as $key => $val)
|
||||
{
|
||||
$_COOKIE[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
|
||||
}
|
||||
}
|
||||
|
||||
// Sanitize PHP_SELF
|
||||
$_SERVER['PHP_SELF'] = strip_tags($_SERVER['PHP_SELF']);
|
||||
|
||||
|
||||
// CSRF Protection check on HTTP requests
|
||||
if ($this->_enable_csrf == TRUE && ! $this->is_cli_request())
|
||||
{
|
||||
$this->security->csrf_verify();
|
||||
}
|
||||
|
||||
log_message('debug', "Global POST and COOKIE data sanitized");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Clean Input Data
|
||||
*
|
||||
* This is a helper function. It escapes data and
|
||||
* standardizes newline characters to \n
|
||||
*
|
||||
* @access private
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function _clean_input_data($str)
|
||||
{
|
||||
if (is_array($str))
|
||||
{
|
||||
$new_array = array();
|
||||
foreach ($str as $key => $val)
|
||||
{
|
||||
$new_array[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
|
||||
}
|
||||
return $new_array;
|
||||
}
|
||||
|
||||
/* We strip slashes if magic quotes is on to keep things consistent
|
||||
|
||||
NOTE: In PHP 5.4 get_magic_quotes_gpc() will always return 0 and
|
||||
it will probably not exist in future versions at all.
|
||||
*/
|
||||
if ( ! is_php('5.4') && get_magic_quotes_gpc())
|
||||
{
|
||||
$str = stripslashes($str);
|
||||
}
|
||||
|
||||
// Clean UTF-8 if supported
|
||||
if (UTF8_ENABLED === TRUE)
|
||||
{
|
||||
$str = $this->uni->clean_string($str);
|
||||
}
|
||||
|
||||
// Remove control characters
|
||||
$str = remove_invisible_characters($str);
|
||||
|
||||
// Should we filter the input data?
|
||||
if ($this->_enable_xss === TRUE)
|
||||
{
|
||||
$str = $this->security->xss_clean($str);
|
||||
}
|
||||
|
||||
// Standardize newlines if needed
|
||||
if ($this->_standardize_newlines == TRUE)
|
||||
{
|
||||
if (strpos($str, "\r") !== FALSE)
|
||||
{
|
||||
$str = str_replace(array("\r\n", "\r", "\r\n\n"), PHP_EOL, $str);
|
||||
}
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Clean Keys
|
||||
*
|
||||
* This is a helper function. To prevent malicious users
|
||||
* from trying to exploit keys we make sure that keys are
|
||||
* only named with alpha-numeric text and a few other items.
|
||||
*
|
||||
* @access private
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function _clean_input_keys($str)
|
||||
{
|
||||
if ( ! preg_match("/^[%a-z0-9:_\/-]+$/i", $str))
|
||||
{
|
||||
throw new Exception("The key '$str' has disallowed characters.");
|
||||
}
|
||||
|
||||
// Clean UTF-8 if supported
|
||||
if (UTF8_ENABLED === TRUE)
|
||||
{
|
||||
$str = $this->uni->clean_string($str);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Request Headers
|
||||
*
|
||||
* In Apache, you can simply call apache_request_headers(), however for
|
||||
* people running other webservers the function is undefined.
|
||||
*
|
||||
* @param bool XSS cleaning
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function request_headers($xss_clean = FALSE)
|
||||
{
|
||||
// Look at Apache go!
|
||||
if (function_exists('apache_request_headers'))
|
||||
{
|
||||
$headers = apache_request_headers();
|
||||
}
|
||||
else
|
||||
{
|
||||
$headers['Content-Type'] = (isset($_SERVER['CONTENT_TYPE'])) ? $_SERVER['CONTENT_TYPE'] : @getenv('CONTENT_TYPE');
|
||||
|
||||
foreach ($_SERVER as $key => $val)
|
||||
{
|
||||
if (strncmp($key, 'HTTP_', 5) === 0)
|
||||
{
|
||||
$headers[substr($key, 5)] = $this->_fetch_from_array($_SERVER, $key, $xss_clean);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// take SOME_HEADER and turn it into Some-Header
|
||||
foreach ($headers as $key => $val)
|
||||
{
|
||||
$key = str_replace('_', ' ', strtolower($key));
|
||||
$key = str_replace(' ', '-', ucwords($key));
|
||||
|
||||
$this->headers[$key] = $val;
|
||||
}
|
||||
|
||||
return $this->headers;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Get Request Header
|
||||
*
|
||||
* Returns the value of a single member of the headers class member
|
||||
*
|
||||
* @param string array key for $this->headers
|
||||
* @param boolean XSS Clean or not
|
||||
* @return mixed FALSE on failure, string on success
|
||||
*/
|
||||
public function get_request_header($index, $xss_clean = FALSE)
|
||||
{
|
||||
if (empty($this->headers))
|
||||
{
|
||||
$this->request_headers();
|
||||
}
|
||||
|
||||
if ( ! isset($this->headers[$index]))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ($xss_clean === TRUE)
|
||||
{
|
||||
return $this->security->xss_clean($this->headers[$index]);
|
||||
}
|
||||
|
||||
return $this->headers[$index];
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Is ajax Request?
|
||||
*
|
||||
* Test to see if a request contains the HTTP_X_REQUESTED_WITH header
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_ajax_request()
|
||||
{
|
||||
return ($this->server('HTTP_X_REQUESTED_WITH') === 'XMLHttpRequest');
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Is cli Request?
|
||||
*
|
||||
* Test to see if a request was made from the command line
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_cli_request()
|
||||
{
|
||||
return (php_sapi_name() === 'cli' OR defined('STDIN'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* End of file Input.php */
|
||||
/* Location: ./system/core/Input.php */
|
||||
160
system/codeigniter/core/Lang.php
Executable file
160
system/codeigniter/core/Lang.php
Executable file
@@ -0,0 +1,160 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 5.1.6 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Language Class
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Libraries
|
||||
* @category Language
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/libraries/language.html
|
||||
*/
|
||||
class CI_Lang {
|
||||
|
||||
/**
|
||||
* List of translations
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $language = array();
|
||||
/**
|
||||
* List of loaded language files
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $is_loaded = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
log_message('debug', "Language Class Initialized");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Load a language file
|
||||
*
|
||||
* @access public
|
||||
* @param mixed the name of the language file to be loaded. Can be an array
|
||||
* @param string the language (english, etc.)
|
||||
* @param bool return loaded array of translations
|
||||
* @param bool add suffix to $langfile
|
||||
* @param string alternative path to look for language file
|
||||
* @return mixed
|
||||
*/
|
||||
function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')
|
||||
{
|
||||
$langfile = str_replace('.php', '', $langfile);
|
||||
|
||||
if ($add_suffix == TRUE)
|
||||
{
|
||||
$langfile = str_replace('_lang.', '', $langfile).'_lang';
|
||||
}
|
||||
|
||||
$langfile .= '.php';
|
||||
|
||||
if (in_array($langfile, $this->is_loaded, TRUE))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$config =& get_config();
|
||||
|
||||
if ($idiom == '')
|
||||
{
|
||||
$deft_lang = ( ! isset($config['language'])) ? 'english' : $config['language'];
|
||||
$idiom = ($deft_lang == '') ? 'english' : $deft_lang;
|
||||
}
|
||||
|
||||
// Determine where the language file is and load it
|
||||
if ($alt_path != '' && file_exists($alt_path.'language/'.$idiom.'/'.$langfile))
|
||||
{
|
||||
include($alt_path.'language/'.$idiom.'/'.$langfile);
|
||||
}
|
||||
else
|
||||
{
|
||||
$found = FALSE;
|
||||
|
||||
foreach (get_instance()->load->get_package_paths(TRUE) as $package_path)
|
||||
{
|
||||
if (file_exists($package_path.'language/'.$idiom.'/'.$langfile))
|
||||
{
|
||||
include($package_path.'language/'.$idiom.'/'.$langfile);
|
||||
$found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($found !== TRUE)
|
||||
{
|
||||
show_error('Unable to load the requested language file: language/'.$idiom.'/'.$langfile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( ! isset($lang))
|
||||
{
|
||||
log_message('error', 'Language file contains no data: language/'.$idiom.'/'.$langfile);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($return == TRUE)
|
||||
{
|
||||
return $lang;
|
||||
}
|
||||
|
||||
$this->is_loaded[] = $langfile;
|
||||
$this->language = array_merge($this->language, $lang);
|
||||
unset($lang);
|
||||
|
||||
log_message('debug', 'Language file loaded: language/'.$idiom.'/'.$langfile);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fetch a single line of text from the language array
|
||||
*
|
||||
* @access public
|
||||
* @param string $line the language line
|
||||
* @return string
|
||||
*/
|
||||
function line($line = '')
|
||||
{
|
||||
$value = ($line == '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line];
|
||||
|
||||
// Because killer robots like unicorns!
|
||||
if ($value === FALSE)
|
||||
{
|
||||
log_message('error', 'Could not find the language line "'.$line.'"');
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
}
|
||||
// END Language Class
|
||||
|
||||
/* End of file Lang.php */
|
||||
/* Location: ./system/core/Lang.php */
|
||||
1269
system/codeigniter/core/Loader.php
Executable file
1269
system/codeigniter/core/Loader.php
Executable file
File diff suppressed because it is too large
Load Diff
57
system/codeigniter/core/Model.php
Executable file
57
system/codeigniter/core/Model.php
Executable file
@@ -0,0 +1,57 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 5.1.6 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* CodeIgniter Model Class
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Libraries
|
||||
* @category Libraries
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/libraries/config.html
|
||||
*/
|
||||
class CI_Model {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
log_message('debug', "Model Class Initialized");
|
||||
}
|
||||
|
||||
/**
|
||||
* __get
|
||||
*
|
||||
* Allows models to access CI's loaded classes using the same
|
||||
* syntax as controllers.
|
||||
*
|
||||
* @param string
|
||||
* @access private
|
||||
*/
|
||||
function __get($key)
|
||||
{
|
||||
$CI =& get_instance();
|
||||
return $CI->$key;
|
||||
}
|
||||
}
|
||||
// END Model Class
|
||||
|
||||
/* End of file Model.php */
|
||||
/* Location: ./system/core/Model.php */
|
||||
574
system/codeigniter/core/Output.php
Executable file
574
system/codeigniter/core/Output.php
Executable file
@@ -0,0 +1,574 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 5.1.6 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Output Class
|
||||
*
|
||||
* Responsible for sending final output to browser
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Libraries
|
||||
* @category Output
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/libraries/output.html
|
||||
*/
|
||||
class CI_Output {
|
||||
|
||||
/**
|
||||
* Current output string
|
||||
*
|
||||
* @var string
|
||||
* @access protected
|
||||
*/
|
||||
protected $final_output;
|
||||
/**
|
||||
* Cache expiration time
|
||||
*
|
||||
* @var int
|
||||
* @access protected
|
||||
*/
|
||||
protected $cache_expiration = 0;
|
||||
/**
|
||||
* List of server headers
|
||||
*
|
||||
* @var array
|
||||
* @access protected
|
||||
*/
|
||||
protected $headers = array();
|
||||
/**
|
||||
* List of mime types
|
||||
*
|
||||
* @var array
|
||||
* @access protected
|
||||
*/
|
||||
protected $mime_types = array();
|
||||
/**
|
||||
* Determines wether profiler is enabled
|
||||
*
|
||||
* @var book
|
||||
* @access protected
|
||||
*/
|
||||
protected $enable_profiler = FALSE;
|
||||
/**
|
||||
* Determines if output compression is enabled
|
||||
*
|
||||
* @var bool
|
||||
* @access protected
|
||||
*/
|
||||
protected $_zlib_oc = FALSE;
|
||||
/**
|
||||
* List of profiler sections
|
||||
*
|
||||
* @var array
|
||||
* @access protected
|
||||
*/
|
||||
protected $_profiler_sections = array();
|
||||
/**
|
||||
* Whether or not to parse variables like {elapsed_time} and {memory_usage}
|
||||
*
|
||||
* @var bool
|
||||
* @access protected
|
||||
*/
|
||||
protected $parse_exec_vars = TRUE;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
$this->_zlib_oc = @ini_get('zlib.output_compression');
|
||||
|
||||
// Get mime types for later
|
||||
if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
|
||||
{
|
||||
include APPPATH.'config/'.ENVIRONMENT.'/mimes.php';
|
||||
}
|
||||
else
|
||||
{
|
||||
include APPPATH.'config/mimes.php';
|
||||
}
|
||||
|
||||
|
||||
$this->mime_types = $mimes;
|
||||
|
||||
log_message('debug', "Output Class Initialized");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Get Output
|
||||
*
|
||||
* Returns the current output string
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
function get_output()
|
||||
{
|
||||
return $this->final_output;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set Output
|
||||
*
|
||||
* Sets the output string
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return void
|
||||
*/
|
||||
function set_output($output)
|
||||
{
|
||||
$this->final_output = $output;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Append Output
|
||||
*
|
||||
* Appends data onto the output string
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return void
|
||||
*/
|
||||
function append_output($output)
|
||||
{
|
||||
if ($this->final_output == '')
|
||||
{
|
||||
$this->final_output = $output;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->final_output .= $output;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set Header
|
||||
*
|
||||
* Lets you set a server header which will be outputted with the final display.
|
||||
*
|
||||
* Note: If a file is cached, headers will not be sent. We need to figure out
|
||||
* how to permit header data to be saved with the cache data...
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param bool
|
||||
* @return void
|
||||
*/
|
||||
function set_header($header, $replace = TRUE)
|
||||
{
|
||||
// If zlib.output_compression is enabled it will compress the output,
|
||||
// but it will not modify the content-length header to compensate for
|
||||
// the reduction, causing the browser to hang waiting for more data.
|
||||
// We'll just skip content-length in those cases.
|
||||
|
||||
if ($this->_zlib_oc && strncasecmp($header, 'content-length', 14) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->headers[] = array($header, $replace);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set Content Type Header
|
||||
*
|
||||
* @access public
|
||||
* @param string extension of the file we're outputting
|
||||
* @return void
|
||||
*/
|
||||
function set_content_type($mime_type)
|
||||
{
|
||||
if (strpos($mime_type, '/') === FALSE)
|
||||
{
|
||||
$extension = ltrim($mime_type, '.');
|
||||
|
||||
// Is this extension supported?
|
||||
if (isset($this->mime_types[$extension]))
|
||||
{
|
||||
$mime_type =& $this->mime_types[$extension];
|
||||
|
||||
if (is_array($mime_type))
|
||||
{
|
||||
$mime_type = current($mime_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$header = 'Content-Type: '.$mime_type;
|
||||
|
||||
$this->headers[] = array($header, TRUE);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set HTTP Status Header
|
||||
* moved to Common procedural functions in 1.7.2
|
||||
*
|
||||
* @access public
|
||||
* @param int the status code
|
||||
* @param string
|
||||
* @return void
|
||||
*/
|
||||
function set_status_header($code = 200, $text = '')
|
||||
{
|
||||
set_status_header($code, $text);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Enable/disable Profiler
|
||||
*
|
||||
* @access public
|
||||
* @param bool
|
||||
* @return void
|
||||
*/
|
||||
function enable_profiler($val = TRUE)
|
||||
{
|
||||
$this->enable_profiler = (is_bool($val)) ? $val : TRUE;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set Profiler Sections
|
||||
*
|
||||
* Allows override of default / config settings for Profiler section display
|
||||
*
|
||||
* @access public
|
||||
* @param array
|
||||
* @return void
|
||||
*/
|
||||
function set_profiler_sections($sections)
|
||||
{
|
||||
foreach ($sections as $section => $enable)
|
||||
{
|
||||
$this->_profiler_sections[$section] = ($enable !== FALSE) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set Cache
|
||||
*
|
||||
* @access public
|
||||
* @param integer
|
||||
* @return void
|
||||
*/
|
||||
function cache($time)
|
||||
{
|
||||
$this->cache_expiration = ( ! is_numeric($time)) ? 0 : $time;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Display Output
|
||||
*
|
||||
* All "view" data is automatically put into this variable by the controller class:
|
||||
*
|
||||
* $this->final_output
|
||||
*
|
||||
* This function sends the finalized output data to the browser along
|
||||
* with any server headers and profile data. It also stops the
|
||||
* benchmark timer so the page rendering speed and memory usage can be shown.
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return mixed
|
||||
*/
|
||||
function _display($output = '')
|
||||
{
|
||||
// Note: We use globals because we can't use $CI =& get_instance()
|
||||
// since this function is sometimes called by the caching mechanism,
|
||||
// which happens before the CI super object is available.
|
||||
global $BM, $CFG;
|
||||
|
||||
// Grab the super object if we can.
|
||||
if (class_exists('CI_Controller'))
|
||||
{
|
||||
$CI =& get_instance();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
// Set the output data
|
||||
if ($output == '')
|
||||
{
|
||||
$output =& $this->final_output;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
// Do we need to write a cache file? Only if the controller does not have its
|
||||
// own _output() method and we are not dealing with a cache file, which we
|
||||
// can determine by the existence of the $CI object above
|
||||
if ($this->cache_expiration > 0 && isset($CI) && ! method_exists($CI, '_output'))
|
||||
{
|
||||
$this->_write_cache($output);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
// Parse out the elapsed time and memory usage,
|
||||
// then swap the pseudo-variables with the data
|
||||
|
||||
$elapsed = $BM->elapsed_time('total_execution_time_start', 'total_execution_time_end');
|
||||
|
||||
if ($this->parse_exec_vars === TRUE)
|
||||
{
|
||||
$memory = ( ! function_exists('memory_get_usage')) ? '0' : round(memory_get_usage()/1024/1024, 2).'MB';
|
||||
|
||||
$output = str_replace('{elapsed_time}', $elapsed, $output ?? "");
|
||||
$output = str_replace('{memory_usage}', $memory, $output);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
// Is compression requested?
|
||||
if ($CFG->item('compress_output') === TRUE && $this->_zlib_oc == FALSE)
|
||||
{
|
||||
if (extension_loaded('zlib'))
|
||||
{
|
||||
if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) AND strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE)
|
||||
{
|
||||
ob_start('ob_gzhandler');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
// Are there any server headers to send?
|
||||
if (count($this->headers) > 0)
|
||||
{
|
||||
foreach ($this->headers as $header)
|
||||
{
|
||||
@header($header[0], $header[1]);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
// Does the $CI object exist?
|
||||
// If not we know we are dealing with a cache file so we'll
|
||||
// simply echo out the data and exit.
|
||||
if ( ! isset($CI))
|
||||
{
|
||||
echo $output;
|
||||
log_message('debug', "Final output sent to browser");
|
||||
log_message('debug', "Total execution time: ".$elapsed);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
// Do we need to generate profile data?
|
||||
// If so, load the Profile class and run it.
|
||||
if ($this->enable_profiler == TRUE)
|
||||
{
|
||||
$CI->load->library('profiler');
|
||||
|
||||
if ( ! empty($this->_profiler_sections))
|
||||
{
|
||||
$CI->profiler->set_sections($this->_profiler_sections);
|
||||
}
|
||||
|
||||
// If the output data contains closing </body> and </html> tags
|
||||
// we will remove them and add them back after we insert the profile data
|
||||
if (preg_match("|</body>.*?</html>|is", $output))
|
||||
{
|
||||
$output = preg_replace("|</body>.*?</html>|is", '', $output);
|
||||
$output .= $CI->profiler->run();
|
||||
$output .= '</body></html>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$output .= $CI->profiler->run();
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
// Does the controller contain a function named _output()?
|
||||
// If so send the output there. Otherwise, echo it.
|
||||
if (method_exists($CI, '_output'))
|
||||
{
|
||||
$CI->_output($output);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo $output; // Send it to the browser!
|
||||
}
|
||||
|
||||
log_message('debug', "Final output sent to browser");
|
||||
log_message('debug', "Total execution time: ".$elapsed);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Write a Cache File
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return void
|
||||
*/
|
||||
function _write_cache($output)
|
||||
{
|
||||
$CI =& get_instance();
|
||||
$path = $CI->config->item('cache_path');
|
||||
|
||||
$cache_path = ($path == '') ? APPPATH.'cache/' : $path;
|
||||
|
||||
if ( ! is_dir($cache_path) OR ! is_really_writable($cache_path))
|
||||
{
|
||||
log_message('error', "Unable to write cache file: ".$cache_path);
|
||||
return;
|
||||
}
|
||||
|
||||
$uri = $CI->config->item('base_url').
|
||||
$CI->config->item('index_page').
|
||||
$CI->uri->uri_string();
|
||||
|
||||
$cache_path .= md5($uri);
|
||||
|
||||
if ( ! $fp = @fopen($cache_path, FOPEN_WRITE_CREATE_DESTRUCTIVE))
|
||||
{
|
||||
log_message('error', "Unable to write cache file: ".$cache_path);
|
||||
return;
|
||||
}
|
||||
|
||||
$expire = time() + ($this->cache_expiration * 60);
|
||||
|
||||
if (flock($fp, LOCK_EX))
|
||||
{
|
||||
fwrite($fp, $expire.'TS--->'.$output);
|
||||
flock($fp, LOCK_UN);
|
||||
}
|
||||
else
|
||||
{
|
||||
log_message('error', "Unable to secure a file lock for file at: ".$cache_path);
|
||||
return;
|
||||
}
|
||||
fclose($fp);
|
||||
@chmod($cache_path, FILE_WRITE_MODE);
|
||||
|
||||
log_message('debug', "Cache file written: ".$cache_path);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Update/serve a cached file
|
||||
*
|
||||
* @access public
|
||||
* @param object config class
|
||||
* @param object uri class
|
||||
* @return void
|
||||
*/
|
||||
function _display_cache(&$CFG, &$URI)
|
||||
{
|
||||
$cache_path = ($CFG->item('cache_path') == '') ? APPPATH.'cache/' : $CFG->item('cache_path');
|
||||
|
||||
// Build the file path. The file name is an MD5 hash of the full URI
|
||||
$uri = $CFG->item('base_url').
|
||||
$CFG->item('index_page').
|
||||
$URI->uri_string;
|
||||
|
||||
$filepath = $cache_path.md5($uri);
|
||||
|
||||
if ( ! @file_exists($filepath))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( ! $fp = @fopen($filepath, FOPEN_READ))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
flock($fp, LOCK_SH);
|
||||
|
||||
$cache = '';
|
||||
if (filesize($filepath) > 0)
|
||||
{
|
||||
$cache = fread($fp, filesize($filepath));
|
||||
}
|
||||
|
||||
flock($fp, LOCK_UN);
|
||||
fclose($fp);
|
||||
|
||||
// Strip out the embedded timestamp
|
||||
if ( ! preg_match("/(\d+TS--->)/", $cache, $match))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Has the file expired? If so we'll delete it.
|
||||
if (time() >= trim(str_replace('TS--->', '', $match['1'])))
|
||||
{
|
||||
if (is_really_writable($cache_path))
|
||||
{
|
||||
@unlink($filepath);
|
||||
log_message('debug', "Cache file has expired. File deleted");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// Display the cache
|
||||
$this->_display(str_replace($match['0'], '', $cache));
|
||||
log_message('debug', "Cache file is current. Sending it to browser.");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// END Output Class
|
||||
|
||||
/* End of file Output.php */
|
||||
/* Location: ./system/core/Output.php */
|
||||
529
system/codeigniter/core/Router.php
Executable file
529
system/codeigniter/core/Router.php
Executable file
@@ -0,0 +1,529 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 5.1.6 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Router Class
|
||||
*
|
||||
* Parses URIs and determines routing
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Libraries
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @category Libraries
|
||||
* @link http://codeigniter.com/user_guide/general/routing.html
|
||||
*/
|
||||
class CI_Router {
|
||||
|
||||
/**
|
||||
* CI_URI class object
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
public $uri;
|
||||
|
||||
/**
|
||||
* Config class
|
||||
*
|
||||
* @var object
|
||||
* @access public
|
||||
*/
|
||||
var $config;
|
||||
/**
|
||||
* List of routes
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $routes = array();
|
||||
/**
|
||||
* List of error routes
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $error_routes = array();
|
||||
/**
|
||||
* Current class name
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
var $class = '';
|
||||
/**
|
||||
* Current method name
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
var $method = 'index';
|
||||
/**
|
||||
* Sub-directory that contains the requested controller class
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
var $directory = '';
|
||||
/**
|
||||
* Default controller (and method if specific)
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
var $default_controller;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Runs the route mapping function.
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
$this->config =& load_class('Config', 'core');
|
||||
$this->uri =& load_class('URI', 'core');
|
||||
log_message('debug', "Router Class Initialized");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set the route mapping
|
||||
*
|
||||
* This function determines what should be served based on the URI request,
|
||||
* as well as any "routes" that have been set in the routing config file.
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
function _set_routing()
|
||||
{
|
||||
// Are query strings enabled in the config file? Normally CI doesn't utilize query strings
|
||||
// since URI segments are more search-engine friendly, but they can optionally be used.
|
||||
// If this feature is enabled, we will gather the directory/class/method a little differently
|
||||
$segments = array();
|
||||
if ($this->config->item('enable_query_strings') === TRUE AND isset($_GET[$this->config->item('controller_trigger')]))
|
||||
{
|
||||
if (isset($_GET[$this->config->item('directory_trigger')]))
|
||||
{
|
||||
$this->set_directory(trim($this->uri->_filter_uri($_GET[$this->config->item('directory_trigger')])));
|
||||
$segments[] = $this->fetch_directory();
|
||||
}
|
||||
|
||||
if (isset($_GET[$this->config->item('controller_trigger')]))
|
||||
{
|
||||
$this->set_class(trim($this->uri->_filter_uri($_GET[$this->config->item('controller_trigger')])));
|
||||
$segments[] = $this->fetch_class();
|
||||
}
|
||||
|
||||
if (isset($_GET[$this->config->item('function_trigger')]))
|
||||
{
|
||||
$this->set_method(trim($this->uri->_filter_uri($_GET[$this->config->item('function_trigger')])));
|
||||
$segments[] = $this->fetch_method();
|
||||
}
|
||||
}
|
||||
|
||||
// Load the routes.php file.
|
||||
if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/routes.php'))
|
||||
{
|
||||
include(APPPATH.'config/'.ENVIRONMENT.'/routes.php');
|
||||
}
|
||||
elseif (is_file(APPPATH.'config/routes.php'))
|
||||
{
|
||||
include(APPPATH.'config/routes.php');
|
||||
}
|
||||
|
||||
$this->routes = ( ! isset($route) OR ! is_array($route)) ? array() : $route;
|
||||
unset($route);
|
||||
|
||||
// Set the default controller so we can display it in the event
|
||||
// the URI doesn't correlated to a valid controller.
|
||||
$this->default_controller = ( ! isset($this->routes['default_controller']) OR $this->routes['default_controller'] == '') ? FALSE : strtolower($this->routes['default_controller']);
|
||||
|
||||
// Were there any query string segments? If so, we'll validate them and bail out since we're done.
|
||||
if (count($segments) > 0)
|
||||
{
|
||||
return $this->_validate_request($segments);
|
||||
}
|
||||
|
||||
// Fetch the complete URI string
|
||||
$this->uri->_fetch_uri_string();
|
||||
|
||||
// Is there a URI string? If not, the default controller specified in the "routes" file will be shown.
|
||||
if ($this->uri->uri_string == '')
|
||||
{
|
||||
return $this->_set_default_controller();
|
||||
}
|
||||
|
||||
// Do we need to remove the URL suffix?
|
||||
$this->uri->_remove_url_suffix();
|
||||
|
||||
// Compile the segments into an array
|
||||
$this->uri->_explode_segments();
|
||||
|
||||
// Parse any custom routing that may exist
|
||||
$this->_parse_routes();
|
||||
|
||||
// Re-index the segment array so that it starts with 1 rather than 0
|
||||
$this->uri->_reindex_segments();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set the default controller
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
function _set_default_controller()
|
||||
{
|
||||
if ($this->default_controller === FALSE)
|
||||
{
|
||||
show_error("Unable to determine what should be displayed. A default route has not been specified in the routing file.");
|
||||
}
|
||||
// Is the method being specified?
|
||||
if (strpos($this->default_controller, '/') !== FALSE)
|
||||
{
|
||||
$x = explode('/', $this->default_controller);
|
||||
|
||||
$this->set_class($x[0]);
|
||||
$this->set_method($x[1]);
|
||||
$this->_set_request($x);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->set_class($this->default_controller);
|
||||
$this->set_method('index');
|
||||
$this->_set_request(array($this->default_controller, 'index'));
|
||||
}
|
||||
|
||||
// re-index the routed segments array so it starts with 1 rather than 0
|
||||
$this->uri->_reindex_segments();
|
||||
|
||||
log_message('debug', "No URI present. Default controller set.");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set the Route
|
||||
*
|
||||
* This function takes an array of URI segments as
|
||||
* input, and sets the current class/method
|
||||
*
|
||||
* @access private
|
||||
* @param array
|
||||
* @param bool
|
||||
* @return void
|
||||
*/
|
||||
function _set_request($segments = array())
|
||||
{
|
||||
$segments = $this->_validate_request($segments);
|
||||
|
||||
if (count($segments) == 0)
|
||||
{
|
||||
return $this->_set_default_controller();
|
||||
}
|
||||
|
||||
$this->set_class($segments[0]);
|
||||
|
||||
if (isset($segments[1]))
|
||||
{
|
||||
// A standard method request
|
||||
$this->set_method($segments[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
// This lets the "routed" segment array identify that the default
|
||||
// index method is being used.
|
||||
$segments[1] = 'index';
|
||||
}
|
||||
|
||||
// Update our "routed" segment array to contain the segments.
|
||||
// Note: If there is no custom routing, this array will be
|
||||
// identical to $this->uri->segments
|
||||
$this->uri->rsegments = $segments;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Validates the supplied segments. Attempts to determine the path to
|
||||
* the controller.
|
||||
*
|
||||
* @access private
|
||||
* @param array
|
||||
* @return array
|
||||
*/
|
||||
function _validate_request($segments)
|
||||
{
|
||||
if (count($segments) == 0)
|
||||
{
|
||||
return $segments;
|
||||
}
|
||||
|
||||
// Does the requested controller exist in the root folder?
|
||||
if (file_exists(APPPATH.'controllers/'.$segments[0].'.php'))
|
||||
{
|
||||
return $segments;
|
||||
}
|
||||
|
||||
// Is the controller in a sub-folder?
|
||||
if (is_dir(APPPATH.'controllers/'.$segments[0]))
|
||||
{
|
||||
// Set the directory and remove it from the segment array
|
||||
$this->set_directory($segments[0]);
|
||||
$segments = array_slice($segments, 1);
|
||||
|
||||
if (count($segments) > 0)
|
||||
{
|
||||
// Does the requested controller exist in the sub-folder?
|
||||
if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$segments[0].'.php'))
|
||||
{
|
||||
if ( ! empty($this->routes['404_override']))
|
||||
{
|
||||
$x = explode('/', $this->routes['404_override']);
|
||||
|
||||
$this->set_directory('');
|
||||
$this->set_class($x[0]);
|
||||
$this->set_method(isset($x[1]) ? $x[1] : 'index');
|
||||
|
||||
return $x;
|
||||
}
|
||||
else
|
||||
{
|
||||
show_404($this->fetch_directory().$segments[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Is the method being specified in the route?
|
||||
if (strpos($this->default_controller, '/') !== FALSE)
|
||||
{
|
||||
$x = explode('/', $this->default_controller);
|
||||
|
||||
$this->set_class($x[0]);
|
||||
$this->set_method($x[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->set_class($this->default_controller);
|
||||
$this->set_method('index');
|
||||
}
|
||||
|
||||
// Does the default controller exist in the sub-folder?
|
||||
if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$this->default_controller.'.php'))
|
||||
{
|
||||
$this->directory = '';
|
||||
return array();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $segments;
|
||||
}
|
||||
|
||||
|
||||
// If we've gotten this far it means that the URI does not correlate to a valid
|
||||
// controller class. We will now see if there is an override
|
||||
if ( ! empty($this->routes['404_override']))
|
||||
{
|
||||
$x = explode('/', $this->routes['404_override']);
|
||||
|
||||
$this->set_class($x[0]);
|
||||
$this->set_method(isset($x[1]) ? $x[1] : 'index');
|
||||
|
||||
return $x;
|
||||
}
|
||||
|
||||
|
||||
// Nothing else to do at this point but show a 404
|
||||
show_404($segments[0]);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Parse Routes
|
||||
*
|
||||
* This function matches any routes that may exist in
|
||||
* the config/routes.php file against the URI to
|
||||
* determine if the class/method need to be remapped.
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
function _parse_routes()
|
||||
{
|
||||
// Turn the segment array into a URI string
|
||||
$uri = implode('/', $this->uri->segments);
|
||||
|
||||
// Is there a literal match? If so we're done
|
||||
if (isset($this->routes[$uri]))
|
||||
{
|
||||
return $this->_set_request(explode('/', $this->routes[$uri]));
|
||||
}
|
||||
|
||||
// Loop through the route array looking for wild-cards
|
||||
foreach ($this->routes as $key => $val)
|
||||
{
|
||||
// Convert wild-cards to RegEx
|
||||
$key = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key));
|
||||
|
||||
// Does the RegEx match?
|
||||
if (preg_match('#^'.$key.'$#', $uri))
|
||||
{
|
||||
// Do we have a back-reference?
|
||||
if (strpos($val, '$') !== FALSE AND strpos($key, '(') !== FALSE)
|
||||
{
|
||||
$val = preg_replace('#^'.$key.'$#', $val, $uri);
|
||||
}
|
||||
|
||||
return $this->_set_request(explode('/', $val));
|
||||
}
|
||||
}
|
||||
|
||||
// If we got this far it means we didn't encounter a
|
||||
// matching route so we'll set the site default route
|
||||
$this->_set_request($this->uri->segments);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set the class name
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return void
|
||||
*/
|
||||
function set_class($class)
|
||||
{
|
||||
$this->class = str_replace(array('/', '.'), '', $class);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fetch the current class
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
function fetch_class()
|
||||
{
|
||||
return $this->class;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set the method name
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return void
|
||||
*/
|
||||
function set_method($method)
|
||||
{
|
||||
$this->method = $method;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fetch the current method
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
function fetch_method()
|
||||
{
|
||||
if ($this->method == $this->fetch_class())
|
||||
{
|
||||
return 'index';
|
||||
}
|
||||
|
||||
return $this->method;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set the directory name
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return void
|
||||
*/
|
||||
function set_directory($dir)
|
||||
{
|
||||
$this->directory = str_replace(array('/', '.'), '', $dir).'/';
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fetch the sub-directory (if any) that contains the requested controller class
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
function fetch_directory()
|
||||
{
|
||||
return $this->directory;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set the controller overrides
|
||||
*
|
||||
* @access public
|
||||
* @param array
|
||||
* @return null
|
||||
*/
|
||||
function _set_overrides($routing)
|
||||
{
|
||||
if ( ! is_array($routing))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($routing['directory']))
|
||||
{
|
||||
$this->set_directory($routing['directory']);
|
||||
}
|
||||
|
||||
if (isset($routing['controller']) AND $routing['controller'] != '')
|
||||
{
|
||||
$this->set_class($routing['controller']);
|
||||
}
|
||||
|
||||
if (isset($routing['function']))
|
||||
{
|
||||
$routing['function'] = ($routing['function'] == '') ? 'index' : $routing['function'];
|
||||
$this->set_method($routing['function']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// END Router Class
|
||||
|
||||
/* End of file Router.php */
|
||||
/* Location: ./system/core/Router.php */
|
||||
1
system/codeigniter/core/Security.php
Executable file
1
system/codeigniter/core/Security.php
Executable file
File diff suppressed because one or more lines are too long
594
system/codeigniter/core/URI.php
Executable file
594
system/codeigniter/core/URI.php
Executable file
@@ -0,0 +1,594 @@
|
||||
<?php
|
||||
/**
|
||||
* CodeIgniter
|
||||
* An open source application development framework for PHP
|
||||
* This content is released under the MIT License (MIT)
|
||||
* Copyright (c) 2014 - 2017, British Columbia Institute of Technology
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
* @filesource
|
||||
*/
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* URI Class
|
||||
* Parses URIs and determines routing
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Libraries
|
||||
* @category URI
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/uri.html
|
||||
*/
|
||||
class CI_URI {
|
||||
|
||||
/**
|
||||
* CI_Config instance
|
||||
*
|
||||
* @var CI_Config
|
||||
*/
|
||||
public $config;
|
||||
|
||||
/**
|
||||
* List of cached URI segments
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $keyval = array();
|
||||
|
||||
/**
|
||||
* Current URI string
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $uri_string = '';
|
||||
|
||||
/**
|
||||
* List of URI segments
|
||||
* Starts at 1 instead of 0.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $segments = array();
|
||||
|
||||
/**
|
||||
* List of routed URI segments
|
||||
* Starts at 1 instead of 0.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $rsegments = array();
|
||||
|
||||
/**
|
||||
* Permitted URI chars
|
||||
* PCRE character group allowed in URI segments
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_permitted_uri_chars;
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(CI_Config $config) {
|
||||
$this->config = $config;
|
||||
|
||||
// If it's a CLI request, ignore the configuration
|
||||
if (is_cli()) {
|
||||
$this->_set_uri_string($this->_parse_argv(), true);
|
||||
} // If query strings are enabled, we don't need to parse any segments.
|
||||
elseif ($this->config->item('enable_query_strings') !== true) {
|
||||
$this->_permitted_uri_chars = $this->config->item('permitted_uri_chars');
|
||||
$protocol = $this->config->item('uri_protocol');
|
||||
empty($protocol) && $protocol = 'REQUEST_URI';
|
||||
|
||||
switch ($protocol) {
|
||||
case 'AUTO': // For BC purposes only
|
||||
case 'REQUEST_URI':
|
||||
$uri = $this->_parse_request_uri();
|
||||
break;
|
||||
case 'QUERY_STRING':
|
||||
$uri = $this->_parse_query_string();
|
||||
break;
|
||||
case 'PATH_INFO':
|
||||
default:
|
||||
$uri = isset($_SERVER[$protocol])
|
||||
? $_SERVER[$protocol]
|
||||
: $this->_parse_request_uri();
|
||||
break;
|
||||
}
|
||||
|
||||
$this->_set_uri_string($uri, false);
|
||||
}
|
||||
|
||||
log_message('info', 'URI Class Initialized');
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set URI String
|
||||
*
|
||||
* @param string $str Input URI string
|
||||
* @param bool $is_cli Whether the input comes from CLI
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _set_uri_string($str, $is_cli = false) {
|
||||
// CLI requests have a bit simpler logic
|
||||
if ($is_cli) {
|
||||
if (($this->uri_string = trim($str, '/')) === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->segments[0] = null;
|
||||
foreach (explode('/', $this->uri_string) as $segment) {
|
||||
if (($segment = trim($segment)) !== '') {
|
||||
$this->segments[] = $segment;
|
||||
}
|
||||
}
|
||||
|
||||
unset($this->segments[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
// Filter out control characters and trim slashes
|
||||
$this->uri_string = trim(remove_invisible_characters($str, false), '/');
|
||||
|
||||
if ($this->uri_string === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove the URL suffix, if present
|
||||
if (($suffix = (string) $this->config->item('url_suffix')) !== '') {
|
||||
$slen = strlen($suffix);
|
||||
|
||||
if (substr($this->uri_string, -$slen) === $suffix) {
|
||||
$this->uri_string = substr($this->uri_string, 0, -$slen);
|
||||
}
|
||||
}
|
||||
|
||||
$this->segments[0] = null;
|
||||
foreach (explode('/', trim($this->uri_string, '/')) as $segment) {
|
||||
$segment = trim($segment);
|
||||
// Filter segments for security
|
||||
$this->filter_uri($segment);
|
||||
|
||||
if ($segment !== '') {
|
||||
$this->segments[] = $segment;
|
||||
}
|
||||
}
|
||||
|
||||
unset($this->segments[0]);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Parse REQUEST_URI
|
||||
* Will parse REQUEST_URI and automatically detect the URI from it,
|
||||
* while fixing the query string if necessary.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _parse_request_uri() {
|
||||
if (!isset($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME'])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// parse_url() returns false if no host is present, but the path or query string
|
||||
// contains a colon followed by a number
|
||||
$uri = parse_url('http://dummy' . $_SERVER['REQUEST_URI']);
|
||||
$query = isset($uri['query']) ? $uri['query'] : '';
|
||||
$uri = isset($uri['path']) ? $uri['path'] : '';
|
||||
|
||||
if (isset($_SERVER['SCRIPT_NAME'][0])) {
|
||||
if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0) {
|
||||
$uri = (string) substr($uri, strlen($_SERVER['SCRIPT_NAME']));
|
||||
} elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0) {
|
||||
$uri = (string) substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME'])));
|
||||
}
|
||||
}
|
||||
|
||||
// This section ensures that even on servers that require the URI to be in the query string (Nginx) a correct
|
||||
// URI is found, and also fixes the QUERY_STRING server var and $_GET array.
|
||||
if (trim($uri, '/') === '' && strncmp($query, '/', 1) === 0) {
|
||||
$query = explode('?', $query, 2);
|
||||
$uri = $query[0];
|
||||
$_SERVER['QUERY_STRING'] = isset($query[1]) ? $query[1] : '';
|
||||
} else {
|
||||
$_SERVER['QUERY_STRING'] = $query;
|
||||
}
|
||||
|
||||
parse_str($_SERVER['QUERY_STRING'], $_GET);
|
||||
|
||||
if ($uri === '/' OR $uri === '') {
|
||||
return '/';
|
||||
}
|
||||
|
||||
// Do some final cleaning of the URI and return it
|
||||
return $this->_remove_relative_directory($uri);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Parse QUERY_STRING
|
||||
* Will parse QUERY_STRING and automatically detect the URI from it.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _parse_query_string() {
|
||||
$uri = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING');
|
||||
|
||||
if (trim($uri, '/') === '') {
|
||||
return '';
|
||||
} elseif (strncmp($uri, '/', 1) === 0) {
|
||||
$uri = explode('?', $uri, 2);
|
||||
$_SERVER['QUERY_STRING'] = isset($uri[1]) ? $uri[1] : '';
|
||||
$uri = $uri[0];
|
||||
}
|
||||
|
||||
parse_str($_SERVER['QUERY_STRING'], $_GET);
|
||||
|
||||
return $this->_remove_relative_directory($uri);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Parse CLI arguments
|
||||
* Take each command line argument and assume it is a URI segment.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _parse_argv() {
|
||||
$args = array_slice($_SERVER['argv'], 1);
|
||||
return $args ? implode('/', $args) : '';
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Remove relative directory (../) and multi slashes (///)
|
||||
* Do some final cleaning of the URI and return it, currently only used in self::_parse_request_uri()
|
||||
*
|
||||
* @param string $uri
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _remove_relative_directory($uri) {
|
||||
$uris = array();
|
||||
$tok = strtok($uri, '/');
|
||||
while ($tok !== false) {
|
||||
if ((!empty($tok) OR $tok === '0') && $tok !== '..') {
|
||||
$uris[] = $tok;
|
||||
}
|
||||
$tok = strtok('/');
|
||||
}
|
||||
|
||||
return implode('/', $uris);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Filter URI
|
||||
* Filters segments for malicious characters.
|
||||
*
|
||||
* @param string $str
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function filter_uri(&$str) {
|
||||
if (!empty($str) && !empty($this->_permitted_uri_chars) && !preg_match('/^[' . $this->_permitted_uri_chars . ']+$/i' . (UTF8_ENABLED ? 'u' : ''), $str)) {
|
||||
show_error('The URI you submitted has disallowed characters.', 400);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fetch URI Segment
|
||||
*
|
||||
* @see CI_URI::$segments
|
||||
*
|
||||
* @param int $n Index
|
||||
* @param mixed $no_result What to return if the segment index is not found
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function segment($n, $no_result = null) {
|
||||
return isset($this->segments[$n]) ? $this->segments[$n] : $no_result;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fetch URI "routed" Segment
|
||||
* Returns the re-routed URI segment (assuming routing rules are used)
|
||||
* based on the index provided. If there is no routing, will return
|
||||
* the same result as CI_URI::segment().
|
||||
*
|
||||
* @see CI_URI::$rsegments
|
||||
* @see CI_URI::segment()
|
||||
*
|
||||
* @param int $n Index
|
||||
* @param mixed $no_result What to return if the segment index is not found
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function rsegment($n, $no_result = null) {
|
||||
return isset($this->rsegments[$n]) ? $this->rsegments[$n] : $no_result;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* URI to assoc
|
||||
* Generates an associative array of URI data starting at the supplied
|
||||
* segment index. For example, if this is your URI:
|
||||
* example.com/user/search/name/joe/location/UK/gender/male
|
||||
* You can use this method to generate an array with this prototype:
|
||||
* array (
|
||||
* name => joe
|
||||
* location => UK
|
||||
* gender => male
|
||||
* )
|
||||
*
|
||||
* @param int $n Index (default: 3)
|
||||
* @param array $default Default values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function uri_to_assoc($n = 3, $default = array()) {
|
||||
return $this->_uri_to_assoc($n, $default, 'segment');
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Routed URI to assoc
|
||||
* Identical to CI_URI::uri_to_assoc(), only it uses the re-routed
|
||||
* segment array.
|
||||
*
|
||||
* @see CI_URI::uri_to_assoc()
|
||||
*
|
||||
* @param int $n Index (default: 3)
|
||||
* @param array $default Default values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function ruri_to_assoc($n = 3, $default = array()) {
|
||||
return $this->_uri_to_assoc($n, $default, 'rsegment');
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Internal URI-to-assoc
|
||||
* Generates a key/value pair from the URI string or re-routed URI string.
|
||||
*
|
||||
* @used-by CI_URI::uri_to_assoc()
|
||||
* @used-by CI_URI::ruri_to_assoc()
|
||||
*
|
||||
* @param int $n Index (default: 3)
|
||||
* @param array $default Default values
|
||||
* @param string $which Array name ('segment' or 'rsegment')
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function _uri_to_assoc($n = 3, $default = array(), $which = 'segment') {
|
||||
if (!is_numeric($n)) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
if (isset($this->keyval[$which], $this->keyval[$which][$n])) {
|
||||
return $this->keyval[$which][$n];
|
||||
}
|
||||
|
||||
$total_segments = "total_{$which}s";
|
||||
$segment_array = "{$which}_array";
|
||||
|
||||
if ($this->$total_segments() < $n) {
|
||||
return (count($default) === 0)
|
||||
? array()
|
||||
: array_fill_keys($default, null);
|
||||
}
|
||||
|
||||
$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] = null;
|
||||
$lastval = $seg;
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
if (count($default) > 0) {
|
||||
foreach ($default as $val) {
|
||||
if (!array_key_exists($val, $retval)) {
|
||||
$retval[$val] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Cache the array for reuse
|
||||
isset($this->keyval[$which]) OR $this->keyval[$which] = array();
|
||||
$this->keyval[$which][$n] = $retval;
|
||||
return $retval;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Assoc to URI
|
||||
* Generates a URI string from an associative array.
|
||||
*
|
||||
* @param array $array Input array of key/value pairs
|
||||
*
|
||||
* @return string URI string
|
||||
*/
|
||||
public function assoc_to_uri($array) {
|
||||
$temp = array();
|
||||
foreach ((array) $array as $key => $val) {
|
||||
$temp[] = $key;
|
||||
$temp[] = $val;
|
||||
}
|
||||
|
||||
return implode('/', $temp);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Slash segment
|
||||
* Fetches an URI segment with a slash.
|
||||
*
|
||||
* @param int $n Index
|
||||
* @param string $where Where to add the slash ('trailing' or 'leading')
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function slash_segment($n, $where = 'trailing') {
|
||||
return $this->_slash_segment($n, $where, 'segment');
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Slash routed segment
|
||||
* Fetches an URI routed segment with a slash.
|
||||
*
|
||||
* @param int $n Index
|
||||
* @param string $where Where to add the slash ('trailing' or 'leading')
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function slash_rsegment($n, $where = 'trailing') {
|
||||
return $this->_slash_segment($n, $where, 'rsegment');
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Internal Slash segment
|
||||
* Fetches an URI Segment and adds a slash to it.
|
||||
*
|
||||
* @used-by CI_URI::slash_segment()
|
||||
* @used-by CI_URI::slash_rsegment()
|
||||
*
|
||||
* @param int $n Index
|
||||
* @param string $where Where to add the slash ('trailing' or 'leading')
|
||||
* @param string $which Array name ('segment' or 'rsegment')
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _slash_segment($n, $where = 'trailing', $which = 'segment') {
|
||||
$leading = $trailing = '/';
|
||||
|
||||
if ($where === 'trailing') {
|
||||
$leading = '';
|
||||
} elseif ($where === 'leading') {
|
||||
$trailing = '';
|
||||
}
|
||||
|
||||
return $leading . $this->$which($n) . $trailing;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Segment Array
|
||||
*
|
||||
* @return array CI_URI::$segments
|
||||
*/
|
||||
public function segment_array() {
|
||||
return $this->segments;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Routed Segment Array
|
||||
*
|
||||
* @return array CI_URI::$rsegments
|
||||
*/
|
||||
public function rsegment_array() {
|
||||
return $this->rsegments;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Total number of segments
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function total_segments() {
|
||||
return count($this->segments);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Total number of routed segments
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function total_rsegments() {
|
||||
return count($this->rsegments);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fetch URI string
|
||||
*
|
||||
* @return string CI_URI::$uri_string
|
||||
*/
|
||||
public function uri_string() {
|
||||
return $this->uri_string;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fetch Re-routed URI string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function ruri_string() {
|
||||
return ltrim(load_class('Router', 'core')->directory, '/') . implode('/', $this->rsegments);
|
||||
}
|
||||
|
||||
}
|
||||
181
system/codeigniter/core/Utf8.php
Executable file
181
system/codeigniter/core/Utf8.php
Executable file
@@ -0,0 +1,181 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP 5.1.6 or newer
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
|
||||
* @license http://codeigniter.com/user_guide/license.html
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 2.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Utf8 Class
|
||||
*
|
||||
* Provides support for UTF-8 environments
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Libraries
|
||||
* @category UTF-8
|
||||
* @author ExpressionEngine Dev Team
|
||||
* @link http://codeigniter.com/user_guide/libraries/utf8.html
|
||||
*/
|
||||
class CI_Utf8 {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Determines if UTF-8 support is to be enabled
|
||||
*
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
log_message('debug', "Utf8 Class Initialized");
|
||||
|
||||
global $CFG;
|
||||
|
||||
# Use MB when iconv is not supported.
|
||||
# This fixes an issue that was causing problems with PHP installations that had MB but not ICONV.
|
||||
# - Bruno
|
||||
if (!function_exists('iconv') and extension_loaded('mbstring') && preg_match('/./u', 'é') === 1 && ini_get('mbstring.func_overload') != 1 && $CFG->item('charset') == 'UTF-8') {
|
||||
log_message('debug', "UTF-8 Support Enabled");
|
||||
define('UTF8_ENABLED', true);
|
||||
define('MB_ENABLED', TRUE);
|
||||
mb_internal_encoding('UTF-8');
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
preg_match('/./u', 'é') === 1 // PCRE must support UTF-8
|
||||
AND function_exists('iconv') // iconv must be installed
|
||||
AND ini_get('mbstring.func_overload') != 1 // Multibyte string function overloading cannot be enabled
|
||||
AND $CFG->item('charset') == 'UTF-8' // Application charset must be UTF-8
|
||||
)
|
||||
{
|
||||
log_message('debug', "UTF-8 Support Enabled");
|
||||
|
||||
define('UTF8_ENABLED', TRUE);
|
||||
|
||||
// set internal encoding for multibyte string functions if necessary
|
||||
// and set a flag so we don't have to repeatedly use extension_loaded()
|
||||
// or function_exists()
|
||||
if (extension_loaded('mbstring'))
|
||||
{
|
||||
define('MB_ENABLED', TRUE);
|
||||
mb_internal_encoding('UTF-8');
|
||||
}
|
||||
else
|
||||
{
|
||||
define('MB_ENABLED', FALSE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log_message('debug', "UTF-8 Support Disabled");
|
||||
define('UTF8_ENABLED', FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Clean UTF-8 strings
|
||||
*
|
||||
* Ensures strings are UTF-8
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function clean_string($str)
|
||||
{
|
||||
if ($this->_is_ascii($str) === FALSE)
|
||||
{
|
||||
if (function_exists('mb_substitute_character')) {
|
||||
mb_substitute_character(0xFFFD);
|
||||
$str = mb_convert_encoding($str, 'UTF-8', 'UTF-8');
|
||||
} else {
|
||||
$str = @iconv('UTF-8', 'UTF-8//IGNORE', $str);
|
||||
}
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Remove ASCII control characters
|
||||
*
|
||||
* Removes all ASCII control characters except horizontal tabs,
|
||||
* line feeds, and carriage returns, as all others can cause
|
||||
* problems in XML
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function safe_ascii_for_xml($str)
|
||||
{
|
||||
return remove_invisible_characters($str, FALSE);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Convert to UTF-8
|
||||
*
|
||||
* Attempts to convert a string to UTF-8
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @param string - input encoding
|
||||
* @return string
|
||||
*/
|
||||
function convert_to_utf8($str, $encoding)
|
||||
{
|
||||
if (function_exists('iconv'))
|
||||
{
|
||||
$str = @iconv($encoding, 'UTF-8', $str);
|
||||
}
|
||||
elseif (function_exists('mb_convert_encoding'))
|
||||
{
|
||||
$str = @mb_convert_encoding($str, 'UTF-8', $encoding);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Is ASCII?
|
||||
*
|
||||
* Tests if a string is standard 7-bit ASCII or not
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return bool
|
||||
*/
|
||||
function _is_ascii($str)
|
||||
{
|
||||
return (preg_match('/[^\x00-\x7F]/S', $str) == 0);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
}
|
||||
// End Utf8 Class
|
||||
|
||||
/* End of file Utf8.php */
|
||||
/* Location: ./system/core/Utf8.php */
|
||||
10
system/codeigniter/core/index.html
Executable file
10
system/codeigniter/core/index.html
Executable file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
225
system/codeigniter/database/DB.php
Executable file
225
system/codeigniter/database/DB.php
Executable file
@@ -0,0 +1,225 @@
|
||||
<?php
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
* @filesource
|
||||
*/
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Initialize the database
|
||||
*
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
*
|
||||
* @param string|string[] $params
|
||||
* @param bool $query_builder_override
|
||||
* Determines if query builder should be used or not
|
||||
*/
|
||||
function &DB($params = '', $query_builder_override = NULL)
|
||||
{
|
||||
// Load the DB config file if a DSN string wasn't passed
|
||||
if (is_string($params) && strpos($params, '://') === FALSE)
|
||||
{
|
||||
// Is the config file in the environment folder?
|
||||
if ( ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/database.php')
|
||||
&& ! file_exists($file_path = APPPATH.'config/database.php'))
|
||||
{
|
||||
show_error('The configuration file database.php does not exist.');
|
||||
}
|
||||
|
||||
include($file_path);
|
||||
|
||||
// Make packages contain database config files,
|
||||
// given that the controller instance already exists
|
||||
if (class_exists('CI_Controller', FALSE))
|
||||
{
|
||||
foreach (get_instance()->load->get_package_paths() as $path)
|
||||
{
|
||||
if ($path !== APPPATH)
|
||||
{
|
||||
if (file_exists($file_path = $path.'config/'.ENVIRONMENT.'/database.php'))
|
||||
{
|
||||
include($file_path);
|
||||
}
|
||||
elseif (file_exists($file_path = $path.'config/database.php'))
|
||||
{
|
||||
include($file_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! isset($db) OR count($db) === 0)
|
||||
{
|
||||
show_error('No database connection settings were found in the database config file.');
|
||||
}
|
||||
|
||||
if ($params !== '')
|
||||
{
|
||||
$active_group = $params;
|
||||
}
|
||||
|
||||
if ( ! isset($active_group))
|
||||
{
|
||||
show_error('You have not specified a database connection group via $active_group in your config/database.php file.');
|
||||
}
|
||||
elseif ( ! isset($db[$active_group]))
|
||||
{
|
||||
show_error('You have specified an invalid database connection group ('.$active_group.') in your config/database.php file.');
|
||||
}
|
||||
|
||||
$params = $db[$active_group];
|
||||
}
|
||||
elseif (is_string($params))
|
||||
{
|
||||
/**
|
||||
* Parse the URL from the DSN string
|
||||
* Database settings can be passed as discreet
|
||||
* parameters or as a data source name in the first
|
||||
* parameter. DSNs must have this prototype:
|
||||
* $dsn = 'driver://username:password@hostname/database';
|
||||
*/
|
||||
if (($dsn = @parse_url($params)) === FALSE)
|
||||
{
|
||||
show_error('Invalid DB Connection String');
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'dbdriver' => $dsn['scheme'],
|
||||
'hostname' => isset($dsn['host']) ? rawurldecode($dsn['host']) : '',
|
||||
'port' => isset($dsn['port']) ? rawurldecode($dsn['port']) : '',
|
||||
'username' => isset($dsn['user']) ? rawurldecode($dsn['user']) : '',
|
||||
'password' => isset($dsn['pass']) ? rawurldecode($dsn['pass']) : '',
|
||||
'database' => isset($dsn['path']) ? rawurldecode(substr($dsn['path'], 1)) : ''
|
||||
);
|
||||
|
||||
// Were additional config items set?
|
||||
if (isset($dsn['query']))
|
||||
{
|
||||
parse_str($dsn['query'], $extra);
|
||||
|
||||
foreach ($extra as $key => $val)
|
||||
{
|
||||
if (is_string($val) && in_array(strtoupper($val), array('TRUE', 'FALSE', 'NULL')))
|
||||
{
|
||||
$val = var_export($val, TRUE);
|
||||
}
|
||||
|
||||
$params[$key] = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// No DB specified yet? Beat them senseless...
|
||||
if (empty($params['dbdriver']))
|
||||
{
|
||||
show_error('You have not selected a database type to connect to.');
|
||||
}
|
||||
|
||||
# Force-load the right extension - MySQLi if available, MySQL if not.
|
||||
if (extension_loaded('mysqli')) {
|
||||
$params['dbdriver'] = "mysqli";
|
||||
} else {
|
||||
$params['dbdriver'] = "mysql";
|
||||
}
|
||||
|
||||
// Load the DB classes. Note: Since the query builder class is optional
|
||||
// we need to dynamically create a class that extends proper parent class
|
||||
// based on whether we're using the query builder class or not.
|
||||
if ($query_builder_override !== NULL)
|
||||
{
|
||||
$query_builder = $query_builder_override;
|
||||
}
|
||||
// Backwards compatibility work-around for keeping the
|
||||
// $active_record config variable working. Should be
|
||||
// removed in v3.1
|
||||
elseif ( ! isset($query_builder) && isset($active_record))
|
||||
{
|
||||
$query_builder = $active_record;
|
||||
}
|
||||
|
||||
require_once(BASEPATH.'database/DB_driver.php');
|
||||
|
||||
if ( ! isset($query_builder) OR $query_builder === TRUE)
|
||||
{
|
||||
require_once(BASEPATH.'database/DB_query_builder.php');
|
||||
if ( ! class_exists('CI_DB', FALSE))
|
||||
{
|
||||
/**
|
||||
* CI_DB
|
||||
*
|
||||
* Acts as an alias for both CI_DB_driver and CI_DB_query_builder.
|
||||
*
|
||||
* @see CI_DB_query_builder
|
||||
* @see CI_DB_driver
|
||||
*/
|
||||
class CI_DB extends CI_DB_query_builder { }
|
||||
}
|
||||
}
|
||||
elseif ( ! class_exists('CI_DB', FALSE))
|
||||
{
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
class CI_DB extends CI_DB_driver { }
|
||||
}
|
||||
|
||||
// Load the DB driver
|
||||
$driver_file = BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].'_driver.php';
|
||||
|
||||
file_exists($driver_file) OR show_error('Invalid DB driver');
|
||||
require_once($driver_file);
|
||||
|
||||
// Instantiate the DB adapter
|
||||
$driver = 'CI_DB_'.$params['dbdriver'].'_driver';
|
||||
$DB = new $driver($params);
|
||||
|
||||
// Check for a subdriver
|
||||
if ( ! empty($DB->subdriver))
|
||||
{
|
||||
$driver_file = BASEPATH.'database/drivers/'.$DB->dbdriver.'/subdrivers/'.$DB->dbdriver.'_'.$DB->subdriver.'_driver.php';
|
||||
|
||||
if (file_exists($driver_file))
|
||||
{
|
||||
require_once($driver_file);
|
||||
$driver = 'CI_DB_'.$DB->dbdriver.'_'.$DB->subdriver.'_driver';
|
||||
$DB = new $driver($params);
|
||||
}
|
||||
}
|
||||
|
||||
$DB->initialize();
|
||||
return $DB;
|
||||
}
|
||||
221
system/codeigniter/database/DB_cache.php
Executable file
221
system/codeigniter/database/DB_cache.php
Executable file
@@ -0,0 +1,221 @@
|
||||
<?php
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
* @filesource
|
||||
*/
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Database Cache Class
|
||||
*
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_Cache {
|
||||
|
||||
/**
|
||||
* CI Singleton
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
public $CI;
|
||||
|
||||
/**
|
||||
* Database object
|
||||
*
|
||||
* Allows passing of DB object so that multiple database connections
|
||||
* and returned DB objects can be supported.
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
public $db;
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param object &$db
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(&$db)
|
||||
{
|
||||
// Assign the main CI object to $this->CI and load the file helper since we use it a lot
|
||||
$this->CI =& get_instance();
|
||||
$this->db =& $db;
|
||||
$this->CI->load->helper('file');
|
||||
|
||||
$this->check_path();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set Cache Directory Path
|
||||
*
|
||||
* @param string $path Path to the cache directory
|
||||
* @return bool
|
||||
*/
|
||||
public function check_path($path = '')
|
||||
{
|
||||
if ($path === '')
|
||||
{
|
||||
if ($this->db->cachedir === '')
|
||||
{
|
||||
return $this->db->cache_off();
|
||||
}
|
||||
|
||||
$path = $this->db->cachedir;
|
||||
}
|
||||
|
||||
// Add a trailing slash to the path if needed
|
||||
$path = realpath($path)
|
||||
? rtrim(realpath($path), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR
|
||||
: rtrim($path, '/').'/';
|
||||
|
||||
if ( ! is_dir($path))
|
||||
{
|
||||
log_message('debug', 'DB cache path error: '.$path);
|
||||
|
||||
// If the path is wrong we'll turn off caching
|
||||
return $this->db->cache_off();
|
||||
}
|
||||
|
||||
if ( ! is_really_writable($path))
|
||||
{
|
||||
log_message('debug', 'DB cache dir not writable: '.$path);
|
||||
|
||||
// If the path is not really writable we'll turn off caching
|
||||
return $this->db->cache_off();
|
||||
}
|
||||
|
||||
$this->db->cachedir = $path;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Retrieve a cached query
|
||||
*
|
||||
* The URI being requested will become the name of the cache sub-folder.
|
||||
* An MD5 hash of the SQL statement will become the cache file name.
|
||||
*
|
||||
* @param string $sql
|
||||
* @return string
|
||||
*/
|
||||
public function read($sql)
|
||||
{
|
||||
$segment_one = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1);
|
||||
$segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2);
|
||||
$filepath = $this->db->cachedir.$segment_one.'+'.$segment_two.'/'.md5($sql);
|
||||
|
||||
if (FALSE === ($cachedata = @file_get_contents($filepath)))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return unserialize($cachedata);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Write a query to a cache file
|
||||
*
|
||||
* @param string $sql
|
||||
* @param object $object
|
||||
* @return bool
|
||||
*/
|
||||
public function write($sql, $object)
|
||||
{
|
||||
$segment_one = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1);
|
||||
$segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2);
|
||||
$dir_path = $this->db->cachedir.$segment_one.'+'.$segment_two.'/';
|
||||
$filename = md5($sql);
|
||||
|
||||
if ( ! is_dir($dir_path) && ! @mkdir($dir_path, 0750))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (write_file($dir_path.$filename, serialize($object)) === FALSE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
chmod($dir_path.$filename, 0640);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Delete cache files within a particular directory
|
||||
*
|
||||
* @param string $segment_one
|
||||
* @param string $segment_two
|
||||
* @return void
|
||||
*/
|
||||
public function delete($segment_one = '', $segment_two = '')
|
||||
{
|
||||
if ($segment_one === '')
|
||||
{
|
||||
$segment_one = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1);
|
||||
}
|
||||
|
||||
if ($segment_two === '')
|
||||
{
|
||||
$segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2);
|
||||
}
|
||||
|
||||
$dir_path = $this->db->cachedir.$segment_one.'+'.$segment_two.'/';
|
||||
delete_files($dir_path, TRUE);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Delete all existing cache files
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete_all()
|
||||
{
|
||||
delete_files($this->db->cachedir, TRUE, TRUE);
|
||||
}
|
||||
|
||||
}
|
||||
1989
system/codeigniter/database/DB_driver.php
Executable file
1989
system/codeigniter/database/DB_driver.php
Executable file
File diff suppressed because it is too large
Load Diff
1032
system/codeigniter/database/DB_forge.php
Executable file
1032
system/codeigniter/database/DB_forge.php
Executable file
File diff suppressed because it is too large
Load Diff
2810
system/codeigniter/database/DB_query_builder.php
Executable file
2810
system/codeigniter/database/DB_query_builder.php
Executable file
File diff suppressed because it is too large
Load Diff
666
system/codeigniter/database/DB_result.php
Executable file
666
system/codeigniter/database/DB_result.php
Executable file
@@ -0,0 +1,666 @@
|
||||
<?php
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
* @filesource
|
||||
*/
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* 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 EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_result {
|
||||
|
||||
/**
|
||||
* Connection ID
|
||||
*
|
||||
* @var resource|object
|
||||
*/
|
||||
public $conn_id;
|
||||
|
||||
/**
|
||||
* Result ID
|
||||
*
|
||||
* @var resource|object
|
||||
*/
|
||||
public $result_id;
|
||||
|
||||
/**
|
||||
* Result Array
|
||||
*
|
||||
* @var array[]
|
||||
*/
|
||||
public $result_array = array();
|
||||
|
||||
/**
|
||||
* Result Object
|
||||
*
|
||||
* @var object[]
|
||||
*/
|
||||
public $result_object = array();
|
||||
|
||||
/**
|
||||
* Custom Result Object
|
||||
*
|
||||
* @var object[]
|
||||
*/
|
||||
public $custom_result_object = array();
|
||||
|
||||
/**
|
||||
* Current Row index
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $current_row = 0;
|
||||
|
||||
/**
|
||||
* Number of rows
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $num_rows;
|
||||
|
||||
/**
|
||||
* Row data
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $row_data;
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param object $driver_object
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(&$driver_object)
|
||||
{
|
||||
$this->conn_id = $driver_object->conn_id;
|
||||
$this->result_id = $driver_object->result_id;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Number of rows in the result set
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function num_rows()
|
||||
{
|
||||
if (is_int($this->num_rows))
|
||||
{
|
||||
return $this->num_rows;
|
||||
}
|
||||
elseif (count($this->result_array) > 0)
|
||||
{
|
||||
return $this->num_rows = count($this->result_array);
|
||||
}
|
||||
elseif (count($this->result_object) > 0)
|
||||
{
|
||||
return $this->num_rows = count($this->result_object);
|
||||
}
|
||||
|
||||
return $this->num_rows = count($this->result_array());
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Query result. Acts as a wrapper function for the following functions.
|
||||
*
|
||||
* @param string $type 'object', 'array' or a custom class name
|
||||
* @return array
|
||||
*/
|
||||
public function result($type = 'object')
|
||||
{
|
||||
if ($type === 'array')
|
||||
{
|
||||
return $this->result_array();
|
||||
}
|
||||
elseif ($type === 'object')
|
||||
{
|
||||
return $this->result_object();
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->custom_result_object($type);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Custom query result.
|
||||
*
|
||||
* @param string $class_name
|
||||
* @return array
|
||||
*/
|
||||
public function custom_result_object($class_name)
|
||||
{
|
||||
if (isset($this->custom_result_object[$class_name]))
|
||||
{
|
||||
return $this->custom_result_object[$class_name];
|
||||
}
|
||||
elseif ( ! $this->result_id OR $this->num_rows === 0)
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
// Don't fetch the result set again if we already have it
|
||||
$_data = NULL;
|
||||
if (($c = count($this->result_array)) > 0)
|
||||
{
|
||||
$_data = 'result_array';
|
||||
}
|
||||
elseif (($c = count($this->result_object)) > 0)
|
||||
{
|
||||
$_data = 'result_object';
|
||||
}
|
||||
|
||||
if ($_data !== NULL)
|
||||
{
|
||||
for ($i = 0; $i < $c; $i++)
|
||||
{
|
||||
$this->custom_result_object[$class_name][$i] = new $class_name();
|
||||
|
||||
foreach ($this->{$_data}[$i] as $key => $value)
|
||||
{
|
||||
$this->custom_result_object[$class_name][$i]->$key = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->custom_result_object[$class_name];
|
||||
}
|
||||
|
||||
is_null($this->row_data) OR $this->data_seek(0);
|
||||
$this->custom_result_object[$class_name] = array();
|
||||
|
||||
while ($row = $this->_fetch_object($class_name))
|
||||
{
|
||||
$this->custom_result_object[$class_name][] = $row;
|
||||
}
|
||||
|
||||
return $this->custom_result_object[$class_name];
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Query result. "object" version.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public 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 not be a valid resource so we'll simply return an empty
|
||||
// array.
|
||||
if ( ! $this->result_id OR $this->num_rows === 0)
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
if (($c = count($this->result_array)) > 0)
|
||||
{
|
||||
for ($i = 0; $i < $c; $i++)
|
||||
{
|
||||
$this->result_object[$i] = (object) $this->result_array[$i];
|
||||
}
|
||||
|
||||
return $this->result_object;
|
||||
}
|
||||
|
||||
is_null($this->row_data) OR $this->data_seek(0);
|
||||
while ($row = $this->_fetch_object())
|
||||
{
|
||||
$this->result_object[] = $row;
|
||||
}
|
||||
|
||||
return $this->result_object;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Query result. "array" version.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public 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 not be a valid resource so we'll simply return an empty
|
||||
// array.
|
||||
if ( ! $this->result_id OR $this->num_rows === 0)
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
if (($c = count($this->result_object)) > 0)
|
||||
{
|
||||
for ($i = 0; $i < $c; $i++)
|
||||
{
|
||||
$this->result_array[$i] = (array) $this->result_object[$i];
|
||||
}
|
||||
|
||||
return $this->result_array;
|
||||
}
|
||||
|
||||
is_null($this->row_data) OR $this->data_seek(0);
|
||||
while ($row = $this->_fetch_assoc())
|
||||
{
|
||||
$this->result_array[] = $row;
|
||||
}
|
||||
|
||||
return $this->result_array;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Row
|
||||
*
|
||||
* A wrapper method.
|
||||
*
|
||||
* @param mixed $n
|
||||
* @param string $type 'object' or 'array'
|
||||
* @return mixed
|
||||
*/
|
||||
public function row($n = 0, $type = 'object')
|
||||
{
|
||||
if ( ! is_numeric($n))
|
||||
{
|
||||
// We cache the row data for subsequent uses
|
||||
is_array($this->row_data) OR $this->row_data = $this->row_array(0);
|
||||
|
||||
// array_key_exists() instead of isset() to allow for NULL values
|
||||
if (empty($this->row_data) OR ! array_key_exists($n, $this->row_data))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return $this->row_data[$n];
|
||||
}
|
||||
|
||||
if ($type === 'object') return $this->row_object($n);
|
||||
elseif ($type === 'array') return $this->row_array($n);
|
||||
else return $this->custom_row_object($n, $type);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Assigns an item into a particular column slot
|
||||
*
|
||||
* @param mixed $key
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
*/
|
||||
public function set_row($key, $value = NULL)
|
||||
{
|
||||
// We cache the row data for subsequent uses
|
||||
if ( ! is_array($this->row_data))
|
||||
{
|
||||
$this->row_data = $this->row_array(0);
|
||||
}
|
||||
|
||||
if (is_array($key))
|
||||
{
|
||||
foreach ($key as $k => $v)
|
||||
{
|
||||
$this->row_data[$k] = $v;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ($key !== '' && $value !== NULL)
|
||||
{
|
||||
$this->row_data[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns a single result row - custom object version
|
||||
*
|
||||
* @param int $n
|
||||
* @param string $type
|
||||
* @return object
|
||||
*/
|
||||
public function custom_row_object($n, $type)
|
||||
{
|
||||
isset($this->custom_result_object[$type]) OR $this->custom_result_object($type);
|
||||
|
||||
if (count($this->custom_result_object[$type]) === 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ($n !== $this->current_row && isset($this->custom_result_object[$type][$n]))
|
||||
{
|
||||
$this->current_row = $n;
|
||||
}
|
||||
|
||||
return $this->custom_result_object[$type][$this->current_row];
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns a single result row - object version
|
||||
*
|
||||
* @param int $n
|
||||
* @return object
|
||||
*/
|
||||
public function row_object($n = 0)
|
||||
{
|
||||
$result = $this->result_object();
|
||||
if (count($result) === 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ($n !== $this->current_row && isset($result[$n]))
|
||||
{
|
||||
$this->current_row = $n;
|
||||
}
|
||||
|
||||
return $result[$this->current_row];
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns a single result row - array version
|
||||
*
|
||||
* @param int $n
|
||||
* @return array
|
||||
*/
|
||||
public function row_array($n = 0)
|
||||
{
|
||||
$result = $this->result_array();
|
||||
if (count($result) === 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ($n !== $this->current_row && isset($result[$n]))
|
||||
{
|
||||
$this->current_row = $n;
|
||||
}
|
||||
|
||||
return $result[$this->current_row];
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the "first" row
|
||||
*
|
||||
* @param string $type
|
||||
* @return mixed
|
||||
*/
|
||||
public function first_row($type = 'object')
|
||||
{
|
||||
$result = $this->result($type);
|
||||
return (count($result) === 0) ? NULL : $result[0];
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the "last" row
|
||||
*
|
||||
* @param string $type
|
||||
* @return mixed
|
||||
*/
|
||||
public function last_row($type = 'object')
|
||||
{
|
||||
$result = $this->result($type);
|
||||
return (count($result) === 0) ? NULL : $result[count($result) - 1];
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the "next" row
|
||||
*
|
||||
* @param string $type
|
||||
* @return mixed
|
||||
*/
|
||||
public function next_row($type = 'object')
|
||||
{
|
||||
$result = $this->result($type);
|
||||
if (count($result) === 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return isset($result[$this->current_row + 1])
|
||||
? $result[++$this->current_row]
|
||||
: NULL;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the "previous" row
|
||||
*
|
||||
* @param string $type
|
||||
* @return mixed
|
||||
*/
|
||||
public function previous_row($type = 'object')
|
||||
{
|
||||
$result = $this->result($type);
|
||||
if (count($result) === 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (isset($result[$this->current_row - 1]))
|
||||
{
|
||||
--$this->current_row;
|
||||
}
|
||||
return $result[$this->current_row];
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns an unbuffered row and move pointer to next row
|
||||
*
|
||||
* @param string $type 'array', 'object' or a custom class name
|
||||
* @return mixed
|
||||
*/
|
||||
public function unbuffered_row($type = 'object')
|
||||
{
|
||||
if ($type === 'array')
|
||||
{
|
||||
return $this->_fetch_assoc();
|
||||
}
|
||||
elseif ($type === 'object')
|
||||
{
|
||||
return $this->_fetch_object();
|
||||
}
|
||||
|
||||
return $this->_fetch_object($type);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The following methods 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.
|
||||
*/
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Number of fields in the result set
|
||||
*
|
||||
* Overridden by driver result classes.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function num_fields()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fetch Field Names
|
||||
*
|
||||
* Generates an array of column names.
|
||||
*
|
||||
* Overridden by driver result classes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function list_fields()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Field data
|
||||
*
|
||||
* Generates an array of objects containing field meta-data.
|
||||
*
|
||||
* Overridden by driver result classes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function field_data()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Free the result
|
||||
*
|
||||
* Overridden by driver result classes.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function free_result()
|
||||
{
|
||||
$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.
|
||||
*
|
||||
* Overridden by driver result classes.
|
||||
*
|
||||
* @param int $n
|
||||
* @return bool
|
||||
*/
|
||||
public function data_seek($n = 0)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Result - associative array
|
||||
*
|
||||
* Returns the result set as an array.
|
||||
*
|
||||
* Overridden by driver result classes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function _fetch_assoc()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Result - object
|
||||
*
|
||||
* Returns the result set as an object.
|
||||
*
|
||||
* Overridden by driver result classes.
|
||||
*
|
||||
* @param string $class_name
|
||||
* @return object
|
||||
*/
|
||||
protected function _fetch_object($class_name = 'stdClass')
|
||||
{
|
||||
return new $class_name();
|
||||
}
|
||||
|
||||
}
|
||||
424
system/codeigniter/database/DB_utility.php
Executable file
424
system/codeigniter/database/DB_utility.php
Executable file
@@ -0,0 +1,424 @@
|
||||
<?php
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
* @filesource
|
||||
*/
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Database Utility Class
|
||||
*
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
abstract class CI_DB_utility {
|
||||
|
||||
/**
|
||||
* Database object
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $db;
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* List databases statement
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_list_databases = FALSE;
|
||||
|
||||
/**
|
||||
* OPTIMIZE TABLE statement
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_optimize_table = FALSE;
|
||||
|
||||
/**
|
||||
* REPAIR TABLE statement
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_repair_table = FALSE;
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param object &$db Database object
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(&$db)
|
||||
{
|
||||
$this->db =& $db;
|
||||
log_message('info', 'Database Utility Class Initialized');
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* List databases
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function list_databases()
|
||||
{
|
||||
// Is there a cached result?
|
||||
if (isset($this->db->data_cache['db_names']))
|
||||
{
|
||||
return $this->db->data_cache['db_names'];
|
||||
}
|
||||
elseif ($this->_list_databases === FALSE)
|
||||
{
|
||||
return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE;
|
||||
}
|
||||
|
||||
$this->db->data_cache['db_names'] = array();
|
||||
|
||||
$query = $this->db->query($this->_list_databases);
|
||||
if ($query === FALSE)
|
||||
{
|
||||
return $this->db->data_cache['db_names'];
|
||||
}
|
||||
|
||||
for ($i = 0, $query = $query->result_array(), $c = count($query); $i < $c; $i++)
|
||||
{
|
||||
$this->db->data_cache['db_names'][] = current($query[$i]);
|
||||
}
|
||||
|
||||
return $this->db->data_cache['db_names'];
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Determine if a particular database exists
|
||||
*
|
||||
* @param string $database_name
|
||||
* @return bool
|
||||
*/
|
||||
public function database_exists($database_name)
|
||||
{
|
||||
return in_array($database_name, $this->list_databases());
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Optimize Table
|
||||
*
|
||||
* @param string $table_name
|
||||
* @return mixed
|
||||
*/
|
||||
public function optimize_table($table_name)
|
||||
{
|
||||
if ($this->_optimize_table === FALSE)
|
||||
{
|
||||
return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE;
|
||||
}
|
||||
|
||||
$query = $this->db->query(sprintf($this->_optimize_table, $this->db->escape_identifiers($table_name)));
|
||||
if ($query !== FALSE)
|
||||
{
|
||||
$query = $query->result_array();
|
||||
return current($query);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Optimize Database
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function optimize_database()
|
||||
{
|
||||
if ($this->_optimize_table === FALSE)
|
||||
{
|
||||
return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE;
|
||||
}
|
||||
|
||||
$result = array();
|
||||
foreach ($this->db->list_tables() as $table_name)
|
||||
{
|
||||
$res = $this->db->query(sprintf($this->_optimize_table, $this->db->escape_identifiers($table_name)));
|
||||
if (is_bool($res))
|
||||
{
|
||||
return $res;
|
||||
}
|
||||
|
||||
// Build the result array...
|
||||
$res = $res->result_array();
|
||||
$res = current($res);
|
||||
$key = str_replace($this->db->database.'.', '', current($res));
|
||||
$keys = array_keys($res);
|
||||
unset($res[$keys[0]]);
|
||||
|
||||
$result[$key] = $res;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Repair Table
|
||||
*
|
||||
* @param string $table_name
|
||||
* @return mixed
|
||||
*/
|
||||
public function repair_table($table_name)
|
||||
{
|
||||
if ($this->_repair_table === FALSE)
|
||||
{
|
||||
return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE;
|
||||
}
|
||||
|
||||
$query = $this->db->query(sprintf($this->_repair_table, $this->db->escape_identifiers($table_name)));
|
||||
if (is_bool($query))
|
||||
{
|
||||
return $query;
|
||||
}
|
||||
|
||||
$query = $query->result_array();
|
||||
return current($query);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Generate CSV from a query result object
|
||||
*
|
||||
* @param object $query Query result object
|
||||
* @param string $delim Delimiter (default: ,)
|
||||
* @param string $newline Newline character (default: \n)
|
||||
* @param string $enclosure Enclosure (default: ")
|
||||
* @return string
|
||||
*/
|
||||
public function csv_from_result($query, $delim = ',', $newline = "\n", $enclosure = '"')
|
||||
{
|
||||
if ( ! is_object($query) OR ! method_exists($query, 'list_fields'))
|
||||
{
|
||||
show_error('You must submit a valid result object');
|
||||
}
|
||||
|
||||
$out = '';
|
||||
// First generate the headings from the table column names
|
||||
foreach ($query->list_fields() as $name)
|
||||
{
|
||||
$out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $name).$enclosure.$delim;
|
||||
}
|
||||
|
||||
$out = substr($out, 0, -strlen($delim)).$newline;
|
||||
|
||||
// Next blast through the result array and build out the rows
|
||||
while ($row = $query->unbuffered_row('array'))
|
||||
{
|
||||
$line = array();
|
||||
foreach ($row as $item)
|
||||
{
|
||||
$line[] = $enclosure.str_replace($enclosure, $enclosure.$enclosure, $item).$enclosure;
|
||||
}
|
||||
$out .= implode($delim, $line).$newline;
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Generate XML data from a query result object
|
||||
*
|
||||
* @param object $query Query result object
|
||||
* @param array $params Any preferences
|
||||
* @return string
|
||||
*/
|
||||
public function xml_from_result($query, $params = array())
|
||||
{
|
||||
if ( ! is_object($query) OR ! method_exists($query, 'list_fields'))
|
||||
{
|
||||
show_error('You must submit a valid result object');
|
||||
}
|
||||
|
||||
// Set our default values
|
||||
foreach (array('root' => 'root', 'element' => 'element', 'newline' => "\n", 'tab' => "\t") as $key => $val)
|
||||
{
|
||||
if ( ! isset($params[$key]))
|
||||
{
|
||||
$params[$key] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
// Create variables for convenience
|
||||
extract($params);
|
||||
|
||||
// Load the xml helper
|
||||
get_instance()->load->helper('xml');
|
||||
|
||||
// Generate the result
|
||||
$xml = '<'.$root.'>'.$newline;
|
||||
while ($row = $query->unbuffered_row())
|
||||
{
|
||||
$xml .= $tab.'<'.$element.'>'.$newline;
|
||||
foreach ($row as $key => $val)
|
||||
{
|
||||
$xml .= $tab.$tab.'<'.$key.'>'.xml_convert($val).'</'.$key.'>'.$newline;
|
||||
}
|
||||
$xml .= $tab.'</'.$element.'>'.$newline;
|
||||
}
|
||||
|
||||
return $xml.'</'.$root.'>'.$newline;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Database Backup
|
||||
*
|
||||
* @param array $params
|
||||
* @return string
|
||||
*/
|
||||
public 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",
|
||||
'foreign_key_checks' => TRUE
|
||||
);
|
||||
|
||||
// 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' && ! function_exists('gzencode'))
|
||||
OR ($prefs['format'] === 'zip' && ! function_exists('gzcompress')))
|
||||
{
|
||||
if ($this->db->db_debug)
|
||||
{
|
||||
return $this->db->display_error('db_unsupported_compression');
|
||||
}
|
||||
|
||||
$prefs['format'] = 'txt';
|
||||
}
|
||||
|
||||
// Was a Zip file requested?
|
||||
if ($prefs['format'] === 'zip')
|
||||
{
|
||||
// Set the filename if not provided (only needed with Zip files)
|
||||
if ($prefs['filename'] === '')
|
||||
{
|
||||
$prefs['filename'] = (count($prefs['tables']) === 1 ? $prefs['tables'] : $this->db->database)
|
||||
.date('Y-m-d_H-i', time()).'.sql';
|
||||
}
|
||||
else
|
||||
{
|
||||
// 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();
|
||||
}
|
||||
elseif ($prefs['format'] === 'txt') // Was a text file requested?
|
||||
{
|
||||
return $this->_backup($prefs);
|
||||
}
|
||||
elseif ($prefs['format'] === 'gzip') // Was a Gzip file requested?
|
||||
{
|
||||
return gzencode($this->_backup($prefs));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
405
system/codeigniter/database/drivers/cubrid/cubrid_driver.php
Executable file
405
system/codeigniter/database/drivers/cubrid/cubrid_driver.php
Executable file
@@ -0,0 +1,405 @@
|
||||
<?php
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 2.1.0
|
||||
* @filesource
|
||||
*/
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* CUBRID Database Adapter Class
|
||||
*
|
||||
* Note: _DB is an extender class that the app controller
|
||||
* creates dynamically based on whether the query builder
|
||||
* class is being used or not.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author Esen Sagynov
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_cubrid_driver extends CI_DB {
|
||||
|
||||
/**
|
||||
* Database driver
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $dbdriver = 'cubrid';
|
||||
|
||||
/**
|
||||
* Auto-commit flag
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $auto_commit = TRUE;
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Identifier escape character
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_escape_char = '`';
|
||||
|
||||
/**
|
||||
* ORDER BY random keyword
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_random_keyword = array('RANDOM()', 'RANDOM(%d)');
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param array $params
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($params)
|
||||
{
|
||||
parent::__construct($params);
|
||||
|
||||
if (preg_match('/^CUBRID:[^:]+(:[0-9][1-9]{0,4})?:[^:]+:[^:]*:[^:]*:(\?.+)?$/', $this->dsn, $matches))
|
||||
{
|
||||
if (stripos($matches[2], 'autocommit=off') !== FALSE)
|
||||
{
|
||||
$this->auto_commit = FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// If no port is defined by the user, use the default value
|
||||
empty($this->port) OR $this->port = 33000;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Non-persistent database connection
|
||||
*
|
||||
* @param bool $persistent
|
||||
* @return resource
|
||||
*/
|
||||
public function db_connect($persistent = FALSE)
|
||||
{
|
||||
if (preg_match('/^CUBRID:[^:]+(:[0-9][1-9]{0,4})?:[^:]+:([^:]*):([^:]*):(\?.+)?$/', $this->dsn, $matches))
|
||||
{
|
||||
$func = ($persistent !== TRUE) ? 'cubrid_connect_with_url' : 'cubrid_pconnect_with_url';
|
||||
return ($matches[2] === '' && $matches[3] === '' && $this->username !== '' && $this->password !== '')
|
||||
? $func($this->dsn, $this->username, $this->password)
|
||||
: $func($this->dsn);
|
||||
}
|
||||
|
||||
$func = ($persistent !== TRUE) ? 'cubrid_connect' : 'cubrid_pconnect';
|
||||
return ($this->username !== '')
|
||||
? $func($this->hostname, $this->port, $this->database, $this->username, $this->password)
|
||||
: $func($this->hostname, $this->port, $this->database);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Reconnect
|
||||
*
|
||||
* Keep / reestablish the db connection if no queries have been
|
||||
* sent for a length of time exceeding the server's idle timeout
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function reconnect()
|
||||
{
|
||||
if (cubrid_ping($this->conn_id) === FALSE)
|
||||
{
|
||||
$this->conn_id = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Database version number
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function version()
|
||||
{
|
||||
if (isset($this->data_cache['version']))
|
||||
{
|
||||
return $this->data_cache['version'];
|
||||
}
|
||||
|
||||
return ( ! $this->conn_id OR ($version = cubrid_get_server_info($this->conn_id)) === FALSE)
|
||||
? FALSE
|
||||
: $this->data_cache['version'] = $version;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Execute the query
|
||||
*
|
||||
* @param string $sql an SQL query
|
||||
* @return resource
|
||||
*/
|
||||
protected function _execute($sql)
|
||||
{
|
||||
return cubrid_query($sql, $this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Begin Transaction
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function _trans_begin()
|
||||
{
|
||||
if (($autocommit = cubrid_get_autocommit($this->conn_id)) === NULL)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
elseif ($autocommit === TRUE)
|
||||
{
|
||||
return cubrid_set_autocommit($this->conn_id, CUBRID_AUTOCOMMIT_FALSE);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Commit Transaction
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function _trans_commit()
|
||||
{
|
||||
if ( ! cubrid_commit($this->conn_id))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ($this->auto_commit && ! cubrid_get_autocommit($this->conn_id))
|
||||
{
|
||||
return cubrid_set_autocommit($this->conn_id, CUBRID_AUTOCOMMIT_TRUE);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Rollback Transaction
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function _trans_rollback()
|
||||
{
|
||||
if ( ! cubrid_rollback($this->conn_id))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ($this->auto_commit && ! cubrid_get_autocommit($this->conn_id))
|
||||
{
|
||||
cubrid_set_autocommit($this->conn_id, CUBRID_AUTOCOMMIT_TRUE);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Platform-dependent string escape
|
||||
*
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
protected function _escape_str($str)
|
||||
{
|
||||
return cubrid_real_escape_string($str, $this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Affected Rows
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function affected_rows()
|
||||
{
|
||||
return cubrid_affected_rows();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Insert ID
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function insert_id()
|
||||
{
|
||||
return cubrid_insert_id($this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* List table query
|
||||
*
|
||||
* Generates a platform-specific query string so that the table names can be fetched
|
||||
*
|
||||
* @param bool $prefix_limit
|
||||
* @return string
|
||||
*/
|
||||
protected function _list_tables($prefix_limit = FALSE)
|
||||
{
|
||||
$sql = 'SHOW TABLES';
|
||||
|
||||
if ($prefix_limit !== FALSE && $this->dbprefix !== '')
|
||||
{
|
||||
return $sql." LIKE '".$this->escape_like_str($this->dbprefix)."%'";
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Show column query
|
||||
*
|
||||
* Generates a platform-specific query string so that the column names can be fetched
|
||||
*
|
||||
* @param string $table
|
||||
* @return string
|
||||
*/
|
||||
protected function _list_columns($table = '')
|
||||
{
|
||||
return 'SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns an object with field data
|
||||
*
|
||||
* @param string $table
|
||||
* @return array
|
||||
*/
|
||||
public function field_data($table)
|
||||
{
|
||||
if (($query = $this->query('SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE))) === FALSE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
$query = $query->result_object();
|
||||
|
||||
$retval = array();
|
||||
for ($i = 0, $c = count($query); $i < $c; $i++)
|
||||
{
|
||||
$retval[$i] = new stdClass();
|
||||
$retval[$i]->name = $query[$i]->Field;
|
||||
|
||||
sscanf($query[$i]->Type, '%[a-z](%d)',
|
||||
$retval[$i]->type,
|
||||
$retval[$i]->max_length
|
||||
);
|
||||
|
||||
$retval[$i]->default = $query[$i]->Default;
|
||||
$retval[$i]->primary_key = (int) ($query[$i]->Key === 'PRI');
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Error
|
||||
*
|
||||
* Returns an array containing code and message of the last
|
||||
* database error that has occurred.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function error()
|
||||
{
|
||||
return array('code' => cubrid_errno($this->conn_id), 'message' => cubrid_error($this->conn_id));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* FROM tables
|
||||
*
|
||||
* Groups tables in FROM clauses if needed, so there is no confusion
|
||||
* about operator precedence.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _from_tables()
|
||||
{
|
||||
if ( ! empty($this->qb_join) && count($this->qb_from) > 1)
|
||||
{
|
||||
return '('.implode(', ', $this->qb_from).')';
|
||||
}
|
||||
|
||||
return implode(', ', $this->qb_from);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Close DB Connection
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _close()
|
||||
{
|
||||
cubrid_close($this->conn_id);
|
||||
}
|
||||
|
||||
}
|
||||
230
system/codeigniter/database/drivers/cubrid/cubrid_forge.php
Executable file
230
system/codeigniter/database/drivers/cubrid/cubrid_forge.php
Executable file
@@ -0,0 +1,230 @@
|
||||
<?php
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 2.1.0
|
||||
* @filesource
|
||||
*/
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* CUBRID Forge Class
|
||||
*
|
||||
* @category Database
|
||||
* @author Esen Sagynov
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_cubrid_forge extends CI_DB_forge {
|
||||
|
||||
/**
|
||||
* CREATE DATABASE statement
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_create_database = FALSE;
|
||||
|
||||
/**
|
||||
* CREATE TABLE keys flag
|
||||
*
|
||||
* Whether table keys are created from within the
|
||||
* CREATE TABLE statement.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $_create_table_keys = TRUE;
|
||||
|
||||
/**
|
||||
* DROP DATABASE statement
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_drop_database = FALSE;
|
||||
|
||||
/**
|
||||
* CREATE TABLE IF statement
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_create_table_if = FALSE;
|
||||
|
||||
/**
|
||||
* UNSIGNED support
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_unsigned = array(
|
||||
'SHORT' => 'INTEGER',
|
||||
'SMALLINT' => 'INTEGER',
|
||||
'INT' => 'BIGINT',
|
||||
'INTEGER' => 'BIGINT',
|
||||
'BIGINT' => 'NUMERIC',
|
||||
'FLOAT' => 'DOUBLE',
|
||||
'REAL' => 'DOUBLE'
|
||||
);
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* ALTER TABLE
|
||||
*
|
||||
* @param string $alter_type ALTER type
|
||||
* @param string $table Table name
|
||||
* @param mixed $field Column definition
|
||||
* @return string|string[]
|
||||
*/
|
||||
protected function _alter_table($alter_type, $table, $field)
|
||||
{
|
||||
if (in_array($alter_type, array('DROP', 'ADD'), TRUE))
|
||||
{
|
||||
return parent::_alter_table($alter_type, $table, $field);
|
||||
}
|
||||
|
||||
$sql = 'ALTER TABLE '.$this->db->escape_identifiers($table);
|
||||
$sqls = array();
|
||||
for ($i = 0, $c = count($field); $i < $c; $i++)
|
||||
{
|
||||
if ($field[$i]['_literal'] !== FALSE)
|
||||
{
|
||||
$sqls[] = $sql.' CHANGE '.$field[$i]['_literal'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$alter_type = empty($field[$i]['new_name']) ? ' MODIFY ' : ' CHANGE ';
|
||||
$sqls[] = $sql.$alter_type.$this->_process_column($field[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
return $sqls;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Process column
|
||||
*
|
||||
* @param array $field
|
||||
* @return string
|
||||
*/
|
||||
protected function _process_column($field)
|
||||
{
|
||||
$extra_clause = isset($field['after'])
|
||||
? ' AFTER '.$this->db->escape_identifiers($field['after']) : '';
|
||||
|
||||
if (empty($extra_clause) && isset($field['first']) && $field['first'] === TRUE)
|
||||
{
|
||||
$extra_clause = ' FIRST';
|
||||
}
|
||||
|
||||
return $this->db->escape_identifiers($field['name'])
|
||||
.(empty($field['new_name']) ? '' : ' '.$this->db->escape_identifiers($field['new_name']))
|
||||
.' '.$field['type'].$field['length']
|
||||
.$field['unsigned']
|
||||
.$field['null']
|
||||
.$field['default']
|
||||
.$field['auto_increment']
|
||||
.$field['unique']
|
||||
.$extra_clause;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Field attribute TYPE
|
||||
*
|
||||
* Performs a data type mapping between different databases.
|
||||
*
|
||||
* @param array &$attributes
|
||||
* @return void
|
||||
*/
|
||||
protected function _attr_type(&$attributes)
|
||||
{
|
||||
switch (strtoupper($attributes['TYPE']))
|
||||
{
|
||||
case 'TINYINT':
|
||||
$attributes['TYPE'] = 'SMALLINT';
|
||||
$attributes['UNSIGNED'] = FALSE;
|
||||
return;
|
||||
case 'MEDIUMINT':
|
||||
$attributes['TYPE'] = 'INTEGER';
|
||||
$attributes['UNSIGNED'] = FALSE;
|
||||
return;
|
||||
case 'LONGTEXT':
|
||||
$attributes['TYPE'] = 'STRING';
|
||||
return;
|
||||
default: return;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Process indexes
|
||||
*
|
||||
* @param string $table (ignored)
|
||||
* @return string
|
||||
*/
|
||||
protected function _process_indexes($table)
|
||||
{
|
||||
$sql = '';
|
||||
|
||||
for ($i = 0, $c = count($this->keys); $i < $c; $i++)
|
||||
{
|
||||
if (is_array($this->keys[$i]))
|
||||
{
|
||||
for ($i2 = 0, $c2 = count($this->keys[$i]); $i2 < $c2; $i2++)
|
||||
{
|
||||
if ( ! isset($this->fields[$this->keys[$i][$i2]]))
|
||||
{
|
||||
unset($this->keys[$i][$i2]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ( ! isset($this->fields[$this->keys[$i]]))
|
||||
{
|
||||
unset($this->keys[$i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
is_array($this->keys[$i]) OR $this->keys[$i] = array($this->keys[$i]);
|
||||
|
||||
$sql .= ",\n\tKEY ".$this->db->escape_identifiers(implode('_', $this->keys[$i]))
|
||||
.' ('.implode(', ', $this->db->escape_identifiers($this->keys[$i])).')';
|
||||
}
|
||||
|
||||
$this->keys = array();
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
}
|
||||
177
system/codeigniter/database/drivers/cubrid/cubrid_result.php
Executable file
177
system/codeigniter/database/drivers/cubrid/cubrid_result.php
Executable file
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 2.1.0
|
||||
* @filesource
|
||||
*/
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* CUBRID Result Class
|
||||
*
|
||||
* This class extends the parent result class: CI_DB_result
|
||||
*
|
||||
* @category Database
|
||||
* @author Esen Sagynov
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_cubrid_result extends CI_DB_result {
|
||||
|
||||
/**
|
||||
* Number of rows in the result set
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function num_rows()
|
||||
{
|
||||
return is_int($this->num_rows)
|
||||
? $this->num_rows
|
||||
: $this->num_rows = cubrid_num_rows($this->result_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Number of fields in the result set
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function num_fields()
|
||||
{
|
||||
return cubrid_num_fields($this->result_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fetch Field Names
|
||||
*
|
||||
* Generates an array of column names
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function list_fields()
|
||||
{
|
||||
return cubrid_column_names($this->result_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Field data
|
||||
*
|
||||
* Generates an array of objects containing field meta-data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function field_data()
|
||||
{
|
||||
$retval = array();
|
||||
|
||||
for ($i = 0, $c = $this->num_fields(); $i < $c; $i++)
|
||||
{
|
||||
$retval[$i] = new stdClass();
|
||||
$retval[$i]->name = cubrid_field_name($this->result_id, $i);
|
||||
$retval[$i]->type = cubrid_field_type($this->result_id, $i);
|
||||
$retval[$i]->max_length = cubrid_field_len($this->result_id, $i);
|
||||
$retval[$i]->primary_key = (int) (strpos(cubrid_field_flags($this->result_id, $i), 'primary_key') !== FALSE);
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Free the result
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function free_result()
|
||||
{
|
||||
if (is_resource($this->result_id) OR
|
||||
(get_resource_type($this->result_id) === 'Unknown' && preg_match('/Resource id #/', strval($this->result_id))))
|
||||
{
|
||||
cubrid_close_request($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.
|
||||
*
|
||||
* @param int $n
|
||||
* @return bool
|
||||
*/
|
||||
public function data_seek($n = 0)
|
||||
{
|
||||
return cubrid_data_seek($this->result_id, $n);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Result - associative array
|
||||
*
|
||||
* Returns the result set as an array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function _fetch_assoc()
|
||||
{
|
||||
return cubrid_fetch_assoc($this->result_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Result - object
|
||||
*
|
||||
* Returns the result set as an object
|
||||
*
|
||||
* @param string $class_name
|
||||
* @return object
|
||||
*/
|
||||
protected function _fetch_object($class_name = 'stdClass')
|
||||
{
|
||||
return cubrid_fetch_object($this->result_id, $class_name);
|
||||
}
|
||||
|
||||
}
|
||||
79
system/codeigniter/database/drivers/cubrid/cubrid_utility.php
Executable file
79
system/codeigniter/database/drivers/cubrid/cubrid_utility.php
Executable file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 2.1.0
|
||||
* @filesource
|
||||
*/
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* CUBRID Utility Class
|
||||
*
|
||||
* @category Database
|
||||
* @author Esen Sagynov
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_cubrid_utility extends CI_DB_utility {
|
||||
|
||||
/**
|
||||
* List databases
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function list_databases()
|
||||
{
|
||||
if (isset($this->db->data_cache['db_names']))
|
||||
{
|
||||
return $this->db->data_cache['db_names'];
|
||||
}
|
||||
|
||||
return $this->db->data_cache['db_names'] = cubrid_list_dbs($this->db->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* CUBRID Export
|
||||
*
|
||||
* @param array Preferences
|
||||
* @return mixed
|
||||
*/
|
||||
protected function _backup($params = array())
|
||||
{
|
||||
// No SQL based support in CUBRID as of version 8.4.0. Database or
|
||||
// table backup can be performed using CUBRID Manager
|
||||
// database administration tool.
|
||||
return $this->db->display_error('db_unsupported_feature');
|
||||
}
|
||||
}
|
||||
11
system/codeigniter/database/drivers/cubrid/index.html
Executable file
11
system/codeigniter/database/drivers/cubrid/index.html
Executable file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
413
system/codeigniter/database/drivers/ibase/ibase_driver.php
Executable file
413
system/codeigniter/database/drivers/ibase/ibase_driver.php
Executable file
@@ -0,0 +1,413 @@
|
||||
<?php
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 3.0.0
|
||||
* @filesource
|
||||
*/
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Firebird/Interbase Database Adapter Class
|
||||
*
|
||||
* Note: _DB is an extender class that the app controller
|
||||
* creates dynamically based on whether the query builder
|
||||
* class is being used or not.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_ibase_driver extends CI_DB {
|
||||
|
||||
/**
|
||||
* Database driver
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $dbdriver = 'ibase';
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* ORDER BY random keyword
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_random_keyword = array('RAND()', 'RAND()');
|
||||
|
||||
/**
|
||||
* IBase Transaction status flag
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
protected $_ibase_trans;
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Non-persistent database connection
|
||||
*
|
||||
* @param bool $persistent
|
||||
* @return resource
|
||||
*/
|
||||
public function db_connect($persistent = FALSE)
|
||||
{
|
||||
return ($persistent === TRUE)
|
||||
? ibase_pconnect($this->hostname.':'.$this->database, $this->username, $this->password, $this->char_set)
|
||||
: ibase_connect($this->hostname.':'.$this->database, $this->username, $this->password, $this->char_set);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Database version number
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function version()
|
||||
{
|
||||
if (isset($this->data_cache['version']))
|
||||
{
|
||||
return $this->data_cache['version'];
|
||||
}
|
||||
|
||||
if (($service = ibase_service_attach($this->hostname, $this->username, $this->password)))
|
||||
{
|
||||
$this->data_cache['version'] = ibase_server_info($service, IBASE_SVC_SERVER_VERSION);
|
||||
|
||||
// Don't keep the service open
|
||||
ibase_service_detach($service);
|
||||
return $this->data_cache['version'];
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Execute the query
|
||||
*
|
||||
* @param string $sql an SQL query
|
||||
* @return resource
|
||||
*/
|
||||
protected function _execute($sql)
|
||||
{
|
||||
return ibase_query(isset($this->_ibase_trans) ? $this->_ibase_trans : $this->conn_id, $sql);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Begin Transaction
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function _trans_begin()
|
||||
{
|
||||
if (($trans_handle = ibase_trans($this->conn_id)) === FALSE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$this->_ibase_trans = $trans_handle;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Commit Transaction
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function _trans_commit()
|
||||
{
|
||||
if (ibase_commit($this->_ibase_trans))
|
||||
{
|
||||
$this->_ibase_trans = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Rollback Transaction
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function _trans_rollback()
|
||||
{
|
||||
if (ibase_rollback($this->_ibase_trans))
|
||||
{
|
||||
$this->_ibase_trans = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Affected Rows
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function affected_rows()
|
||||
{
|
||||
return ibase_affected_rows($this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Insert ID
|
||||
*
|
||||
* @param string $generator_name
|
||||
* @param int $inc_by
|
||||
* @return int
|
||||
*/
|
||||
public function insert_id($generator_name, $inc_by = 0)
|
||||
{
|
||||
//If a generator hasn't been used before it will return 0
|
||||
return ibase_gen_id('"'.$generator_name.'"', $inc_by);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* List table query
|
||||
*
|
||||
* Generates a platform-specific query string so that the table names can be fetched
|
||||
*
|
||||
* @param bool $prefix_limit
|
||||
* @return string
|
||||
*/
|
||||
protected function _list_tables($prefix_limit = FALSE)
|
||||
{
|
||||
$sql = 'SELECT TRIM("RDB$RELATION_NAME") AS TABLE_NAME FROM "RDB$RELATIONS" WHERE "RDB$RELATION_NAME" NOT LIKE \'RDB$%\' AND "RDB$RELATION_NAME" NOT LIKE \'MON$%\'';
|
||||
|
||||
if ($prefix_limit !== FALSE && $this->dbprefix !== '')
|
||||
{
|
||||
return $sql.' AND TRIM("RDB$RELATION_NAME") AS TABLE_NAME LIKE \''.$this->escape_like_str($this->dbprefix)."%' "
|
||||
.sprintf($this->_like_escape_str, $this->_like_escape_chr);
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Show column query
|
||||
*
|
||||
* Generates a platform-specific query string so that the column names can be fetched
|
||||
*
|
||||
* @param string $table
|
||||
* @return string
|
||||
*/
|
||||
protected function _list_columns($table = '')
|
||||
{
|
||||
return 'SELECT TRIM("RDB$FIELD_NAME") AS COLUMN_NAME FROM "RDB$RELATION_FIELDS" WHERE "RDB$RELATION_NAME" = '.$this->escape($table);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns an object with field data
|
||||
*
|
||||
* @param string $table
|
||||
* @return array
|
||||
*/
|
||||
public function field_data($table)
|
||||
{
|
||||
$sql = 'SELECT "rfields"."RDB$FIELD_NAME" AS "name",
|
||||
CASE "fields"."RDB$FIELD_TYPE"
|
||||
WHEN 7 THEN \'SMALLINT\'
|
||||
WHEN 8 THEN \'INTEGER\'
|
||||
WHEN 9 THEN \'QUAD\'
|
||||
WHEN 10 THEN \'FLOAT\'
|
||||
WHEN 11 THEN \'DFLOAT\'
|
||||
WHEN 12 THEN \'DATE\'
|
||||
WHEN 13 THEN \'TIME\'
|
||||
WHEN 14 THEN \'CHAR\'
|
||||
WHEN 16 THEN \'INT64\'
|
||||
WHEN 27 THEN \'DOUBLE\'
|
||||
WHEN 35 THEN \'TIMESTAMP\'
|
||||
WHEN 37 THEN \'VARCHAR\'
|
||||
WHEN 40 THEN \'CSTRING\'
|
||||
WHEN 261 THEN \'BLOB\'
|
||||
ELSE NULL
|
||||
END AS "type",
|
||||
"fields"."RDB$FIELD_LENGTH" AS "max_length",
|
||||
"rfields"."RDB$DEFAULT_VALUE" AS "default"
|
||||
FROM "RDB$RELATION_FIELDS" "rfields"
|
||||
JOIN "RDB$FIELDS" "fields" ON "rfields"."RDB$FIELD_SOURCE" = "fields"."RDB$FIELD_NAME"
|
||||
WHERE "rfields"."RDB$RELATION_NAME" = '.$this->escape($table).'
|
||||
ORDER BY "rfields"."RDB$FIELD_POSITION"';
|
||||
|
||||
return (($query = $this->query($sql)) !== FALSE)
|
||||
? $query->result_object()
|
||||
: FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Error
|
||||
*
|
||||
* Returns an array containing code and message of the last
|
||||
* database error that has occurred.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function error()
|
||||
{
|
||||
return array('code' => ibase_errcode(), 'message' => ibase_errmsg());
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Update statement
|
||||
*
|
||||
* Generates a platform-specific update string from the supplied data
|
||||
*
|
||||
* @param string $table
|
||||
* @param array $values
|
||||
* @return string
|
||||
*/
|
||||
protected function _update($table, $values)
|
||||
{
|
||||
$this->qb_limit = FALSE;
|
||||
return parent::_update($table, $values);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Truncate statement
|
||||
*
|
||||
* Generates a platform-specific truncate string from the supplied data
|
||||
*
|
||||
* If the database does not support the TRUNCATE statement,
|
||||
* then this method maps to 'DELETE FROM table'
|
||||
*
|
||||
* @param string $table
|
||||
* @return string
|
||||
*/
|
||||
protected function _truncate($table)
|
||||
{
|
||||
return 'DELETE FROM '.$table;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Delete statement
|
||||
*
|
||||
* Generates a platform-specific delete string from the supplied data
|
||||
*
|
||||
* @param string $table
|
||||
* @return string
|
||||
*/
|
||||
protected function _delete($table)
|
||||
{
|
||||
$this->qb_limit = FALSE;
|
||||
return parent::_delete($table);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* LIMIT
|
||||
*
|
||||
* Generates a platform-specific LIMIT clause
|
||||
*
|
||||
* @param string $sql SQL Query
|
||||
* @return string
|
||||
*/
|
||||
protected function _limit($sql)
|
||||
{
|
||||
// Limit clause depends on if Interbase or Firebird
|
||||
if (stripos($this->version(), 'firebird') !== FALSE)
|
||||
{
|
||||
$select = 'FIRST '.$this->qb_limit
|
||||
.($this->qb_offset ? ' SKIP '.$this->qb_offset : '');
|
||||
}
|
||||
else
|
||||
{
|
||||
$select = 'ROWS '
|
||||
.($this->qb_offset ? $this->qb_offset.' TO '.($this->qb_limit + $this->qb_offset) : $this->qb_limit);
|
||||
}
|
||||
|
||||
return preg_replace('`SELECT`i', 'SELECT '.$select, $sql, 1);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Insert batch statement
|
||||
*
|
||||
* Generates a platform-specific insert string from the supplied data.
|
||||
*
|
||||
* @param string $table Table name
|
||||
* @param array $keys INSERT keys
|
||||
* @param array $values INSERT values
|
||||
* @return string|bool
|
||||
*/
|
||||
protected function _insert_batch($table, $keys, $values)
|
||||
{
|
||||
return ($this->db_debug) ? $this->display_error('db_unsupported_feature') : FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Close DB Connection
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _close()
|
||||
{
|
||||
ibase_close($this->conn_id);
|
||||
}
|
||||
|
||||
}
|
||||
251
system/codeigniter/database/drivers/ibase/ibase_forge.php
Executable file
251
system/codeigniter/database/drivers/ibase/ibase_forge.php
Executable file
@@ -0,0 +1,251 @@
|
||||
<?php
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 3.0.0
|
||||
* @filesource
|
||||
*/
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Interbase/Firebird Forge Class
|
||||
*
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_ibase_forge extends CI_DB_forge {
|
||||
|
||||
/**
|
||||
* CREATE TABLE IF statement
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_create_table_if = FALSE;
|
||||
|
||||
/**
|
||||
* RENAME TABLE statement
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_rename_table = FALSE;
|
||||
|
||||
/**
|
||||
* DROP TABLE IF statement
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_drop_table_if = FALSE;
|
||||
|
||||
/**
|
||||
* UNSIGNED support
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_unsigned = array(
|
||||
'SMALLINT' => 'INTEGER',
|
||||
'INTEGER' => 'INT64',
|
||||
'FLOAT' => 'DOUBLE PRECISION'
|
||||
);
|
||||
|
||||
/**
|
||||
* NULL value representation in CREATE/ALTER TABLE statements
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_null = 'NULL';
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Create database
|
||||
*
|
||||
* @param string $db_name
|
||||
* @return string
|
||||
*/
|
||||
public function create_database($db_name)
|
||||
{
|
||||
// Firebird databases are flat files, so a path is required
|
||||
|
||||
// Hostname is needed for remote access
|
||||
empty($this->db->hostname) OR $db_name = $this->hostname.':'.$db_name;
|
||||
|
||||
return parent::create_database('"'.$db_name.'"');
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Drop database
|
||||
*
|
||||
* @param string $db_name (ignored)
|
||||
* @return bool
|
||||
*/
|
||||
public function drop_database($db_name)
|
||||
{
|
||||
if ( ! ibase_drop_db($this->conn_id))
|
||||
{
|
||||
return ($this->db->db_debug) ? $this->db->display_error('db_unable_to_drop') : FALSE;
|
||||
}
|
||||
elseif ( ! empty($this->db->data_cache['db_names']))
|
||||
{
|
||||
$key = array_search(strtolower($this->db->database), array_map('strtolower', $this->db->data_cache['db_names']), TRUE);
|
||||
if ($key !== FALSE)
|
||||
{
|
||||
unset($this->db->data_cache['db_names'][$key]);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* ALTER TABLE
|
||||
*
|
||||
* @param string $alter_type ALTER type
|
||||
* @param string $table Table name
|
||||
* @param mixed $field Column definition
|
||||
* @return string|string[]
|
||||
*/
|
||||
protected function _alter_table($alter_type, $table, $field)
|
||||
{
|
||||
if (in_array($alter_type, array('DROP', 'ADD'), TRUE))
|
||||
{
|
||||
return parent::_alter_table($alter_type, $table, $field);
|
||||
}
|
||||
|
||||
$sql = 'ALTER TABLE '.$this->db->escape_identifiers($table);
|
||||
$sqls = array();
|
||||
for ($i = 0, $c = count($field); $i < $c; $i++)
|
||||
{
|
||||
if ($field[$i]['_literal'] !== FALSE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (isset($field[$i]['type']))
|
||||
{
|
||||
$sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identififers($field[$i]['name'])
|
||||
.' TYPE '.$field[$i]['type'].$field[$i]['length'];
|
||||
}
|
||||
|
||||
if ( ! empty($field[$i]['default']))
|
||||
{
|
||||
$sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identifiers($field[$i]['name'])
|
||||
.' SET DEFAULT '.$field[$i]['default'];
|
||||
}
|
||||
|
||||
if (isset($field[$i]['null']))
|
||||
{
|
||||
$sqls[] = 'UPDATE "RDB$RELATION_FIELDS" SET "RDB$NULL_FLAG" = '
|
||||
.($field[$i]['null'] === TRUE ? 'NULL' : '1')
|
||||
.' WHERE "RDB$FIELD_NAME" = '.$this->db->escape($field[$i]['name'])
|
||||
.' AND "RDB$RELATION_NAME" = '.$this->db->escape($table);
|
||||
}
|
||||
|
||||
if ( ! empty($field[$i]['new_name']))
|
||||
{
|
||||
$sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identifiers($field[$i]['name'])
|
||||
.' TO '.$this->db->escape_identifiers($field[$i]['new_name']);
|
||||
}
|
||||
}
|
||||
|
||||
return $sqls;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Process column
|
||||
*
|
||||
* @param array $field
|
||||
* @return string
|
||||
*/
|
||||
protected function _process_column($field)
|
||||
{
|
||||
return $this->db->escape_identifiers($field['name'])
|
||||
.' '.$field['type'].$field['length']
|
||||
.$field['null']
|
||||
.$field['unique']
|
||||
.$field['default'];
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Field attribute TYPE
|
||||
*
|
||||
* Performs a data type mapping between different databases.
|
||||
*
|
||||
* @param array &$attributes
|
||||
* @return void
|
||||
*/
|
||||
protected function _attr_type(&$attributes)
|
||||
{
|
||||
switch (strtoupper($attributes['TYPE']))
|
||||
{
|
||||
case 'TINYINT':
|
||||
$attributes['TYPE'] = 'SMALLINT';
|
||||
$attributes['UNSIGNED'] = FALSE;
|
||||
return;
|
||||
case 'MEDIUMINT':
|
||||
$attributes['TYPE'] = 'INTEGER';
|
||||
$attributes['UNSIGNED'] = FALSE;
|
||||
return;
|
||||
case 'INT':
|
||||
$attributes['TYPE'] = 'INTEGER';
|
||||
return;
|
||||
case 'BIGINT':
|
||||
$attributes['TYPE'] = 'INT64';
|
||||
return;
|
||||
default: return;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Field attribute AUTO_INCREMENT
|
||||
*
|
||||
* @param array &$attributes
|
||||
* @param array &$field
|
||||
* @return void
|
||||
*/
|
||||
protected function _attr_auto_increment(&$attributes, &$field)
|
||||
{
|
||||
// Not supported
|
||||
}
|
||||
|
||||
}
|
||||
161
system/codeigniter/database/drivers/ibase/ibase_result.php
Executable file
161
system/codeigniter/database/drivers/ibase/ibase_result.php
Executable file
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 3.0.0
|
||||
* @filesource
|
||||
*/
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Interbase/Firebird Result Class
|
||||
*
|
||||
* This class extends the parent result class: CI_DB_result
|
||||
*
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_ibase_result extends CI_DB_result {
|
||||
|
||||
/**
|
||||
* Number of fields in the result set
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function num_fields()
|
||||
{
|
||||
return ibase_num_fields($this->result_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fetch Field Names
|
||||
*
|
||||
* Generates an array of column names
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function list_fields()
|
||||
{
|
||||
$field_names = array();
|
||||
for ($i = 0, $num_fields = $this->num_fields(); $i < $num_fields; $i++)
|
||||
{
|
||||
$info = ibase_field_info($this->result_id, $i);
|
||||
$field_names[] = $info['name'];
|
||||
}
|
||||
|
||||
return $field_names;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Field data
|
||||
*
|
||||
* Generates an array of objects containing field meta-data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function field_data()
|
||||
{
|
||||
$retval = array();
|
||||
for ($i = 0, $c = $this->num_fields(); $i < $c; $i++)
|
||||
{
|
||||
$info = ibase_field_info($this->result_id, $i);
|
||||
|
||||
$retval[$i] = new stdClass();
|
||||
$retval[$i]->name = $info['name'];
|
||||
$retval[$i]->type = $info['type'];
|
||||
$retval[$i]->max_length = $info['length'];
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Free the result
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function free_result()
|
||||
{
|
||||
ibase_free_result($this->result_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Result - associative array
|
||||
*
|
||||
* Returns the result set as an array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function _fetch_assoc()
|
||||
{
|
||||
return ibase_fetch_assoc($this->result_id, IBASE_FETCH_BLOBS);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Result - object
|
||||
*
|
||||
* Returns the result set as an object
|
||||
*
|
||||
* @param string $class_name
|
||||
* @return object
|
||||
*/
|
||||
protected function _fetch_object($class_name = 'stdClass')
|
||||
{
|
||||
$row = ibase_fetch_object($this->result_id, IBASE_FETCH_BLOBS);
|
||||
|
||||
if ($class_name === 'stdClass' OR ! $row)
|
||||
{
|
||||
return $row;
|
||||
}
|
||||
|
||||
$class_name = new $class_name();
|
||||
foreach ($row as $key => $value)
|
||||
{
|
||||
$class_name->$key = $value;
|
||||
}
|
||||
|
||||
return $class_name;
|
||||
}
|
||||
|
||||
}
|
||||
69
system/codeigniter/database/drivers/ibase/ibase_utility.php
Executable file
69
system/codeigniter/database/drivers/ibase/ibase_utility.php
Executable file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 3.0.0
|
||||
* @filesource
|
||||
*/
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Interbase/Firebird Utility Class
|
||||
*
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_ibase_utility extends CI_DB_utility {
|
||||
|
||||
/**
|
||||
* Export
|
||||
*
|
||||
* @param string $filename
|
||||
* @return mixed
|
||||
*/
|
||||
protected function _backup($filename)
|
||||
{
|
||||
if ($service = ibase_service_attach($this->db->hostname, $this->db->username, $this->db->password))
|
||||
{
|
||||
$res = ibase_backup($service, $this->db->database, $filename.'.fbk');
|
||||
|
||||
// Close the service connection
|
||||
ibase_service_detach($service);
|
||||
return $res;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
11
system/codeigniter/database/drivers/ibase/index.html
Executable file
11
system/codeigniter/database/drivers/ibase/index.html
Executable file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
11
system/codeigniter/database/drivers/index.html
Executable file
11
system/codeigniter/database/drivers/index.html
Executable file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
11
system/codeigniter/database/drivers/mssql/index.html
Executable file
11
system/codeigniter/database/drivers/mssql/index.html
Executable file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
518
system/codeigniter/database/drivers/mssql/mssql_driver.php
Executable file
518
system/codeigniter/database/drivers/mssql/mssql_driver.php
Executable file
@@ -0,0 +1,518 @@
|
||||
<?php
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.3.0
|
||||
* @filesource
|
||||
*/
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* MS SQL Database Adapter Class
|
||||
*
|
||||
* Note: _DB is an extender class that the app controller
|
||||
* creates dynamically based on whether the query builder
|
||||
* class is being used or not.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_mssql_driver extends CI_DB {
|
||||
|
||||
/**
|
||||
* Database driver
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $dbdriver = 'mssql';
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* ORDER BY random keyword
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_random_keyword = array('NEWID()', 'RAND(%d)');
|
||||
|
||||
/**
|
||||
* Quoted identifier flag
|
||||
*
|
||||
* Whether to use SQL-92 standard quoted identifier
|
||||
* (double quotes) or brackets for identifier escaping.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $_quoted_identifier = TRUE;
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* Appends the port number to the hostname, if needed.
|
||||
*
|
||||
* @param array $params
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($params)
|
||||
{
|
||||
parent::__construct($params);
|
||||
|
||||
if ( ! empty($this->port))
|
||||
{
|
||||
$this->hostname .= (DIRECTORY_SEPARATOR === '\\' ? ',' : ':').$this->port;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Non-persistent database connection
|
||||
*
|
||||
* @param bool $persistent
|
||||
* @return resource
|
||||
*/
|
||||
public function db_connect($persistent = FALSE)
|
||||
{
|
||||
$this->conn_id = ($persistent)
|
||||
? mssql_pconnect($this->hostname, $this->username, $this->password)
|
||||
: mssql_connect($this->hostname, $this->username, $this->password);
|
||||
|
||||
if ( ! $this->conn_id)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
// Select the DB... assuming a database name is specified in the config file
|
||||
if ($this->database !== '' && ! $this->db_select())
|
||||
{
|
||||
log_message('error', 'Unable to select database: '.$this->database);
|
||||
|
||||
return ($this->db_debug === TRUE)
|
||||
? $this->display_error('db_unable_to_select', $this->database)
|
||||
: FALSE;
|
||||
}
|
||||
|
||||
// Determine how identifiers are escaped
|
||||
$query = $this->query('SELECT CASE WHEN (@@OPTIONS | 256) = @@OPTIONS THEN 1 ELSE 0 END AS qi');
|
||||
$query = $query->row_array();
|
||||
$this->_quoted_identifier = empty($query) ? FALSE : (bool) $query['qi'];
|
||||
$this->_escape_char = ($this->_quoted_identifier) ? '"' : array('[', ']');
|
||||
|
||||
return $this->conn_id;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Select the database
|
||||
*
|
||||
* @param string $database
|
||||
* @return bool
|
||||
*/
|
||||
public function db_select($database = '')
|
||||
{
|
||||
if ($database === '')
|
||||
{
|
||||
$database = $this->database;
|
||||
}
|
||||
|
||||
// Note: Escaping is required in the event that the DB name
|
||||
// contains reserved characters.
|
||||
if (mssql_select_db('['.$database.']', $this->conn_id))
|
||||
{
|
||||
$this->database = $database;
|
||||
$this->data_cache = array();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Execute the query
|
||||
*
|
||||
* @param string $sql an SQL query
|
||||
* @return mixed resource if rows are returned, bool otherwise
|
||||
*/
|
||||
protected function _execute($sql)
|
||||
{
|
||||
return mssql_query($sql, $this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Begin Transaction
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function _trans_begin()
|
||||
{
|
||||
return $this->simple_query('BEGIN TRAN');
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Commit Transaction
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function _trans_commit()
|
||||
{
|
||||
return $this->simple_query('COMMIT TRAN');
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Rollback Transaction
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function _trans_rollback()
|
||||
{
|
||||
return $this->simple_query('ROLLBACK TRAN');
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Affected Rows
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function affected_rows()
|
||||
{
|
||||
return mssql_rows_affected($this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Insert ID
|
||||
*
|
||||
* Returns the last id created in the Identity column.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function insert_id()
|
||||
{
|
||||
$query = version_compare($this->version(), '8', '>=')
|
||||
? 'SELECT SCOPE_IDENTITY() AS last_id'
|
||||
: 'SELECT @@IDENTITY AS last_id';
|
||||
|
||||
$query = $this->query($query);
|
||||
$query = $query->row();
|
||||
return $query->last_id;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set client character set
|
||||
*
|
||||
* @param string $charset
|
||||
* @return bool
|
||||
*/
|
||||
protected function _db_set_charset($charset)
|
||||
{
|
||||
return (ini_set('mssql.charset', $charset) !== FALSE);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Version number query string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _version()
|
||||
{
|
||||
return "SELECT SERVERPROPERTY('ProductVersion') AS ver";
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* List table query
|
||||
*
|
||||
* Generates a platform-specific query string so that the table names can be fetched
|
||||
*
|
||||
* @param bool $prefix_limit
|
||||
* @return string
|
||||
*/
|
||||
protected function _list_tables($prefix_limit = FALSE)
|
||||
{
|
||||
$sql = 'SELECT '.$this->escape_identifiers('name')
|
||||
.' FROM '.$this->escape_identifiers('sysobjects')
|
||||
.' WHERE '.$this->escape_identifiers('type')." = 'U'";
|
||||
|
||||
if ($prefix_limit !== FALSE && $this->dbprefix !== '')
|
||||
{
|
||||
$sql .= ' AND '.$this->escape_identifiers('name')." LIKE '".$this->escape_like_str($this->dbprefix)."%' "
|
||||
.sprintf($this->_like_escape_str, $this->_like_escape_chr);
|
||||
}
|
||||
|
||||
return $sql.' ORDER BY '.$this->escape_identifiers('name');
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* List column query
|
||||
*
|
||||
* Generates a platform-specific query string so that the column names can be fetched
|
||||
*
|
||||
* @param string $table
|
||||
* @return string
|
||||
*/
|
||||
protected function _list_columns($table = '')
|
||||
{
|
||||
return 'SELECT COLUMN_NAME
|
||||
FROM INFORMATION_SCHEMA.Columns
|
||||
WHERE UPPER(TABLE_NAME) = '.$this->escape(strtoupper($table));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns an object with field data
|
||||
*
|
||||
* @param string $table
|
||||
* @return array
|
||||
*/
|
||||
public function field_data($table)
|
||||
{
|
||||
$sql = 'SELECT COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, NUMERIC_PRECISION, COLUMN_DEFAULT
|
||||
FROM INFORMATION_SCHEMA.Columns
|
||||
WHERE UPPER(TABLE_NAME) = '.$this->escape(strtoupper($table));
|
||||
|
||||
if (($query = $this->query($sql)) === FALSE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
$query = $query->result_object();
|
||||
|
||||
$retval = array();
|
||||
for ($i = 0, $c = count($query); $i < $c; $i++)
|
||||
{
|
||||
$retval[$i] = new stdClass();
|
||||
$retval[$i]->name = $query[$i]->COLUMN_NAME;
|
||||
$retval[$i]->type = $query[$i]->DATA_TYPE;
|
||||
$retval[$i]->max_length = ($query[$i]->CHARACTER_MAXIMUM_LENGTH > 0) ? $query[$i]->CHARACTER_MAXIMUM_LENGTH : $query[$i]->NUMERIC_PRECISION;
|
||||
$retval[$i]->default = $query[$i]->COLUMN_DEFAULT;
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Error
|
||||
*
|
||||
* Returns an array containing code and message of the last
|
||||
* database error that has occurred.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function error()
|
||||
{
|
||||
// We need this because the error info is discarded by the
|
||||
// server the first time you request it, and query() already
|
||||
// calls error() once for logging purposes when a query fails.
|
||||
static $error = array('code' => 0, 'message' => NULL);
|
||||
|
||||
$message = mssql_get_last_message();
|
||||
if ( ! empty($message))
|
||||
{
|
||||
$error['code'] = $this->query('SELECT @@ERROR AS code')->row()->code;
|
||||
$error['message'] = $message;
|
||||
}
|
||||
|
||||
return $error;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Update statement
|
||||
*
|
||||
* Generates a platform-specific update string from the supplied data
|
||||
*
|
||||
* @param string $table
|
||||
* @param array $values
|
||||
* @return string
|
||||
*/
|
||||
protected function _update($table, $values)
|
||||
{
|
||||
$this->qb_limit = FALSE;
|
||||
$this->qb_orderby = array();
|
||||
return parent::_update($table, $values);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Truncate statement
|
||||
*
|
||||
* Generates a platform-specific truncate string from the supplied data
|
||||
*
|
||||
* If the database does not support the TRUNCATE statement,
|
||||
* then this method maps to 'DELETE FROM table'
|
||||
*
|
||||
* @param string $table
|
||||
* @return string
|
||||
*/
|
||||
protected function _truncate($table)
|
||||
{
|
||||
return 'TRUNCATE TABLE '.$table;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Delete statement
|
||||
*
|
||||
* Generates a platform-specific delete string from the supplied data
|
||||
*
|
||||
* @param string $table
|
||||
* @return string
|
||||
*/
|
||||
protected function _delete($table)
|
||||
{
|
||||
if ($this->qb_limit)
|
||||
{
|
||||
return 'WITH ci_delete AS (SELECT TOP '.$this->qb_limit.' * FROM '.$table.$this->_compile_wh('qb_where').') DELETE FROM ci_delete';
|
||||
}
|
||||
|
||||
return parent::_delete($table);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* LIMIT
|
||||
*
|
||||
* Generates a platform-specific LIMIT clause
|
||||
*
|
||||
* @param string $sql SQL Query
|
||||
* @return string
|
||||
*/
|
||||
protected function _limit($sql)
|
||||
{
|
||||
$limit = $this->qb_offset + $this->qb_limit;
|
||||
|
||||
// As of SQL Server 2005 (9.0.*) ROW_NUMBER() is supported,
|
||||
// however an ORDER BY clause is required for it to work
|
||||
if (version_compare($this->version(), '9', '>=') && $this->qb_offset && ! empty($this->qb_orderby))
|
||||
{
|
||||
$orderby = $this->_compile_order_by();
|
||||
|
||||
// We have to strip the ORDER BY clause
|
||||
$sql = trim(substr($sql, 0, strrpos($sql, $orderby)));
|
||||
|
||||
// Get the fields to select from our subquery, so that we can avoid CI_rownum appearing in the actual results
|
||||
if (count($this->qb_select) === 0)
|
||||
{
|
||||
$select = '*'; // Inevitable
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use only field names and their aliases, everything else is out of our scope.
|
||||
$select = array();
|
||||
$field_regexp = ($this->_quoted_identifier)
|
||||
? '("[^\"]+")' : '(\[[^\]]+\])';
|
||||
for ($i = 0, $c = count($this->qb_select); $i < $c; $i++)
|
||||
{
|
||||
$select[] = preg_match('/(?:\s|\.)'.$field_regexp.'$/i', $this->qb_select[$i], $m)
|
||||
? $m[1] : $this->qb_select[$i];
|
||||
}
|
||||
$select = implode(', ', $select);
|
||||
}
|
||||
|
||||
return 'SELECT '.$select." FROM (\n\n"
|
||||
.preg_replace('/^(SELECT( DISTINCT)?)/i', '\\1 ROW_NUMBER() OVER('.trim($orderby).') AS '.$this->escape_identifiers('CI_rownum').', ', $sql)
|
||||
."\n\n) ".$this->escape_identifiers('CI_subquery')
|
||||
."\nWHERE ".$this->escape_identifiers('CI_rownum').' BETWEEN '.($this->qb_offset + 1).' AND '.$limit;
|
||||
}
|
||||
|
||||
return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$limit.' ', $sql);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Insert batch statement
|
||||
*
|
||||
* Generates a platform-specific insert string from the supplied data.
|
||||
*
|
||||
* @param string $table Table name
|
||||
* @param array $keys INSERT keys
|
||||
* @param array $values INSERT values
|
||||
* @return string|bool
|
||||
*/
|
||||
protected function _insert_batch($table, $keys, $values)
|
||||
{
|
||||
// Multiple-value inserts are only supported as of SQL Server 2008
|
||||
if (version_compare($this->version(), '10', '>='))
|
||||
{
|
||||
return parent::_insert_batch($table, $keys, $values);
|
||||
}
|
||||
|
||||
return ($this->db_debug) ? $this->display_error('db_unsupported_feature') : FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Close DB Connection
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _close()
|
||||
{
|
||||
mssql_close($this->conn_id);
|
||||
}
|
||||
|
||||
}
|
||||
151
system/codeigniter/database/drivers/mssql/mssql_forge.php
Executable file
151
system/codeigniter/database/drivers/mssql/mssql_forge.php
Executable file
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.3.0
|
||||
* @filesource
|
||||
*/
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* MS SQL Forge Class
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_mssql_forge extends CI_DB_forge {
|
||||
|
||||
/**
|
||||
* CREATE TABLE IF statement
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_create_table_if = "IF NOT EXISTS (SELECT * FROM sysobjects WHERE ID = object_id(N'%s') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)\nCREATE TABLE";
|
||||
|
||||
/**
|
||||
* DROP TABLE IF statement
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_drop_table_if = "IF EXISTS (SELECT * FROM sysobjects WHERE ID = object_id(N'%s') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)\nDROP TABLE";
|
||||
|
||||
/**
|
||||
* UNSIGNED support
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_unsigned = array(
|
||||
'TINYINT' => 'SMALLINT',
|
||||
'SMALLINT' => 'INT',
|
||||
'INT' => 'BIGINT',
|
||||
'REAL' => 'FLOAT'
|
||||
);
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* ALTER TABLE
|
||||
*
|
||||
* @param string $alter_type ALTER type
|
||||
* @param string $table Table name
|
||||
* @param mixed $field Column definition
|
||||
* @return string|string[]
|
||||
*/
|
||||
protected function _alter_table($alter_type, $table, $field)
|
||||
{
|
||||
if (in_array($alter_type, array('ADD', 'DROP'), TRUE))
|
||||
{
|
||||
return parent::_alter_table($alter_type, $table, $field);
|
||||
}
|
||||
|
||||
$sql = 'ALTER TABLE '.$this->db->escape_identifiers($table).' ALTER COLUMN ';
|
||||
$sqls = array();
|
||||
for ($i = 0, $c = count($field); $i < $c; $i++)
|
||||
{
|
||||
$sqls[] = $sql.$this->_process_column($field[$i]);
|
||||
}
|
||||
|
||||
return $sqls;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Field attribute TYPE
|
||||
*
|
||||
* Performs a data type mapping between different databases.
|
||||
*
|
||||
* @param array &$attributes
|
||||
* @return void
|
||||
*/
|
||||
protected function _attr_type(&$attributes)
|
||||
{
|
||||
if (isset($attributes['CONSTRAINT']) && strpos($attributes['TYPE'], 'INT') !== FALSE)
|
||||
{
|
||||
unset($attributes['CONSTRAINT']);
|
||||
}
|
||||
|
||||
switch (strtoupper($attributes['TYPE']))
|
||||
{
|
||||
case 'MEDIUMINT':
|
||||
$attributes['TYPE'] = 'INTEGER';
|
||||
$attributes['UNSIGNED'] = FALSE;
|
||||
return;
|
||||
case 'INTEGER':
|
||||
$attributes['TYPE'] = 'INT';
|
||||
return;
|
||||
default: return;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Field attribute AUTO_INCREMENT
|
||||
*
|
||||
* @param array &$attributes
|
||||
* @param array &$field
|
||||
* @return void
|
||||
*/
|
||||
protected function _attr_auto_increment(&$attributes, &$field)
|
||||
{
|
||||
if ( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE && stripos($field['type'], 'int') !== FALSE)
|
||||
{
|
||||
$field['auto_increment'] = ' IDENTITY(1,1)';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
198
system/codeigniter/database/drivers/mssql/mssql_result.php
Executable file
198
system/codeigniter/database/drivers/mssql/mssql_result.php
Executable file
@@ -0,0 +1,198 @@
|
||||
<?php
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.3.0
|
||||
* @filesource
|
||||
*/
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* MSSQL Result Class
|
||||
*
|
||||
* This class extends the parent result class: CI_DB_result
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_mssql_result extends CI_DB_result {
|
||||
|
||||
/**
|
||||
* Number of rows in the result set
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function num_rows()
|
||||
{
|
||||
return is_int($this->num_rows)
|
||||
? $this->num_rows
|
||||
: $this->num_rows = mssql_num_rows($this->result_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Number of fields in the result set
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function num_fields()
|
||||
{
|
||||
return mssql_num_fields($this->result_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fetch Field Names
|
||||
*
|
||||
* Generates an array of column names
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function list_fields()
|
||||
{
|
||||
$field_names = array();
|
||||
mssql_field_seek($this->result_id, 0);
|
||||
while ($field = mssql_fetch_field($this->result_id))
|
||||
{
|
||||
$field_names[] = $field->name;
|
||||
}
|
||||
|
||||
return $field_names;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Field data
|
||||
*
|
||||
* Generates an array of objects containing field meta-data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function field_data()
|
||||
{
|
||||
$retval = array();
|
||||
for ($i = 0, $c = $this->num_fields(); $i < $c; $i++)
|
||||
{
|
||||
$field = mssql_fetch_field($this->result_id, $i);
|
||||
|
||||
$retval[$i] = new stdClass();
|
||||
$retval[$i]->name = $field->name;
|
||||
$retval[$i]->type = $field->type;
|
||||
$retval[$i]->max_length = $field->max_length;
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Free the result
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public 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.
|
||||
*
|
||||
* @param int $n
|
||||
* @return bool
|
||||
*/
|
||||
public function data_seek($n = 0)
|
||||
{
|
||||
return mssql_data_seek($this->result_id, $n);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Result - associative array
|
||||
*
|
||||
* Returns the result set as an array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function _fetch_assoc()
|
||||
{
|
||||
return mssql_fetch_assoc($this->result_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Result - object
|
||||
*
|
||||
* Returns the result set as an object
|
||||
*
|
||||
* @param string $class_name
|
||||
* @return object
|
||||
*/
|
||||
protected function _fetch_object($class_name = 'stdClass')
|
||||
{
|
||||
$row = mssql_fetch_object($this->result_id);
|
||||
|
||||
if ($class_name === 'stdClass' OR ! $row)
|
||||
{
|
||||
return $row;
|
||||
}
|
||||
|
||||
$class_name = new $class_name();
|
||||
foreach ($row as $key => $value)
|
||||
{
|
||||
$class_name->$key = $value;
|
||||
}
|
||||
|
||||
return $class_name;
|
||||
}
|
||||
|
||||
}
|
||||
77
system/codeigniter/database/drivers/mssql/mssql_utility.php
Executable file
77
system/codeigniter/database/drivers/mssql/mssql_utility.php
Executable file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.3.0
|
||||
* @filesource
|
||||
*/
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* MS SQL Utility Class
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_mssql_utility extends CI_DB_utility {
|
||||
|
||||
/**
|
||||
* List databases statement
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_list_databases = 'EXEC sp_helpdb'; // Can also be: EXEC sp_databases
|
||||
|
||||
/**
|
||||
* OPTIMIZE TABLE statement
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_optimize_table = 'ALTER INDEX all ON %s REORGANIZE';
|
||||
|
||||
/**
|
||||
* Export
|
||||
*
|
||||
* @param array $params Preferences
|
||||
* @return bool
|
||||
*/
|
||||
protected function _backup($params = array())
|
||||
{
|
||||
// Currently unsupported
|
||||
return $this->db->display_error('db_unsupported_feature');
|
||||
}
|
||||
|
||||
}
|
||||
11
system/codeigniter/database/drivers/mysql/index.html
Executable file
11
system/codeigniter/database/drivers/mysql/index.html
Executable file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
548
system/codeigniter/database/drivers/mysql/mysql_driver.php
Executable file
548
system/codeigniter/database/drivers/mysql/mysql_driver.php
Executable file
@@ -0,0 +1,548 @@
|
||||
<?php
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
* @filesource
|
||||
*/
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* MySQL Database Adapter Class
|
||||
*
|
||||
* Note: _DB is an extender class that the app controller
|
||||
* creates dynamically based on whether the query builder
|
||||
* class is being used or not.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
*/
|
||||
class CI_DB_mysql_driver extends CI_DB {
|
||||
|
||||
/**
|
||||
* Database driver
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $dbdriver = 'mysql';
|
||||
|
||||
/**
|
||||
* Compression flag
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $compress = FALSE;
|
||||
|
||||
/**
|
||||
* DELETE hack flag
|
||||
*
|
||||
* 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 bool
|
||||
*/
|
||||
public $delete_hack = TRUE;
|
||||
|
||||
/**
|
||||
* Strict ON flag
|
||||
*
|
||||
* Whether we're running in strict SQL mode.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $stricton;
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Identifier escape character
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_escape_char = '`';
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param array $params
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($params)
|
||||
{
|
||||
parent::__construct($params);
|
||||
|
||||
if ( ! empty($this->port))
|
||||
{
|
||||
$this->hostname .= ':'.$this->port;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Non-persistent database connection
|
||||
*
|
||||
* @param bool $persistent
|
||||
* @return resource
|
||||
*/
|
||||
public function db_connect($persistent = FALSE)
|
||||
{
|
||||
$client_flags = ($this->compress === FALSE) ? 0 : MYSQL_CLIENT_COMPRESS;
|
||||
|
||||
if ($this->encrypt === TRUE)
|
||||
{
|
||||
$client_flags = $client_flags | MYSQL_CLIENT_SSL;
|
||||
}
|
||||
|
||||
// Error suppression is necessary mostly due to PHP 5.5+ issuing E_DEPRECATED messages
|
||||
$this->conn_id = ($persistent === TRUE)
|
||||
? mysql_pconnect($this->hostname, $this->username, $this->password, $client_flags)
|
||||
: mysql_connect($this->hostname, $this->username, $this->password, TRUE, $client_flags);
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
// Select the DB... assuming a database name is specified in the config file
|
||||
if ($this->database !== '' && ! $this->db_select())
|
||||
{
|
||||
log_message('error', 'Unable to select database: '.$this->database);
|
||||
|
||||
return ($this->db_debug === TRUE)
|
||||
? $this->display_error('db_unable_to_select', $this->database)
|
||||
: FALSE;
|
||||
}
|
||||
|
||||
if (isset($this->stricton) && is_resource($this->conn_id))
|
||||
{
|
||||
if ($this->stricton)
|
||||
{
|
||||
$this->simple_query('SET SESSION sql_mode = CONCAT(@@sql_mode, ",", "STRICT_ALL_TABLES")');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->simple_query(
|
||||
'SET SESSION sql_mode =
|
||||
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
|
||||
@@sql_mode,
|
||||
"STRICT_ALL_TABLES,", ""),
|
||||
",STRICT_ALL_TABLES", ""),
|
||||
"STRICT_ALL_TABLES", ""),
|
||||
"STRICT_TRANS_TABLES,", ""),
|
||||
",STRICT_TRANS_TABLES", ""),
|
||||
"STRICT_TRANS_TABLES", "")'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->conn_id;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Reconnect
|
||||
*
|
||||
* Keep / reestablish the db connection if no queries have been
|
||||
* sent for a length of time exceeding the server's idle timeout
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function reconnect()
|
||||
{
|
||||
if (@mysql_ping($this->conn_id) === FALSE)
|
||||
{
|
||||
$this->conn_id = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Select the database
|
||||
*
|
||||
* @param string $database
|
||||
* @return bool
|
||||
*/
|
||||
public function db_select($database = '')
|
||||
{
|
||||
if ($database === '')
|
||||
{
|
||||
$database = $this->database;
|
||||
}
|
||||
|
||||
if (mysql_select_db($database, $this->conn_id))
|
||||
{
|
||||
$this->database = $database;
|
||||
$this->data_cache = array();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set client character set
|
||||
*
|
||||
* @param string $charset
|
||||
* @return bool
|
||||
*/
|
||||
protected function _db_set_charset($charset)
|
||||
{
|
||||
return mysql_set_charset($charset, $this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Database version number
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function version()
|
||||
{
|
||||
if (isset($this->data_cache['version']))
|
||||
{
|
||||
return $this->data_cache['version'];
|
||||
}
|
||||
|
||||
if ( ! $this->conn_id OR ($version = mysql_get_server_info($this->conn_id)) === FALSE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return $this->data_cache['version'] = $version;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Execute the query
|
||||
*
|
||||
* @param string $sql an SQL query
|
||||
* @return mixed
|
||||
*/
|
||||
protected function _execute($sql)
|
||||
{
|
||||
return mysql_query($this->_prep_query($sql), $this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Prep the query
|
||||
*
|
||||
* If needed, each database adapter can prep the query string
|
||||
*
|
||||
* @param string $sql an SQL query
|
||||
* @return string
|
||||
*/
|
||||
protected function _prep_query($sql)
|
||||
{
|
||||
// mysql_affected_rows() returns 0 for "DELETE FROM TABLE" queries. This hack
|
||||
// modifies the query so that it a proper number of affected rows is returned.
|
||||
if ($this->delete_hack === TRUE && preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $sql))
|
||||
{
|
||||
return trim($sql).' WHERE 1=1';
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Begin Transaction
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function _trans_begin()
|
||||
{
|
||||
$this->simple_query('SET AUTOCOMMIT=0');
|
||||
return $this->simple_query('START TRANSACTION'); // can also be BEGIN or BEGIN WORK
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Commit Transaction
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function _trans_commit()
|
||||
{
|
||||
if ($this->simple_query('COMMIT'))
|
||||
{
|
||||
$this->simple_query('SET AUTOCOMMIT=1');
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Rollback Transaction
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function _trans_rollback()
|
||||
{
|
||||
if ($this->simple_query('ROLLBACK'))
|
||||
{
|
||||
$this->simple_query('SET AUTOCOMMIT=1');
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Platform-dependent string escape
|
||||
*
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
protected function _escape_str($str)
|
||||
{
|
||||
return mysql_real_escape_string($str, $this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Affected Rows
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function affected_rows()
|
||||
{
|
||||
return mysql_affected_rows($this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
######
|
||||
# Begin Bruno Changes
|
||||
#
|
||||
# This code is necessary to alert Pancake models when an insert occurs,
|
||||
# so they can do whatever they want to do. If you update this file,
|
||||
# include these changes!
|
||||
#
|
||||
# The reason $this->locked_id and $this->inside_callbacks is necessary
|
||||
# is that we don't want the result of insert_id() to change because of
|
||||
# callbacks inserting records. This way, the insert_id() return is
|
||||
# always the one related to the insert query, not any onInsert callbacks.
|
||||
#
|
||||
######
|
||||
|
||||
public $onInsertCallbacks = array();
|
||||
public $locked_id = false;
|
||||
public $inside_callbacks = false;
|
||||
|
||||
/**
|
||||
* Insert ID
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function insert_id()
|
||||
{
|
||||
return $this->locked_id === false ? mysql_insert_id($this->conn_id) : $this->locked_id;
|
||||
}
|
||||
|
||||
function insert($table = '', $set = null, $escape = null) {
|
||||
if (!$this->inside_callbacks) {
|
||||
$this->locked_id = false;
|
||||
}
|
||||
$result = parent::insert($table, $set, $escape);
|
||||
|
||||
if ($this->inside_callbacks) {
|
||||
# Callbacks aren't called when running a query in a callback.
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ($result) {
|
||||
$this->locked_id = $this->insert_id();
|
||||
$this->inside_callbacks = true;
|
||||
foreach ($this->onInsertCallbacks as $callback) {
|
||||
call_user_func_array($callback, array($table, $this->locked_id));
|
||||
}
|
||||
$this->inside_callbacks = false;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function onInsert($callback = null) {
|
||||
if (is_callable($callback)) {
|
||||
$this->onInsertCallbacks[] = $callback;
|
||||
} else {
|
||||
throw new Exception("$callback is not callable!");
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* List table query
|
||||
*
|
||||
* Generates a platform-specific query string so that the table names can be fetched
|
||||
*
|
||||
* @param bool $prefix_limit
|
||||
* @return string
|
||||
*/
|
||||
protected function _list_tables($prefix_limit = FALSE)
|
||||
{
|
||||
$sql = 'SHOW TABLES FROM `' . $this->database . '`';
|
||||
|
||||
if ($prefix_limit !== FALSE && $this->dbprefix !== '')
|
||||
{
|
||||
return $sql." LIKE '".$this->escape_like_str($this->dbprefix)."%'";
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
######
|
||||
# End Bruno Changes
|
||||
######
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Show column query
|
||||
*
|
||||
* Generates a platform-specific query string so that the column names can be fetched
|
||||
*
|
||||
* @param string $table
|
||||
* @return string
|
||||
*/
|
||||
protected function _list_columns($table = '')
|
||||
{
|
||||
return 'SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns an object with field data
|
||||
*
|
||||
* @param string $table
|
||||
* @return array
|
||||
*/
|
||||
public function field_data($table)
|
||||
{
|
||||
if (($query = $this->query('SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE))) === FALSE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
$query = $query->result_object();
|
||||
|
||||
$retval = array();
|
||||
for ($i = 0, $c = count($query); $i < $c; $i++)
|
||||
{
|
||||
$retval[$i] = new stdClass();
|
||||
$retval[$i]->name = $query[$i]->Field;
|
||||
|
||||
sscanf($query[$i]->Type, '%[a-z](%d)',
|
||||
$retval[$i]->type,
|
||||
$retval[$i]->max_length
|
||||
);
|
||||
|
||||
$retval[$i]->default = $query[$i]->Default;
|
||||
$retval[$i]->primary_key = (int) ($query[$i]->Key === 'PRI');
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Error
|
||||
*
|
||||
* Returns an array containing code and message of the last
|
||||
* database error that has occurred.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function error()
|
||||
{
|
||||
return array('code' => mysql_errno($this->conn_id), 'message' => mysql_error($this->conn_id));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* FROM tables
|
||||
*
|
||||
* Groups tables in FROM clauses if needed, so there is no confusion
|
||||
* about operator precedence.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _from_tables()
|
||||
{
|
||||
if ( ! empty($this->qb_join) && count($this->qb_from) > 1)
|
||||
{
|
||||
return '('.implode(', ', $this->qb_from).')';
|
||||
}
|
||||
|
||||
return implode(', ', $this->qb_from);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Close DB Connection
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _close()
|
||||
{
|
||||
// Error suppression to avoid annoying E_WARNINGs in cases
|
||||
// where the connection has already been closed for some reason.
|
||||
@mysql_close($this->conn_id);
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user