diff options
author | Florian Pritz <bluewind@server-speed.net> | 2011-01-28 22:51:06 +0100 |
---|---|---|
committer | Florian Pritz <bluewind@server-speed.net> | 2011-01-28 22:58:52 +0100 |
commit | ce2b69675075444c9e40b72bcdd42ab7edbbe633 (patch) | |
tree | 2932f13b0db14fe53dc0622d888318db638a017f | |
parent | b6b8a6587c399bfd89e13e92ce04ee8486688e6e (diff) |
update to CI 2.0
Signed-off-by: Florian Pritz <bluewind@server-speed.net>
-rwxr-xr-x | application/cache/index.html (renamed from system/application/config/index.html) | 0 | ||||
-rw-r--r-- | application/config/.gitignore (renamed from system/application/config/.gitignore) | 0 | ||||
-rw-r--r-- | application/config/example/.gitignore (renamed from system/application/config/example/.gitignore) | 0 | ||||
-rwxr-xr-x | application/config/example/autoload.php (renamed from system/application/config/example/autoload.php) | 36 | ||||
-rwxr-xr-x | application/config/example/config.php (renamed from system/application/config/example/config.php) | 94 | ||||
-rwxr-xr-x | application/config/example/constants.php (renamed from system/application/config/example/constants.php) | 14 | ||||
-rwxr-xr-x | application/config/example/database.php (renamed from system/application/config/example/database.php) | 12 | ||||
-rwxr-xr-x | application/config/example/doctypes.php (renamed from system/application/config/example/doctypes.php) | 2 | ||||
-rwxr-xr-x | application/config/example/foreign_chars.php | 64 | ||||
-rwxr-xr-x | application/config/example/hooks.php (renamed from system/application/config/example/hooks.php) | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | application/config/example/index.html (renamed from system/application/controllers/index.html) | 0 | ||||
-rw-r--r-- | application/config/example/memcache.php (renamed from system/application/config/example/memcache.php) | 0 | ||||
-rwxr-xr-x | application/config/example/mimes.php (renamed from system/application/config/example/mimes.php) | 10 | ||||
-rwxr-xr-x | application/config/example/profiler.php | 17 | ||||
-rwxr-xr-x | application/config/example/routes.php (renamed from system/application/config/example/routes.php) | 16 | ||||
-rwxr-xr-x | application/config/example/smileys.php (renamed from system/application/config/example/smileys.php) | 4 | ||||
-rwxr-xr-x | application/config/example/user_agents.php (renamed from system/application/config/example/user_agents.php) | 13 | ||||
-rwxr-xr-x[-rw-r--r--] | application/config/index.html (renamed from system/application/errors/index.html) | 0 | ||||
-rw-r--r-- | application/controllers/file.php (renamed from system/application/controllers/file.php) | 4 | ||||
-rw-r--r-- | application/controllers/index.html (renamed from system/application/helpers/index.html) | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | application/core/index.html (renamed from system/application/hooks/index.html) | 0 | ||||
-rw-r--r-- | application/errors/error_404.php (renamed from system/application/errors/error_404.php) | 0 | ||||
-rw-r--r-- | application/errors/error_db.php (renamed from system/application/errors/error_db.php) | 0 | ||||
-rw-r--r-- | application/errors/error_general.php (renamed from system/application/errors/error_general.php) | 0 | ||||
-rw-r--r-- | application/errors/error_php.php (renamed from system/application/errors/error_php.php) | 0 | ||||
-rw-r--r-- | application/errors/index.html (renamed from system/application/index.html) | 0 | ||||
-rw-r--r-- | application/helpers/filebin_helper.php (renamed from system/application/helpers/filebin_helper.php) | 0 | ||||
-rw-r--r-- | application/helpers/index.html (renamed from system/application/language/english/index.html) | 0 | ||||
-rw-r--r-- | application/hooks/index.html (renamed from system/application/libraries/index.html) | 0 | ||||
-rw-r--r-- | application/index.html (renamed from system/application/models/index.html) | 0 | ||||
-rw-r--r-- | application/language/english/index.html (renamed from system/application/views/index.html) | 0 | ||||
-rw-r--r-- | application/libraries/MemcacheLibrary.php (renamed from system/application/libraries/MemcacheLibrary.php) | 0 | ||||
-rw-r--r-- | application/libraries/contrib/aliased.php (renamed from system/application/libraries/contrib/aliased.php) | 0 | ||||
-rw-r--r-- | application/libraries/contrib/cssgen.php (renamed from system/application/libraries/contrib/cssgen.php) | 0 | ||||
-rw-r--r-- | application/libraries/contrib/cssgen2.php (renamed from system/application/libraries/contrib/cssgen2.php) | 0 | ||||
-rw-r--r-- | application/libraries/contrib/example.php (renamed from system/application/libraries/contrib/example.php) | 0 | ||||
-rw-r--r-- | application/libraries/contrib/langcheck.php (renamed from system/application/libraries/contrib/langcheck.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi.php (renamed from system/application/libraries/geshi.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/4cs.php (renamed from system/application/libraries/geshi/4cs.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/abap.php (renamed from system/application/libraries/geshi/abap.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/actionscript.php (renamed from system/application/libraries/geshi/actionscript.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/actionscript3.php (renamed from system/application/libraries/geshi/actionscript3.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/ada.php (renamed from system/application/libraries/geshi/ada.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/apache.php (renamed from system/application/libraries/geshi/apache.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/applescript.php (renamed from system/application/libraries/geshi/applescript.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/apt_sources.php (renamed from system/application/libraries/geshi/apt_sources.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/asm.php (renamed from system/application/libraries/geshi/asm.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/asp.php (renamed from system/application/libraries/geshi/asp.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/autohotkey.php (renamed from system/application/libraries/geshi/autohotkey.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/autoit.php (renamed from system/application/libraries/geshi/autoit.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/avisynth.php (renamed from system/application/libraries/geshi/avisynth.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/awk.php (renamed from system/application/libraries/geshi/awk.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/bash.php (renamed from system/application/libraries/geshi/bash.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/basic4gl.php (renamed from system/application/libraries/geshi/basic4gl.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/bf.php (renamed from system/application/libraries/geshi/bf.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/bibtex.php (renamed from system/application/libraries/geshi/bibtex.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/blitzbasic.php (renamed from system/application/libraries/geshi/blitzbasic.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/bnf.php (renamed from system/application/libraries/geshi/bnf.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/boo.php (renamed from system/application/libraries/geshi/boo.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/c.php (renamed from system/application/libraries/geshi/c.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/c_mac.php (renamed from system/application/libraries/geshi/c_mac.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/caddcl.php (renamed from system/application/libraries/geshi/caddcl.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/cadlisp.php (renamed from system/application/libraries/geshi/cadlisp.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/cfdg.php (renamed from system/application/libraries/geshi/cfdg.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/cfm.php (renamed from system/application/libraries/geshi/cfm.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/cil.php (renamed from system/application/libraries/geshi/cil.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/clojure.php (renamed from system/application/libraries/geshi/clojure.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/cmake.php (renamed from system/application/libraries/geshi/cmake.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/cobol.php (renamed from system/application/libraries/geshi/cobol.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/cpp-qt.php (renamed from system/application/libraries/geshi/cpp-qt.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/cpp.php (renamed from system/application/libraries/geshi/cpp.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/csharp.php (renamed from system/application/libraries/geshi/csharp.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/css.php (renamed from system/application/libraries/geshi/css.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/cuesheet.php (renamed from system/application/libraries/geshi/cuesheet.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/d.php (renamed from system/application/libraries/geshi/d.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/dcs.php (renamed from system/application/libraries/geshi/dcs.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/delphi.php (renamed from system/application/libraries/geshi/delphi.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/diff.php (renamed from system/application/libraries/geshi/diff.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/div.php (renamed from system/application/libraries/geshi/div.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/dos.php (renamed from system/application/libraries/geshi/dos.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/dot.php (renamed from system/application/libraries/geshi/dot.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/eiffel.php (renamed from system/application/libraries/geshi/eiffel.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/email.php (renamed from system/application/libraries/geshi/email.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/erlang.php (renamed from system/application/libraries/geshi/erlang.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/fo.php (renamed from system/application/libraries/geshi/fo.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/fortran.php (renamed from system/application/libraries/geshi/fortran.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/freebasic.php (renamed from system/application/libraries/geshi/freebasic.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/fsharp.php (renamed from system/application/libraries/geshi/fsharp.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/gambas.php (renamed from system/application/libraries/geshi/gambas.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/gdb.php (renamed from system/application/libraries/geshi/gdb.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/genero.php (renamed from system/application/libraries/geshi/genero.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/gettext.php (renamed from system/application/libraries/geshi/gettext.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/glsl.php (renamed from system/application/libraries/geshi/glsl.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/gml.php (renamed from system/application/libraries/geshi/gml.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/gnuplot.php (renamed from system/application/libraries/geshi/gnuplot.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/groovy.php (renamed from system/application/libraries/geshi/groovy.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/haskell.php (renamed from system/application/libraries/geshi/haskell.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/hq9plus.php (renamed from system/application/libraries/geshi/hq9plus.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/html4strict.php (renamed from system/application/libraries/geshi/html4strict.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/idl.php (renamed from system/application/libraries/geshi/idl.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/ini.php (renamed from system/application/libraries/geshi/ini.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/inno.php (renamed from system/application/libraries/geshi/inno.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/intercal.php (renamed from system/application/libraries/geshi/intercal.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/io.php (renamed from system/application/libraries/geshi/io.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/java.php (renamed from system/application/libraries/geshi/java.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/java5.php (renamed from system/application/libraries/geshi/java5.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/javascript.php (renamed from system/application/libraries/geshi/javascript.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/jquery.php (renamed from system/application/libraries/geshi/jquery.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/kixtart.php (renamed from system/application/libraries/geshi/kixtart.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/klonec.php (renamed from system/application/libraries/geshi/klonec.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/klonecpp.php (renamed from system/application/libraries/geshi/klonecpp.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/latex.php (renamed from system/application/libraries/geshi/latex.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/lisp.php (renamed from system/application/libraries/geshi/lisp.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/locobasic.php (renamed from system/application/libraries/geshi/locobasic.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/logtalk.php (renamed from system/application/libraries/geshi/logtalk.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/lolcode.php (renamed from system/application/libraries/geshi/lolcode.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/lotusformulas.php (renamed from system/application/libraries/geshi/lotusformulas.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/lotusscript.php (renamed from system/application/libraries/geshi/lotusscript.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/lscript.php (renamed from system/application/libraries/geshi/lscript.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/lsl2.php (renamed from system/application/libraries/geshi/lsl2.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/lua.php (renamed from system/application/libraries/geshi/lua.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/m68k.php (renamed from system/application/libraries/geshi/m68k.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/make.php (renamed from system/application/libraries/geshi/make.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/mapbasic.php (renamed from system/application/libraries/geshi/mapbasic.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/matlab.php (renamed from system/application/libraries/geshi/matlab.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/mirc.php (renamed from system/application/libraries/geshi/mirc.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/mmix.php (renamed from system/application/libraries/geshi/mmix.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/modula3.php (renamed from system/application/libraries/geshi/modula3.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/mpasm.php (renamed from system/application/libraries/geshi/mpasm.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/mxml.php (renamed from system/application/libraries/geshi/mxml.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/mysql.php (renamed from system/application/libraries/geshi/mysql.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/newlisp.php (renamed from system/application/libraries/geshi/newlisp.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/nsis.php (renamed from system/application/libraries/geshi/nsis.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/oberon2.php (renamed from system/application/libraries/geshi/oberon2.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/objc.php (renamed from system/application/libraries/geshi/objc.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/ocaml-brief.php (renamed from system/application/libraries/geshi/ocaml-brief.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/ocaml.php (renamed from system/application/libraries/geshi/ocaml.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/oobas.php (renamed from system/application/libraries/geshi/oobas.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/oracle11.php (renamed from system/application/libraries/geshi/oracle11.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/oracle8.php (renamed from system/application/libraries/geshi/oracle8.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/pascal.php (renamed from system/application/libraries/geshi/pascal.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/per.php (renamed from system/application/libraries/geshi/per.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/perl.php (renamed from system/application/libraries/geshi/perl.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/perl6.php (renamed from system/application/libraries/geshi/perl6.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/php-brief.php (renamed from system/application/libraries/geshi/php-brief.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/php.php (renamed from system/application/libraries/geshi/php.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/pic16.php (renamed from system/application/libraries/geshi/pic16.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/pike.php (renamed from system/application/libraries/geshi/pike.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/pixelbender.php (renamed from system/application/libraries/geshi/pixelbender.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/plsql.php (renamed from system/application/libraries/geshi/plsql.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/povray.php (renamed from system/application/libraries/geshi/povray.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/powerbuilder.php (renamed from system/application/libraries/geshi/powerbuilder.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/powershell.php (renamed from system/application/libraries/geshi/powershell.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/progress.php (renamed from system/application/libraries/geshi/progress.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/prolog.php (renamed from system/application/libraries/geshi/prolog.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/properties.php (renamed from system/application/libraries/geshi/properties.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/providex.php (renamed from system/application/libraries/geshi/providex.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/purebasic.php (renamed from system/application/libraries/geshi/purebasic.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/python.php (renamed from system/application/libraries/geshi/python.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/qbasic.php (renamed from system/application/libraries/geshi/qbasic.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/rails.php (renamed from system/application/libraries/geshi/rails.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/rebol.php (renamed from system/application/libraries/geshi/rebol.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/reg.php (renamed from system/application/libraries/geshi/reg.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/robots.php (renamed from system/application/libraries/geshi/robots.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/rsplus.php (renamed from system/application/libraries/geshi/rsplus.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/ruby.php (renamed from system/application/libraries/geshi/ruby.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/sas.php (renamed from system/application/libraries/geshi/sas.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/scala.php (renamed from system/application/libraries/geshi/scala.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/scheme.php (renamed from system/application/libraries/geshi/scheme.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/scilab.php (renamed from system/application/libraries/geshi/scilab.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/sdlbasic.php (renamed from system/application/libraries/geshi/sdlbasic.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/smalltalk.php (renamed from system/application/libraries/geshi/smalltalk.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/smarty.php (renamed from system/application/libraries/geshi/smarty.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/sql.php (renamed from system/application/libraries/geshi/sql.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/systemverilog.php (renamed from system/application/libraries/geshi/systemverilog.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/tcl.php (renamed from system/application/libraries/geshi/tcl.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/teraterm.php (renamed from system/application/libraries/geshi/teraterm.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/text.php (renamed from system/application/libraries/geshi/text.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/thinbasic.php (renamed from system/application/libraries/geshi/thinbasic.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/tsql.php (renamed from system/application/libraries/geshi/tsql.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/typoscript.php (renamed from system/application/libraries/geshi/typoscript.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/vb.php (renamed from system/application/libraries/geshi/vb.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/vbnet.php (renamed from system/application/libraries/geshi/vbnet.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/verilog.php (renamed from system/application/libraries/geshi/verilog.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/vhdl.php (renamed from system/application/libraries/geshi/vhdl.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/vim.php (renamed from system/application/libraries/geshi/vim.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/visualfoxpro.php (renamed from system/application/libraries/geshi/visualfoxpro.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/visualprolog.php (renamed from system/application/libraries/geshi/visualprolog.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/whitespace.php (renamed from system/application/libraries/geshi/whitespace.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/whois.php (renamed from system/application/libraries/geshi/whois.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/winbatch.php (renamed from system/application/libraries/geshi/winbatch.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/xml.php (renamed from system/application/libraries/geshi/xml.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/xorg_conf.php (renamed from system/application/libraries/geshi/xorg_conf.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/xpp.php (renamed from system/application/libraries/geshi/xpp.php) | 0 | ||||
-rw-r--r-- | application/libraries/geshi/z80.php (renamed from system/application/libraries/geshi/z80.php) | 0 | ||||
-rw-r--r-- | application/libraries/index.html (renamed from system/cache/index.html) | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | application/logs/index.html (renamed from system/codeigniter/index.html) | 0 | ||||
-rw-r--r-- | application/models/file_mod.php (renamed from system/application/models/file_mod.php) | 4 | ||||
-rw-r--r-- | application/models/index.html (renamed from system/logs/index.html) | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | application/third_party/index.html (renamed from system/plugins/index.html) | 0 | ||||
-rw-r--r-- | application/views/file/client.php (renamed from system/application/views/file/client.php) | 0 | ||||
-rw-r--r-- | application/views/file/delete_form.php (renamed from system/application/views/file/delete_form.php) | 0 | ||||
-rw-r--r-- | application/views/file/deleted.php (renamed from system/application/views/file/deleted.php) | 0 | ||||
-rw-r--r-- | application/views/file/footer.php (renamed from system/application/views/file/footer.php) | 0 | ||||
-rw-r--r-- | application/views/file/header.php (renamed from system/application/views/file/header.php) | 0 | ||||
-rw-r--r-- | application/views/file/html_footer.php (renamed from system/application/views/file/html_footer.php) | 0 | ||||
-rw-r--r-- | application/views/file/html_header.php (renamed from system/application/views/file/html_header.php) | 0 | ||||
-rw-r--r-- | application/views/file/non_existent.php (renamed from system/application/views/file/non_existent.php) | 0 | ||||
-rw-r--r-- | application/views/file/show_url.php (renamed from system/application/views/file/show_url.php) | 0 | ||||
-rw-r--r-- | application/views/file/too_big.php (renamed from system/application/views/file/too_big.php) | 0 | ||||
-rw-r--r-- | application/views/file/upload_error.php (renamed from system/application/views/file/upload_error.php) | 0 | ||||
-rw-r--r-- | application/views/file/upload_form.php (renamed from system/application/views/file/upload_form.php) | 0 | ||||
-rw-r--r-- | application/views/index.html (renamed from system/scaffolding/images/index.html) | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | index.php | 236 | ||||
-rwxr-xr-x[-rw-r--r--] | system/.htaccess | 2 | ||||
-rw-r--r-- | system/codeigniter/Base4.php | 69 | ||||
-rw-r--r-- | system/codeigniter/Base5.php | 56 | ||||
-rw-r--r-- | system/codeigniter/CodeIgniter.php | 280 | ||||
-rw-r--r-- | system/codeigniter/Common.php | 421 | ||||
-rw-r--r-- | system/codeigniter/Compat.php | 93 | ||||
-rwxr-xr-x[-rw-r--r--] | system/core/Benchmark.php (renamed from system/libraries/Benchmark.php) | 10 | ||||
-rwxr-xr-x | system/core/CodeIgniter.php | 340 | ||||
-rwxr-xr-x | system/core/Common.php | 503 | ||||
-rwxr-xr-x[-rw-r--r--] | system/core/Config.php (renamed from system/libraries/Config.php) | 183 | ||||
-rwxr-xr-x | system/core/Controller.php | 67 | ||||
-rwxr-xr-x[-rw-r--r--] | system/core/Exceptions.php (renamed from system/libraries/Exceptions.php) | 44 | ||||
-rwxr-xr-x[-rw-r--r--] | system/core/Hooks.php (renamed from system/libraries/Hooks.php) | 29 | ||||
-rwxr-xr-x | system/core/Input.php | 652 | ||||
-rwxr-xr-x[-rw-r--r--] | system/core/Lang.php (renamed from system/libraries/Language.php) | 49 | ||||
-rwxr-xr-x[-rw-r--r--] | system/core/Loader.php (renamed from system/libraries/Loader.php) | 738 | ||||
-rwxr-xr-x | system/core/Model.php | 56 | ||||
-rwxr-xr-x[-rw-r--r--] | system/core/Output.php (renamed from system/libraries/Output.php) | 233 | ||||
-rwxr-xr-x[-rw-r--r--] | system/core/Router.php (renamed from system/libraries/Router.php) | 296 | ||||
-rwxr-xr-x[-rw-r--r--] | system/core/URI.php (renamed from system/libraries/URI.php) | 136 | ||||
-rwxr-xr-x | system/core/Utf8.php | 165 | ||||
-rwxr-xr-x[-rw-r--r--] | system/core/index.html (renamed from system/scaffolding/index.html) | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/DB.php | 59 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/DB_active_rec.php | 703 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/DB_cache.php | 60 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/DB_driver.php | 374 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/DB_forge.php | 79 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/DB_result.php | 167 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/DB_utility.php | 113 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/index.html | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/mssql/index.html | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/mssql/mssql_driver.php | 131 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/mssql/mssql_forge.php | 38 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/mssql/mssql_result.php | 28 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/mssql/mssql_utility.php | 41 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/mysql/index.html | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/mysql/mysql_driver.php | 218 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/mysql/mysql_forge.php | 57 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/mysql/mysql_result.php | 28 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/mysql/mysql_utility.php | 85 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/mysqli/index.html | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/mysqli/mysqli_driver.php | 193 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/mysqli/mysqli_forge.php | 34 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/mysqli/mysqli_result.php | 28 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/mysqli/mysqli_utility.php | 44 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/oci8/index.html | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/oci8/oci8_driver.php | 113 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/oci8/oci8_forge.php | 36 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/oci8/oci8_result.php | 34 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/oci8/oci8_utility.php | 39 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/odbc/index.html | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/odbc/odbc_driver.php | 119 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/odbc/odbc_forge.php | 42 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/odbc/odbc_result.php | 22 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/odbc/odbc_utility.php | 55 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/postgre/index.html | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/postgre/postgre_driver.php | 122 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/postgre/postgre_forge.php | 117 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/postgre/postgre_result.php | 22 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/postgre/postgre_utility.php | 40 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/sqlite/index.html | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/sqlite/sqlite_driver.php | 130 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/sqlite/sqlite_forge.php | 36 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/sqlite/sqlite_result.php | 24 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/drivers/sqlite/sqlite_utility.php | 51 | ||||
-rwxr-xr-x[-rw-r--r--] | system/database/index.html | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | system/fonts/index.html | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | system/fonts/texb.ttf | bin | 143821 -> 152992 bytes | |||
-rwxr-xr-x[-rw-r--r--] | system/helpers/array_helper.php | 52 | ||||
-rwxr-xr-x | system/helpers/captcha_helper.php | 246 | ||||
-rw-r--r-- | system/helpers/compatibility_helper.php | 498 | ||||
-rwxr-xr-x[-rw-r--r--] | system/helpers/cookie_helper.php | 55 | ||||
-rwxr-xr-x[-rw-r--r--] | system/helpers/date_helper.php | 180 | ||||
-rwxr-xr-x[-rw-r--r--] | system/helpers/directory_helper.php | 40 | ||||
-rwxr-xr-x[-rw-r--r--] | system/helpers/download_helper.php | 16 | ||||
-rwxr-xr-x[-rw-r--r--] | system/helpers/email_helper.php | 8 | ||||
-rwxr-xr-x[-rw-r--r--] | system/helpers/file_helper.php | 84 | ||||
-rwxr-xr-x[-rw-r--r--] | system/helpers/form_helper.php | 94 | ||||
-rwxr-xr-x[-rw-r--r--] | system/helpers/html_helper.php | 34 | ||||
-rwxr-xr-x[-rw-r--r--] | system/helpers/index.html | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | system/helpers/inflector_helper.php | 43 | ||||
-rwxr-xr-x[-rw-r--r--] | system/helpers/language_helper.php | 6 | ||||
-rwxr-xr-x[-rw-r--r--] | system/helpers/number_helper.php | 29 | ||||
-rwxr-xr-x[-rw-r--r--] | system/helpers/path_helper.php | 14 | ||||
-rwxr-xr-x[-rw-r--r--] | system/helpers/security_helper.php | 64 | ||||
-rwxr-xr-x[-rw-r--r--] | system/helpers/smiley_helper.php | 52 | ||||
-rwxr-xr-x[-rw-r--r--] | system/helpers/string_helper.php | 73 | ||||
-rwxr-xr-x[-rw-r--r--] | system/helpers/text_helper.php | 319 | ||||
-rwxr-xr-x[-rw-r--r--] | system/helpers/typography_helper.php | 41 | ||||
-rwxr-xr-x[-rw-r--r--] | system/helpers/url_helper.php | 32 | ||||
-rwxr-xr-x[-rw-r--r--] | system/helpers/xml_helper.php | 33 | ||||
-rwxr-xr-x[-rw-r--r--] | system/index.html | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | system/language/english/calendar_lang.php | 66 | ||||
-rwxr-xr-x[-rw-r--r--] | system/language/english/date_lang.php | 1 | ||||
-rwxr-xr-x[-rw-r--r--] | system/language/english/db_lang.php | 3 | ||||
-rwxr-xr-x[-rw-r--r--] | system/language/english/email_lang.php | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | system/language/english/form_validation_lang.php | 9 | ||||
-rwxr-xr-x[-rw-r--r--] | system/language/english/ftp_lang.php | 1 | ||||
-rwxr-xr-x[-rw-r--r--] | system/language/english/imglib_lang.php | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | system/language/english/index.html | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | system/language/english/number_lang.php | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | system/language/english/profiler_lang.php | 5 | ||||
-rw-r--r-- | system/language/english/scaffolding_lang.php | 17 | ||||
-rwxr-xr-x[-rw-r--r--] | system/language/english/unit_test_lang.php | 1 | ||||
-rwxr-xr-x[-rw-r--r--] | system/language/english/upload_lang.php | 0 | ||||
-rw-r--r-- | system/language/english/validation_lang.php | 24 | ||||
-rwxr-xr-x[-rw-r--r--] | system/language/index.html | 0 | ||||
-rwxr-xr-x | system/libraries/Cache/Cache.php | 216 | ||||
-rwxr-xr-x | system/libraries/Cache/drivers/Cache_apc.php | 151 | ||||
-rwxr-xr-x | system/libraries/Cache/drivers/Cache_dummy.php | 129 | ||||
-rwxr-xr-x | system/libraries/Cache/drivers/Cache_file.php | 196 | ||||
-rwxr-xr-x | system/libraries/Cache/drivers/Cache_memcached.php | 209 | ||||
-rwxr-xr-x[-rw-r--r--] | system/libraries/Calendar.php | 164 | ||||
-rwxr-xr-x[-rw-r--r--] | system/libraries/Cart.php | 146 | ||||
-rw-r--r-- | system/libraries/Controller.php | 127 | ||||
-rwxr-xr-x | system/libraries/Driver.php | 229 | ||||
-rwxr-xr-x[-rw-r--r--] | system/libraries/Email.php | 397 | ||||
-rwxr-xr-x[-rw-r--r--] | system/libraries/Encrypt.php | 93 | ||||
-rwxr-xr-x[-rw-r--r--] | system/libraries/Form_validation.php | 493 | ||||
-rwxr-xr-x[-rw-r--r--] | system/libraries/Ftp.php | 50 | ||||
-rwxr-xr-x[-rw-r--r--] | system/libraries/Image_lib.php | 79 | ||||
-rw-r--r-- | system/libraries/Input.php | 1067 | ||||
-rwxr-xr-x | system/libraries/Javascript.php | 871 | ||||
-rwxr-xr-x[-rw-r--r--] | system/libraries/Log.php | 61 | ||||
-rw-r--r-- | system/libraries/Model.php | 83 | ||||
-rwxr-xr-x[-rw-r--r--] | system/libraries/Pagination.php | 93 | ||||
-rwxr-xr-x[-rw-r--r--] | system/libraries/Parser.php | 87 | ||||
-rwxr-xr-x[-rw-r--r--] | system/libraries/Profiler.php | 370 | ||||
-rwxr-xr-x | system/libraries/Security.php | 737 | ||||
-rwxr-xr-x[-rw-r--r--] | system/libraries/Session.php | 49 | ||||
-rwxr-xr-x[-rw-r--r--] | system/libraries/Sha1.php | 28 | ||||
-rwxr-xr-x[-rw-r--r--] | system/libraries/Table.php | 256 | ||||
-rwxr-xr-x[-rw-r--r--] | system/libraries/Trackback.php | 257 | ||||
-rwxr-xr-x[-rw-r--r--] | system/libraries/Typography.php | 164 | ||||
-rwxr-xr-x[-rw-r--r--] | system/libraries/Unit_test.php | 174 | ||||
-rwxr-xr-x[-rw-r--r--] | system/libraries/Upload.php | 508 | ||||
-rwxr-xr-x[-rw-r--r--] | system/libraries/User_agent.php | 265 | ||||
-rw-r--r-- | system/libraries/Validation.php | 875 | ||||
-rwxr-xr-x[-rw-r--r--] | system/libraries/Xmlrpc.php | 372 | ||||
-rwxr-xr-x[-rw-r--r--] | system/libraries/Xmlrpcs.php | 174 | ||||
-rwxr-xr-x[-rw-r--r--] | system/libraries/Zip.php | 156 | ||||
-rwxr-xr-x[-rw-r--r--] | system/libraries/index.html | 0 | ||||
-rwxr-xr-x | system/libraries/javascript/Jquery.php | 1071 | ||||
-rw-r--r-- | system/plugins/captcha_pi.php | 356 | ||||
-rw-r--r-- | system/plugins/js_calendar_pi.php | 629 | ||||
-rw-r--r-- | system/scaffolding/Scaffolding.php | 291 | ||||
-rw-r--r-- | system/scaffolding/images/background.jpg | bin | 410 -> 0 bytes | |||
-rw-r--r-- | system/scaffolding/images/logo.jpg | bin | 4518 -> 0 bytes | |||
-rw-r--r-- | system/scaffolding/views/add.php | 32 | ||||
-rw-r--r-- | system/scaffolding/views/delete.php | 9 | ||||
-rw-r--r-- | system/scaffolding/views/edit.php | 33 | ||||
-rw-r--r-- | system/scaffolding/views/footer.php | 10 | ||||
-rw-r--r-- | system/scaffolding/views/header.php | 29 | ||||
-rw-r--r-- | system/scaffolding/views/index.html | 10 | ||||
-rw-r--r-- | system/scaffolding/views/no_data.php | 8 | ||||
-rw-r--r-- | system/scaffolding/views/stylesheet.css | 143 | ||||
-rw-r--r-- | system/scaffolding/views/view.php | 27 |
371 files changed, 12390 insertions, 10156 deletions
diff --git a/system/application/config/index.html b/application/cache/index.html index c942a79ce..c942a79ce 100755 --- a/system/application/config/index.html +++ b/application/cache/index.html diff --git a/system/application/config/.gitignore b/application/config/.gitignore index cde8069e1..cde8069e1 100644 --- a/system/application/config/.gitignore +++ b/application/config/.gitignore diff --git a/system/application/config/example/.gitignore b/application/config/example/.gitignore index f9be8dfe0..f9be8dfe0 100644 --- a/system/application/config/example/.gitignore +++ b/application/config/example/.gitignore diff --git a/system/application/config/example/autoload.php b/application/config/example/autoload.php index 9cd7a4fce..e527bf5cc 100755 --- a/system/application/config/example/autoload.php +++ b/application/config/example/autoload.php @@ -18,9 +18,9 @@ | | These are the things you can load automatically: | -| 1. Libraries -| 2. Helper files -| 3. Plugins +| 1. Packages +| 2. Libraries +| 3. Helper files | 4. Custom config files | 5. Language files | 6. Models @@ -29,41 +29,42 @@ /* | ------------------------------------------------------------------- -| Auto-load Libraries +| Auto-load Packges | ------------------------------------------------------------------- -| These are the classes located in the system/libraries folder -| or in your system/application/libraries folder. -| | Prototype: | -| $autoload['libraries'] = array('database', 'session', 'xmlrpc'); +| $autoload['packages'] = array(APPPATH.'third_party', '/usr/local/shared'); +| */ -$autoload['libraries'] = array('database'); +$autoload['packages'] = array(APPPATH.'third_party'); /* | ------------------------------------------------------------------- -| Auto-load Helper Files +| Auto-load Libraries | ------------------------------------------------------------------- +| These are the classes located in the system/libraries folder +| or in your application/libraries folder. +| | Prototype: | -| $autoload['helper'] = array('url', 'file'); +| $autoload['libraries'] = array('database', 'session', 'xmlrpc'); */ -$autoload['helper'] = array('url'); +$autoload['libraries'] = array('database'); /* | ------------------------------------------------------------------- -| Auto-load Plugins +| Auto-load Helper Files | ------------------------------------------------------------------- | Prototype: | -| $autoload['plugin'] = array('captcha', 'js_calendar'); +| $autoload['helper'] = array('url', 'file'); */ -$autoload['plugin'] = array(); +$autoload['helper'] = array('url'); /* @@ -90,7 +91,7 @@ $autoload['config'] = array(); | | $autoload['language'] = array('lang1', 'lang2'); | -| NOTE: Do not include the "_lang" part of your file. For example +| NOTE: Do not include the "_lang" part of your file. For example | "codeigniter_lang.php" would be referenced as array('codeigniter'); | */ @@ -111,6 +112,5 @@ $autoload['language'] = array(); $autoload['model'] = array(); - /* End of file autoload.php */ -/* Location: ./system/application/config/autoload.php */ +/* Location: ./application/config/autoload.php */
\ No newline at end of file diff --git a/system/application/config/example/config.php b/application/config/example/config.php index bab0087b0..f7edc7bf6 100755 --- a/system/application/config/example/config.php +++ b/application/config/example/config.php @@ -10,6 +10,9 @@ | | http://example.com/ | +| If this is not set then CodeIgniter will guess the protocol, domain and +| path to your installation. +| */ $config['base_url'] = ''; @@ -23,7 +26,7 @@ $config['base_url'] = ''; | variable so that it is blank. | */ -$config['index_page'] = "index.php"; +$config['index_page'] = 'index.php'; /* |-------------------------------------------------------------------------- @@ -31,7 +34,7 @@ $config['index_page'] = "index.php"; |-------------------------------------------------------------------------- | | This item determines which server global should be used to retrieve the -| URI string. The default setting of "AUTO" works for most servers. +| URI string. The default setting of 'AUTO' works for most servers. | If your links do not seem to work, try one of the other delicious flavors: | | 'AUTO' Default - auto detects @@ -41,7 +44,7 @@ $config['index_page'] = "index.php"; | 'ORIG_PATH_INFO' Uses the ORIG_PATH_INFO | */ -$config['uri_protocol'] = "AUTO"; +$config['uri_protocol'] = 'AUTO'; /* |-------------------------------------------------------------------------- @@ -54,7 +57,7 @@ $config['uri_protocol'] = "AUTO"; | http://codeigniter.com/user_guide/general/urls.html */ -$config['url_suffix'] = ""; +$config['url_suffix'] = ''; /* |-------------------------------------------------------------------------- @@ -66,7 +69,7 @@ $config['url_suffix'] = ""; | than english. | */ -$config['language'] = "english"; +$config['language'] = 'english'; /* |-------------------------------------------------------------------------- @@ -77,14 +80,14 @@ $config['language'] = "english"; | that require a character set to be provided. | */ -$config['charset'] = "UTF-8"; +$config['charset'] = 'UTF-8'; /* |-------------------------------------------------------------------------- | Enable/Disable System Hooks |-------------------------------------------------------------------------- | -| If you would like to use the "hooks" feature you must enable it by +| If you would like to use the 'hooks' feature you must enable it by | setting this variable to TRUE (boolean). See the user guide for details. | */ @@ -134,12 +137,15 @@ $config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-'; | By default CodeIgniter uses search-engine friendly segment based URLs: | example.com/who/what/where/ | +| By default CodeIgniter enables access to the $_GET array. If for some +| reason you would like to disable it, set 'allow_get_array' to FALSE. +| | You can optionally enable standard query string based URLs: | example.com?who=me&what=something&where=here | | Options are: TRUE or FALSE (boolean) | -| The other items let you set the query string "words" that will +| The other items let you set the query string 'words' that will | invoke your controllers and its functions: | example.com/index.php?c=controller&m=function | @@ -148,17 +154,18 @@ $config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-'; | use segment based URLs. | */ +$config['allow_get_array'] = TRUE; $config['enable_query_strings'] = FALSE; -$config['controller_trigger'] = 'c'; -$config['function_trigger'] = 'm'; -$config['directory_trigger'] = 'd'; // experimental not currently in use +$config['controller_trigger'] = 'c'; +$config['function_trigger'] = 'm'; +$config['directory_trigger'] = 'd'; // experimental not currently in use /* |-------------------------------------------------------------------------- | Error Logging Threshold |-------------------------------------------------------------------------- | -| If you have enabled error logging, you can set an error threshold to +| If you have enabled error logging, you can set an error threshold to | determine what gets logged. Threshold options are: | You can enable error logging by setting a threshold over zero. The | threshold determines what gets logged. Threshold options are: @@ -181,7 +188,7 @@ $config['log_threshold'] = 0; |-------------------------------------------------------------------------- | | Leave this BLANK unless you would like to set something other than the default -| system/logs/ folder. Use a full server path with trailing slash. +| application/logs/ folder. Use a full server path with trailing slash. | */ $config['log_path'] = ''; @@ -213,32 +220,39 @@ $config['cache_path'] = ''; | Encryption Key |-------------------------------------------------------------------------- | -| If you use the Encryption class or the Sessions class with encryption -| enabled you MUST set an encryption key. See the user guide for info. +| If you use the Encryption class or the Session class you +| MUST set an encryption key. See the user guide for info. | */ -$config['encryption_key'] = ""; +$config['encryption_key'] = ''; /* |-------------------------------------------------------------------------- | Session Variables |-------------------------------------------------------------------------- | -| 'session_cookie_name' = the name you want for the cookie -| 'encrypt_sess_cookie' = TRUE/FALSE (boolean). Whether to encrypt the cookie -| 'session_expiration' = the number of SECONDS you want the session to last. -| by default sessions last 7200 seconds (two hours). Set to zero for no expiration. -| 'time_to_update' = how many seconds between CI refreshing Session Information +| 'sess_cookie_name' = the name you want for the cookie +| 'sess_expiration' = the number of SECONDS you want the session to last. +| by default sessions last 7200 seconds (two hours). Set to zero for no expiration. +| 'sess_expire_on_close' = Whether to cause the session to expire automatically +| when the browser window is closed +| 'sess_encrypt_cookie' = Whether to encrypt the cookie +| 'sess_use_database' = Whether to save the session data to a database +| 'sess_table_name' = The name of the session database table +| 'sess_match_ip' = Whether to match the user's IP address when reading the session data +| 'sess_match_useragent' = Whether to match the User Agent when reading the session data +| 'sess_time_to_update' = how many seconds between CI refreshing Session Information | */ $config['sess_cookie_name'] = 'ci_session'; $config['sess_expiration'] = 7200; +$config['sess_expire_on_close'] = FALSE; $config['sess_encrypt_cookie'] = FALSE; $config['sess_use_database'] = FALSE; $config['sess_table_name'] = 'ci_sessions'; $config['sess_match_ip'] = FALSE; $config['sess_match_useragent'] = TRUE; -$config['sess_time_to_update'] = 300; +$config['sess_time_to_update'] = 300; /* |-------------------------------------------------------------------------- @@ -250,9 +264,9 @@ $config['sess_time_to_update'] = 300; | 'cookie_path' = Typically will be a forward slash | */ -$config['cookie_prefix'] = ""; -$config['cookie_domain'] = ""; -$config['cookie_path'] = "/"; +$config['cookie_prefix'] = ''; +$config['cookie_domain'] = ''; +$config['cookie_path'] = '/'; /* |-------------------------------------------------------------------------- @@ -267,6 +281,23 @@ $config['global_xss_filtering'] = FALSE; /* |-------------------------------------------------------------------------- +| Cross Site Request Forgery +|-------------------------------------------------------------------------- +| Enables a CSRF cookie token to be set. When set to TRUE, token will be +| checked on a submitted form. If you are accepting user data, it is strongly +| recommended CSRF protection be enabled. +| +| 'csrf_token_name' = The token name +| 'csrf_cookie_name' = The cookie name +| 'csrf_expire' = The number in seconds the token should expire. +*/ +$config['csrf_protection'] = FALSE; +$config['csrf_token_name'] = 'csrf_test_name'; +$config['csrf_cookie_name'] = 'csrf_cookie_name'; +$config['csrf_expire'] = 7200; + +/* +|-------------------------------------------------------------------------- | Output Compression |-------------------------------------------------------------------------- | @@ -279,7 +310,7 @@ $config['global_xss_filtering'] = FALSE; | means you are prematurely outputting something to your browser. It could | even be a line of whitespace at the end of one of your scripts. For | compression to work, nothing can be sent before the output buffer is called -| by the output class. Do not "echo" any values with compression enabled. +| by the output class. Do not 'echo' any values with compression enabled. | */ $config['compress_output'] = FALSE; @@ -289,9 +320,9 @@ $config['compress_output'] = FALSE; | Master Time Reference |-------------------------------------------------------------------------- | -| Options are "local" or "gmt". This pref tells the system whether to use -| your server's local time as the master "now" reference, or convert it to -| GMT. See the "date helper" page of the user guide for information +| Options are 'local' or 'gmt'. This pref tells the system whether to use +| your server's local time as the master 'now' reference, or convert it to +| GMT. See the 'date helper' page of the user guide for information | regarding date handling. | */ @@ -324,13 +355,12 @@ $config['rewrite_short_tags'] = FALSE; */ $config['proxy_ips'] = ''; - /* |-------------------------------------------------------------------------- | Filebin |------------------------------------------------------------------------- | -| upload_path should NOT be readable/served by the server, but only by +| upload_path should NOT be readable/served by the server, but only by | the script | sizes are in bytes | max_age in seconds @@ -350,4 +380,4 @@ $config['small_upload_size'] = 1024*10; // 10KB $config['passwordsalt'] = ''; // just enter any string you want here /* End of file config.php */ -/* Location: ./system/application/config/config.php */ +/* Location: ./application/config/config.php */ diff --git a/system/application/config/example/constants.php b/application/config/example/constants.php index 19c5ee788..1185dbca0 100755 --- a/system/application/config/example/constants.php +++ b/application/config/example/constants.php @@ -29,15 +29,15 @@ define('DIR_WRITE_MODE', 0777); | */ -define('FOPEN_READ', 'rb'); +define('FOPEN_READ', 'rb'); define('FOPEN_READ_WRITE', 'r+b'); -define('FOPEN_WRITE_CREATE_DESTRUCTIVE', 'wb'); // truncates existing file data, use with care -define('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE', 'w+b'); // truncates existing file data, use with care -define('FOPEN_WRITE_CREATE', 'ab'); -define('FOPEN_READ_WRITE_CREATE', 'a+b'); -define('FOPEN_WRITE_CREATE_STRICT', 'xb'); +define('FOPEN_WRITE_CREATE_DESTRUCTIVE', 'wb'); // truncates existing file data, use with care +define('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE', 'w+b'); // truncates existing file data, use with care +define('FOPEN_WRITE_CREATE', 'ab'); +define('FOPEN_READ_WRITE_CREATE', 'a+b'); +define('FOPEN_WRITE_CREATE_STRICT', 'xb'); define('FOPEN_READ_WRITE_CREATE_STRICT', 'x+b'); /* End of file constants.php */ -/* Location: ./system/application/config/constants.php */ +/* Location: ./application/config/constants.php */
\ No newline at end of file diff --git a/system/application/config/example/database.php b/application/config/example/database.php index 2d6780e6a..4bf16f591 100755 --- a/system/application/config/example/database.php +++ b/application/config/example/database.php @@ -5,7 +5,7 @@ | ------------------------------------------------------------------- | This file will contain the settings needed to access your database. | -| For complete instructions please consult the "Database Connection" +| For complete instructions please consult the 'Database Connection' | page of the User Guide. | | ------------------------------------------------------------------- @@ -26,15 +26,19 @@ | ['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). +| 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_group = 'default'; $active_record = TRUE; $db['default']['hostname'] = "localhost"; @@ -52,4 +56,4 @@ $db['default']['dbcollat'] = "utf8_bin"; /* End of file database.php */ -/* Location: ./system/application/config/database.php */ +/* Location: ./application/config/database.php */
\ No newline at end of file diff --git a/system/application/config/example/doctypes.php b/application/config/example/doctypes.php index 9d510abca..f7e1d19a2 100755 --- a/system/application/config/example/doctypes.php +++ b/application/config/example/doctypes.php @@ -12,4 +12,4 @@ $_doctypes = array( ); /* End of file doctypes.php */ -/* Location: application/config/doctypes.php */
\ No newline at end of file +/* Location: ./application/config/doctypes.php */
\ No newline at end of file diff --git a/application/config/example/foreign_chars.php b/application/config/example/foreign_chars.php new file mode 100755 index 000000000..14b0d7373 --- /dev/null +++ b/application/config/example/foreign_chars.php @@ -0,0 +1,64 @@ +<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); +/* +| ------------------------------------------------------------------- +| Foreign Characters +| ------------------------------------------------------------------- +| This file contains an array of foreign characters for transliteration +| conversion used by the Text helper +| +*/ +$foreign_characters = array( + '/ä|æ|ǽ/' => 'ae', + '/ö|œ/' => 'oe', + '/ü/' => 'ue', + '/Ä/' => 'Ae', + '/Ü/' => 'Ue', + '/Ö/' => 'Oe', + '/À|Á|Â|Ã|Ä|Å|Ǻ|Ā|Ă|Ą|Ǎ/' => 'A', + '/à|á|â|ã|å|ǻ|ā|ă|ą|ǎ|ª/' => 'a', + '/Ç|Ć|Ĉ|Ċ|Č/' => 'C', + '/ç|ć|ĉ|ċ|č/' => 'c', + '/Ð|Ď|Đ/' => 'D', + '/ð|ď|đ/' => 'd', + '/È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě/' => 'E', + '/è|é|ê|ë|ē|ĕ|ė|ę|ě/' => 'e', + '/Ĝ|Ğ|Ġ|Ģ/' => 'G', + '/ĝ|ğ|ġ|ģ/' => 'g', + '/Ĥ|Ħ/' => 'H', + '/ĥ|ħ/' => 'h', + '/Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ/' => 'I', + '/ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı/' => 'i', + '/Ĵ/' => 'J', + '/ĵ/' => 'j', + '/Ķ/' => 'K', + '/ķ/' => 'k', + '/Ĺ|Ļ|Ľ|Ŀ|Ł/' => 'L', + '/ĺ|ļ|ľ|ŀ|ł/' => 'l', + '/Ñ|Ń|Ņ|Ň/' => 'N', + '/ñ|ń|ņ|ň|ʼn/' => 'n', + '/Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ/' => 'O', + '/ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º/' => 'o', + '/Ŕ|Ŗ|Ř/' => 'R', + '/ŕ|ŗ|ř/' => 'r', + '/Ś|Ŝ|Ş|Š/' => 'S', + '/ś|ŝ|ş|š|ſ/' => 's', + '/Ţ|Ť|Ŧ/' => 'T', + '/ţ|ť|ŧ/' => 't', + '/Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ/' => 'U', + '/ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ/' => 'u', + '/Ý|Ÿ|Ŷ/' => 'Y', + '/ý|ÿ|ŷ/' => 'y', + '/Ŵ/' => 'W', + '/ŵ/' => 'w', + '/Ź|Ż|Ž/' => 'Z', + '/ź|ż|ž/' => 'z', + '/Æ|Ǽ/' => 'AE', + '/ß/'=> 'ss', + '/IJ/' => 'IJ', + '/ij/' => 'ij', + '/Œ/' => 'OE', + '/ƒ/' => 'f' +); + +/* End of file foreign_chars.php */ +/* Location: ./application/config/foreign_chars.php */
\ No newline at end of file diff --git a/system/application/config/example/hooks.php b/application/config/example/hooks.php index 5e98a9b46..a4ad2be6d 100755 --- a/system/application/config/example/hooks.php +++ b/application/config/example/hooks.php @@ -13,4 +13,4 @@ /* End of file hooks.php */ -/* Location: ./system/application/config/hooks.php */
\ No newline at end of file +/* Location: ./application/config/hooks.php */
\ No newline at end of file diff --git a/system/application/controllers/index.html b/application/config/example/index.html index c942a79ce..c942a79ce 100644..100755 --- a/system/application/controllers/index.html +++ b/application/config/example/index.html diff --git a/system/application/config/example/memcache.php b/application/config/example/memcache.php index a5bc7e3a8..a5bc7e3a8 100644 --- a/system/application/config/example/memcache.php +++ b/application/config/example/memcache.php diff --git a/system/application/config/example/mimes.php b/application/config/example/mimes.php index 438f610ce..de923c45a 100755 --- a/system/application/config/example/mimes.php +++ b/application/config/example/mimes.php @@ -10,12 +10,12 @@ $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'), + 'csv' => array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel'), 'bin' => 'application/macbinary', 'dms' => 'application/octet-stream', 'lha' => 'application/octet-stream', 'lzh' => 'application/octet-stream', - 'exe' => 'application/octet-stream', + 'exe' => array('application/octet-stream', 'application/x-msdownload'), 'class' => 'application/octet-stream', 'psd' => 'application/x-photoshop', 'so' => 'application/octet-stream', @@ -48,7 +48,7 @@ $mimes = array( 'hqx' => 'application/mac-binhex40', 'swf' => 'application/x-shockwave-flash', 'sit' => 'application/x-stuffit', 'tar' => 'application/x-tar', - 'tgz' => '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'), @@ -56,7 +56,7 @@ $mimes = array( 'hqx' => 'application/mac-binhex40', 'midi' => 'audio/midi', 'mpga' => 'audio/mpeg', 'mp2' => 'audio/mpeg', - 'mp3' => array('audio/mpeg', 'audio/mpg'), + 'mp3' => array('audio/mpeg', 'audio/mpg', 'audio/mpeg3'), 'aif' => 'audio/x-aiff', 'aiff' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff', @@ -102,4 +102,4 @@ $mimes = array( 'hqx' => 'application/mac-binhex40', /* End of file mimes.php */ -/* Location: ./system/application/config/mimes.php */
\ No newline at end of file +/* Location: ./application/config/mimes.php */
\ No newline at end of file diff --git a/application/config/example/profiler.php b/application/config/example/profiler.php new file mode 100755 index 000000000..f8a5b1a1e --- /dev/null +++ b/application/config/example/profiler.php @@ -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 */
\ No newline at end of file diff --git a/system/application/config/example/routes.php b/application/config/example/routes.php index 17e5927be..58a6162f0 100755 --- a/system/application/config/example/routes.php +++ b/application/config/example/routes.php @@ -9,7 +9,7 @@ | and its corresponding controller class/method. The segments in a | URL normally follow this pattern: | -| example.com/class/method/id/ +| 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 @@ -23,7 +23,7 @@ | RESERVED ROUTES | ------------------------------------------------------------------------- | -| There are two reserved routes: +| There area two reserved routes: | | $route['default_controller'] = 'welcome'; | @@ -31,12 +31,10 @@ | URI contains no data. In the above example, the "welcome" class | would be loaded. | -| $route['scaffolding_trigger'] = 'scaffolding'; +| $route['404_override'] = 'errors/page_missing'; | -| This route lets you set a "secret" word that will trigger the -| scaffolding feature for added security. Note: Scaffolding must be -| enabled in the controller in which you intend to use it. The reserved -| routes must come before any wildcard or regular expression routes. +| This route will tell the Router what URI segments to use if those provided +| in the URL cannot be matched to a valid route. | */ @@ -44,6 +42,8 @@ $route['default_controller'] = "file"; $route['scaffolding_trigger'] = ""; $route['file/(:any)'] = "file/$1"; $route['(:any)'] = "file/index/$1"; +$route['404_override'] = ''; + /* End of file routes.php */ -/* Location: ./system/application/config/routes.php */ +/* Location: ./application/config/routes.php */
\ No newline at end of file diff --git a/system/application/config/example/smileys.php b/application/config/example/smileys.php index 7f3aba550..25d28b2c4 100755 --- a/system/application/config/example/smileys.php +++ b/application/config/example/smileys.php @@ -7,7 +7,7 @@ | Individual images can be used to replace multiple simileys. For example: | :-) and :) use the same image replacement. | -| Please see user guide for more info: +| Please see user guide for more info: | http://codeigniter.com/user_guide/helpers/smiley_helper.html | */ @@ -63,4 +63,4 @@ $smileys = array( ); /* End of file smileys.php */ -/* Location: ./system/application/config/smileys.php */
\ No newline at end of file +/* Location: ./application/config/smileys.php */
\ No newline at end of file diff --git a/system/application/config/example/user_agents.php b/application/config/example/user_agents.php index c01b2767d..e2d3c3af0 100755 --- a/system/application/config/example/user_agents.php +++ b/application/config/example/user_agents.php @@ -48,6 +48,8 @@ $platforms = array ( // 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', @@ -59,8 +61,8 @@ $browsers = array( 'Camino' => 'Camino', 'Netscape' => 'Netscape', 'OmniWeb' => 'OmniWeb', - 'Mozilla' => 'Mozilla', 'Safari' => 'Safari', + 'Mozilla' => 'Mozilla', 'Konqueror' => 'Konqueror', 'icab' => 'iCab', 'Lynx' => 'Lynx', @@ -92,6 +94,7 @@ $mobiles = array( 'nokia' => "Nokia", 'palm' => "Palm", 'iphone' => "Apple iPhone", + 'ipad' => "iPad", 'ipod' => "Apple iPod Touch", 'sony' => "Sony Ericsson", 'ericsson' => "Sony Ericsson", @@ -111,7 +114,7 @@ $mobiles = array( 'benq' => "BenQ", 'ipaq' => "HP iPaq", 'mot-' => "Motorola", - 'playstation portable' => "PlayStation Portable", + 'playstation portable' => "PlayStation Portable", 'hiptop' => "Danger Hiptop", 'nec-' => "NEC", 'panasonic' => "Panasonic", @@ -124,7 +127,7 @@ $mobiles = array( // Operating Systems 'symbian' => "Symbian", - 'SymbianOS' => "SymbianOS", + 'SymbianOS' => "SymbianOS", 'elaine' => "Palm", 'palm' => "Palm", 'series60' => "Symbian S60", @@ -149,7 +152,7 @@ $mobiles = array( // Fallback 'mobile' => "Generic Mobile", - 'wireless' => "Generic Mobile", + 'wireless' => "Generic Mobile", 'j2me' => "Generic Mobile", 'midp' => "Generic Mobile", 'cldc' => "Generic Mobile", @@ -172,4 +175,4 @@ $robots = array( ); /* End of file user_agents.php */ -/* Location: ./system/application/config/user_agents.php */
\ No newline at end of file +/* Location: ./application/config/user_agents.php */
\ No newline at end of file diff --git a/system/application/errors/index.html b/application/config/index.html index c942a79ce..c942a79ce 100644..100755 --- a/system/application/errors/index.html +++ b/application/config/index.html diff --git a/system/application/controllers/file.php b/application/controllers/file.php index a11255986..7d97913f2 100644 --- a/system/application/controllers/file.php +++ b/application/controllers/file.php @@ -7,11 +7,11 @@ * */ -class File extends Controller { +class File extends CI_Controller { function __construct() { - parent::Controller(); + parent::__construct(); $this->load->helper(array('form', 'filebin')); $this->load->model('file_mod'); $this->var->cli_client = false; diff --git a/system/application/helpers/index.html b/application/controllers/index.html index c942a79ce..c942a79ce 100644 --- a/system/application/helpers/index.html +++ b/application/controllers/index.html diff --git a/system/application/hooks/index.html b/application/core/index.html index c942a79ce..c942a79ce 100644..100755 --- a/system/application/hooks/index.html +++ b/application/core/index.html diff --git a/system/application/errors/error_404.php b/application/errors/error_404.php index 1c513a205..1c513a205 100644 --- a/system/application/errors/error_404.php +++ b/application/errors/error_404.php diff --git a/system/application/errors/error_db.php b/application/errors/error_db.php index 1ce52dfc9..1ce52dfc9 100644 --- a/system/application/errors/error_db.php +++ b/application/errors/error_db.php diff --git a/system/application/errors/error_general.php b/application/errors/error_general.php index d8610702b..d8610702b 100644 --- a/system/application/errors/error_general.php +++ b/application/errors/error_general.php diff --git a/system/application/errors/error_php.php b/application/errors/error_php.php index f085c2037..f085c2037 100644 --- a/system/application/errors/error_php.php +++ b/application/errors/error_php.php diff --git a/system/application/index.html b/application/errors/index.html index c942a79ce..c942a79ce 100644 --- a/system/application/index.html +++ b/application/errors/index.html diff --git a/system/application/helpers/filebin_helper.php b/application/helpers/filebin_helper.php index 3d6c30b76..3d6c30b76 100644 --- a/system/application/helpers/filebin_helper.php +++ b/application/helpers/filebin_helper.php diff --git a/system/application/language/english/index.html b/application/helpers/index.html index c942a79ce..c942a79ce 100644 --- a/system/application/language/english/index.html +++ b/application/helpers/index.html diff --git a/system/application/libraries/index.html b/application/hooks/index.html index c942a79ce..c942a79ce 100644 --- a/system/application/libraries/index.html +++ b/application/hooks/index.html diff --git a/system/application/models/index.html b/application/index.html index c942a79ce..c942a79ce 100644 --- a/system/application/models/index.html +++ b/application/index.html diff --git a/system/application/views/index.html b/application/language/english/index.html index c942a79ce..c942a79ce 100644 --- a/system/application/views/index.html +++ b/application/language/english/index.html diff --git a/system/application/libraries/MemcacheLibrary.php b/application/libraries/MemcacheLibrary.php index dcc08b942..dcc08b942 100644 --- a/system/application/libraries/MemcacheLibrary.php +++ b/application/libraries/MemcacheLibrary.php diff --git a/system/application/libraries/contrib/aliased.php b/application/libraries/contrib/aliased.php index 32bec9239..32bec9239 100644 --- a/system/application/libraries/contrib/aliased.php +++ b/application/libraries/contrib/aliased.php diff --git a/system/application/libraries/contrib/cssgen.php b/application/libraries/contrib/cssgen.php index f746b00c3..f746b00c3 100644 --- a/system/application/libraries/contrib/cssgen.php +++ b/application/libraries/contrib/cssgen.php diff --git a/system/application/libraries/contrib/cssgen2.php b/application/libraries/contrib/cssgen2.php index cc3c39cbf..cc3c39cbf 100644 --- a/system/application/libraries/contrib/cssgen2.php +++ b/application/libraries/contrib/cssgen2.php diff --git a/system/application/libraries/contrib/example.php b/application/libraries/contrib/example.php index 32e6f0c75..32e6f0c75 100644 --- a/system/application/libraries/contrib/example.php +++ b/application/libraries/contrib/example.php diff --git a/system/application/libraries/contrib/langcheck.php b/application/libraries/contrib/langcheck.php index a4ee4f65f..a4ee4f65f 100644 --- a/system/application/libraries/contrib/langcheck.php +++ b/application/libraries/contrib/langcheck.php diff --git a/system/application/libraries/geshi.php b/application/libraries/geshi.php index f6796c9f6..f6796c9f6 100644 --- a/system/application/libraries/geshi.php +++ b/application/libraries/geshi.php diff --git a/system/application/libraries/geshi/4cs.php b/application/libraries/geshi/4cs.php index 6ce702fbc..6ce702fbc 100644 --- a/system/application/libraries/geshi/4cs.php +++ b/application/libraries/geshi/4cs.php diff --git a/system/application/libraries/geshi/abap.php b/application/libraries/geshi/abap.php index fa69c92f9..fa69c92f9 100644 --- a/system/application/libraries/geshi/abap.php +++ b/application/libraries/geshi/abap.php diff --git a/system/application/libraries/geshi/actionscript.php b/application/libraries/geshi/actionscript.php index 394a463c4..394a463c4 100644 --- a/system/application/libraries/geshi/actionscript.php +++ b/application/libraries/geshi/actionscript.php diff --git a/system/application/libraries/geshi/actionscript3.php b/application/libraries/geshi/actionscript3.php index 8449173e8..8449173e8 100644 --- a/system/application/libraries/geshi/actionscript3.php +++ b/application/libraries/geshi/actionscript3.php diff --git a/system/application/libraries/geshi/ada.php b/application/libraries/geshi/ada.php index 4c112f0db..4c112f0db 100644 --- a/system/application/libraries/geshi/ada.php +++ b/application/libraries/geshi/ada.php diff --git a/system/application/libraries/geshi/apache.php b/application/libraries/geshi/apache.php index a5b651bb6..a5b651bb6 100644 --- a/system/application/libraries/geshi/apache.php +++ b/application/libraries/geshi/apache.php diff --git a/system/application/libraries/geshi/applescript.php b/application/libraries/geshi/applescript.php index 8a07d00b5..8a07d00b5 100644 --- a/system/application/libraries/geshi/applescript.php +++ b/application/libraries/geshi/applescript.php diff --git a/system/application/libraries/geshi/apt_sources.php b/application/libraries/geshi/apt_sources.php index fe1711fdd..fe1711fdd 100644 --- a/system/application/libraries/geshi/apt_sources.php +++ b/application/libraries/geshi/apt_sources.php diff --git a/system/application/libraries/geshi/asm.php b/application/libraries/geshi/asm.php index 49699b900..49699b900 100644 --- a/system/application/libraries/geshi/asm.php +++ b/application/libraries/geshi/asm.php diff --git a/system/application/libraries/geshi/asp.php b/application/libraries/geshi/asp.php index 6e799a802..6e799a802 100644 --- a/system/application/libraries/geshi/asp.php +++ b/application/libraries/geshi/asp.php diff --git a/system/application/libraries/geshi/autohotkey.php b/application/libraries/geshi/autohotkey.php index 1a6346340..1a6346340 100644 --- a/system/application/libraries/geshi/autohotkey.php +++ b/application/libraries/geshi/autohotkey.php diff --git a/system/application/libraries/geshi/autoit.php b/application/libraries/geshi/autoit.php index e3185d063..e3185d063 100644 --- a/system/application/libraries/geshi/autoit.php +++ b/application/libraries/geshi/autoit.php diff --git a/system/application/libraries/geshi/avisynth.php b/application/libraries/geshi/avisynth.php index 9031e8caa..9031e8caa 100644 --- a/system/application/libraries/geshi/avisynth.php +++ b/application/libraries/geshi/avisynth.php diff --git a/system/application/libraries/geshi/awk.php b/application/libraries/geshi/awk.php index abecf72b5..abecf72b5 100644 --- a/system/application/libraries/geshi/awk.php +++ b/application/libraries/geshi/awk.php diff --git a/system/application/libraries/geshi/bash.php b/application/libraries/geshi/bash.php index 0b1583b7b..0b1583b7b 100644 --- a/system/application/libraries/geshi/bash.php +++ b/application/libraries/geshi/bash.php diff --git a/system/application/libraries/geshi/basic4gl.php b/application/libraries/geshi/basic4gl.php index 55be6dc34..55be6dc34 100644 --- a/system/application/libraries/geshi/basic4gl.php +++ b/application/libraries/geshi/basic4gl.php diff --git a/system/application/libraries/geshi/bf.php b/application/libraries/geshi/bf.php index c69155e88..c69155e88 100644 --- a/system/application/libraries/geshi/bf.php +++ b/application/libraries/geshi/bf.php diff --git a/system/application/libraries/geshi/bibtex.php b/application/libraries/geshi/bibtex.php index 82c13b8bc..82c13b8bc 100644 --- a/system/application/libraries/geshi/bibtex.php +++ b/application/libraries/geshi/bibtex.php diff --git a/system/application/libraries/geshi/blitzbasic.php b/application/libraries/geshi/blitzbasic.php index c3871a21e..c3871a21e 100644 --- a/system/application/libraries/geshi/blitzbasic.php +++ b/application/libraries/geshi/blitzbasic.php diff --git a/system/application/libraries/geshi/bnf.php b/application/libraries/geshi/bnf.php index db5cdb59d..db5cdb59d 100644 --- a/system/application/libraries/geshi/bnf.php +++ b/application/libraries/geshi/bnf.php diff --git a/system/application/libraries/geshi/boo.php b/application/libraries/geshi/boo.php index df843797d..df843797d 100644 --- a/system/application/libraries/geshi/boo.php +++ b/application/libraries/geshi/boo.php diff --git a/system/application/libraries/geshi/c.php b/application/libraries/geshi/c.php index bb6be43e1..bb6be43e1 100644 --- a/system/application/libraries/geshi/c.php +++ b/application/libraries/geshi/c.php diff --git a/system/application/libraries/geshi/c_mac.php b/application/libraries/geshi/c_mac.php index 6ead4ae15..6ead4ae15 100644 --- a/system/application/libraries/geshi/c_mac.php +++ b/application/libraries/geshi/c_mac.php diff --git a/system/application/libraries/geshi/caddcl.php b/application/libraries/geshi/caddcl.php index 27474627e..27474627e 100644 --- a/system/application/libraries/geshi/caddcl.php +++ b/application/libraries/geshi/caddcl.php diff --git a/system/application/libraries/geshi/cadlisp.php b/application/libraries/geshi/cadlisp.php index 5061c79e4..5061c79e4 100644 --- a/system/application/libraries/geshi/cadlisp.php +++ b/application/libraries/geshi/cadlisp.php diff --git a/system/application/libraries/geshi/cfdg.php b/application/libraries/geshi/cfdg.php index 8d03b89df..8d03b89df 100644 --- a/system/application/libraries/geshi/cfdg.php +++ b/application/libraries/geshi/cfdg.php diff --git a/system/application/libraries/geshi/cfm.php b/application/libraries/geshi/cfm.php index cdb7bf32c..cdb7bf32c 100644 --- a/system/application/libraries/geshi/cfm.php +++ b/application/libraries/geshi/cfm.php diff --git a/system/application/libraries/geshi/cil.php b/application/libraries/geshi/cil.php index 4ca93ecb0..4ca93ecb0 100644 --- a/system/application/libraries/geshi/cil.php +++ b/application/libraries/geshi/cil.php diff --git a/system/application/libraries/geshi/clojure.php b/application/libraries/geshi/clojure.php index b970deea8..b970deea8 100644 --- a/system/application/libraries/geshi/clojure.php +++ b/application/libraries/geshi/clojure.php diff --git a/system/application/libraries/geshi/cmake.php b/application/libraries/geshi/cmake.php index a9cfaafdc..a9cfaafdc 100644 --- a/system/application/libraries/geshi/cmake.php +++ b/application/libraries/geshi/cmake.php diff --git a/system/application/libraries/geshi/cobol.php b/application/libraries/geshi/cobol.php index 63abf3f09..63abf3f09 100644 --- a/system/application/libraries/geshi/cobol.php +++ b/application/libraries/geshi/cobol.php diff --git a/system/application/libraries/geshi/cpp-qt.php b/application/libraries/geshi/cpp-qt.php index a96cd38af..a96cd38af 100644 --- a/system/application/libraries/geshi/cpp-qt.php +++ b/application/libraries/geshi/cpp-qt.php diff --git a/system/application/libraries/geshi/cpp.php b/application/libraries/geshi/cpp.php index 7fb1da360..7fb1da360 100644 --- a/system/application/libraries/geshi/cpp.php +++ b/application/libraries/geshi/cpp.php diff --git a/system/application/libraries/geshi/csharp.php b/application/libraries/geshi/csharp.php index aa166801d..aa166801d 100644 --- a/system/application/libraries/geshi/csharp.php +++ b/application/libraries/geshi/csharp.php diff --git a/system/application/libraries/geshi/css.php b/application/libraries/geshi/css.php index 04313d6d8..04313d6d8 100644 --- a/system/application/libraries/geshi/css.php +++ b/application/libraries/geshi/css.php diff --git a/system/application/libraries/geshi/cuesheet.php b/application/libraries/geshi/cuesheet.php index 2fd610c15..2fd610c15 100644 --- a/system/application/libraries/geshi/cuesheet.php +++ b/application/libraries/geshi/cuesheet.php diff --git a/system/application/libraries/geshi/d.php b/application/libraries/geshi/d.php index f9157a514..f9157a514 100644 --- a/system/application/libraries/geshi/d.php +++ b/application/libraries/geshi/d.php diff --git a/system/application/libraries/geshi/dcs.php b/application/libraries/geshi/dcs.php index daad329c3..daad329c3 100644 --- a/system/application/libraries/geshi/dcs.php +++ b/application/libraries/geshi/dcs.php diff --git a/system/application/libraries/geshi/delphi.php b/application/libraries/geshi/delphi.php index 2b758d7db..2b758d7db 100644 --- a/system/application/libraries/geshi/delphi.php +++ b/application/libraries/geshi/delphi.php diff --git a/system/application/libraries/geshi/diff.php b/application/libraries/geshi/diff.php index f1a4baf65..f1a4baf65 100644 --- a/system/application/libraries/geshi/diff.php +++ b/application/libraries/geshi/diff.php diff --git a/system/application/libraries/geshi/div.php b/application/libraries/geshi/div.php index 5804bb727..5804bb727 100644 --- a/system/application/libraries/geshi/div.php +++ b/application/libraries/geshi/div.php diff --git a/system/application/libraries/geshi/dos.php b/application/libraries/geshi/dos.php index c111e1b5e..c111e1b5e 100644 --- a/system/application/libraries/geshi/dos.php +++ b/application/libraries/geshi/dos.php diff --git a/system/application/libraries/geshi/dot.php b/application/libraries/geshi/dot.php index 6e4df2fff..6e4df2fff 100644 --- a/system/application/libraries/geshi/dot.php +++ b/application/libraries/geshi/dot.php diff --git a/system/application/libraries/geshi/eiffel.php b/application/libraries/geshi/eiffel.php index fa293c074..fa293c074 100644 --- a/system/application/libraries/geshi/eiffel.php +++ b/application/libraries/geshi/eiffel.php diff --git a/system/application/libraries/geshi/email.php b/application/libraries/geshi/email.php index a902433bf..a902433bf 100644 --- a/system/application/libraries/geshi/email.php +++ b/application/libraries/geshi/email.php diff --git a/system/application/libraries/geshi/erlang.php b/application/libraries/geshi/erlang.php index cb7f25bf8..cb7f25bf8 100644 --- a/system/application/libraries/geshi/erlang.php +++ b/application/libraries/geshi/erlang.php diff --git a/system/application/libraries/geshi/fo.php b/application/libraries/geshi/fo.php index aa4567961..aa4567961 100644 --- a/system/application/libraries/geshi/fo.php +++ b/application/libraries/geshi/fo.php diff --git a/system/application/libraries/geshi/fortran.php b/application/libraries/geshi/fortran.php index 7b390eda7..7b390eda7 100644 --- a/system/application/libraries/geshi/fortran.php +++ b/application/libraries/geshi/fortran.php diff --git a/system/application/libraries/geshi/freebasic.php b/application/libraries/geshi/freebasic.php index faeee92f9..faeee92f9 100644 --- a/system/application/libraries/geshi/freebasic.php +++ b/application/libraries/geshi/freebasic.php diff --git a/system/application/libraries/geshi/fsharp.php b/application/libraries/geshi/fsharp.php index 7743d3643..7743d3643 100644 --- a/system/application/libraries/geshi/fsharp.php +++ b/application/libraries/geshi/fsharp.php diff --git a/system/application/libraries/geshi/gambas.php b/application/libraries/geshi/gambas.php index a848440df..a848440df 100644 --- a/system/application/libraries/geshi/gambas.php +++ b/application/libraries/geshi/gambas.php diff --git a/system/application/libraries/geshi/gdb.php b/application/libraries/geshi/gdb.php index 10a35cd38..10a35cd38 100644 --- a/system/application/libraries/geshi/gdb.php +++ b/application/libraries/geshi/gdb.php diff --git a/system/application/libraries/geshi/genero.php b/application/libraries/geshi/genero.php index 0b5611627..0b5611627 100644 --- a/system/application/libraries/geshi/genero.php +++ b/application/libraries/geshi/genero.php diff --git a/system/application/libraries/geshi/gettext.php b/application/libraries/geshi/gettext.php index 10201bd1a..10201bd1a 100644 --- a/system/application/libraries/geshi/gettext.php +++ b/application/libraries/geshi/gettext.php diff --git a/system/application/libraries/geshi/glsl.php b/application/libraries/geshi/glsl.php index 8f521bfc1..8f521bfc1 100644 --- a/system/application/libraries/geshi/glsl.php +++ b/application/libraries/geshi/glsl.php diff --git a/system/application/libraries/geshi/gml.php b/application/libraries/geshi/gml.php index ec7cb5512..ec7cb5512 100644 --- a/system/application/libraries/geshi/gml.php +++ b/application/libraries/geshi/gml.php diff --git a/system/application/libraries/geshi/gnuplot.php b/application/libraries/geshi/gnuplot.php index b4762156c..b4762156c 100644 --- a/system/application/libraries/geshi/gnuplot.php +++ b/application/libraries/geshi/gnuplot.php diff --git a/system/application/libraries/geshi/groovy.php b/application/libraries/geshi/groovy.php index 0270d0135..0270d0135 100644 --- a/system/application/libraries/geshi/groovy.php +++ b/application/libraries/geshi/groovy.php diff --git a/system/application/libraries/geshi/haskell.php b/application/libraries/geshi/haskell.php index 024382deb..024382deb 100644 --- a/system/application/libraries/geshi/haskell.php +++ b/application/libraries/geshi/haskell.php diff --git a/system/application/libraries/geshi/hq9plus.php b/application/libraries/geshi/hq9plus.php index 89af3bee8..89af3bee8 100644 --- a/system/application/libraries/geshi/hq9plus.php +++ b/application/libraries/geshi/hq9plus.php diff --git a/system/application/libraries/geshi/html4strict.php b/application/libraries/geshi/html4strict.php index 08c7f30c7..08c7f30c7 100644 --- a/system/application/libraries/geshi/html4strict.php +++ b/application/libraries/geshi/html4strict.php diff --git a/system/application/libraries/geshi/idl.php b/application/libraries/geshi/idl.php index 64472140a..64472140a 100644 --- a/system/application/libraries/geshi/idl.php +++ b/application/libraries/geshi/idl.php diff --git a/system/application/libraries/geshi/ini.php b/application/libraries/geshi/ini.php index ae0e81ec4..ae0e81ec4 100644 --- a/system/application/libraries/geshi/ini.php +++ b/application/libraries/geshi/ini.php diff --git a/system/application/libraries/geshi/inno.php b/application/libraries/geshi/inno.php index 6d1b97965..6d1b97965 100644 --- a/system/application/libraries/geshi/inno.php +++ b/application/libraries/geshi/inno.php diff --git a/system/application/libraries/geshi/intercal.php b/application/libraries/geshi/intercal.php index 958f886ce..958f886ce 100644 --- a/system/application/libraries/geshi/intercal.php +++ b/application/libraries/geshi/intercal.php diff --git a/system/application/libraries/geshi/io.php b/application/libraries/geshi/io.php index eb4d8646e..eb4d8646e 100644 --- a/system/application/libraries/geshi/io.php +++ b/application/libraries/geshi/io.php diff --git a/system/application/libraries/geshi/java.php b/application/libraries/geshi/java.php index b4080f7ac..b4080f7ac 100644 --- a/system/application/libraries/geshi/java.php +++ b/application/libraries/geshi/java.php diff --git a/system/application/libraries/geshi/java5.php b/application/libraries/geshi/java5.php index 4abffc663..4abffc663 100644 --- a/system/application/libraries/geshi/java5.php +++ b/application/libraries/geshi/java5.php diff --git a/system/application/libraries/geshi/javascript.php b/application/libraries/geshi/javascript.php index 96c345477..96c345477 100644 --- a/system/application/libraries/geshi/javascript.php +++ b/application/libraries/geshi/javascript.php diff --git a/system/application/libraries/geshi/jquery.php b/application/libraries/geshi/jquery.php index b4264cb1c..b4264cb1c 100644 --- a/system/application/libraries/geshi/jquery.php +++ b/application/libraries/geshi/jquery.php diff --git a/system/application/libraries/geshi/kixtart.php b/application/libraries/geshi/kixtart.php index 3d37f8ce6..3d37f8ce6 100644 --- a/system/application/libraries/geshi/kixtart.php +++ b/application/libraries/geshi/kixtart.php diff --git a/system/application/libraries/geshi/klonec.php b/application/libraries/geshi/klonec.php index 24f32dbc3..24f32dbc3 100644 --- a/system/application/libraries/geshi/klonec.php +++ b/application/libraries/geshi/klonec.php diff --git a/system/application/libraries/geshi/klonecpp.php b/application/libraries/geshi/klonecpp.php index ad2844c6d..ad2844c6d 100644 --- a/system/application/libraries/geshi/klonecpp.php +++ b/application/libraries/geshi/klonecpp.php diff --git a/system/application/libraries/geshi/latex.php b/application/libraries/geshi/latex.php index ae7f0b3c5..ae7f0b3c5 100644 --- a/system/application/libraries/geshi/latex.php +++ b/application/libraries/geshi/latex.php diff --git a/system/application/libraries/geshi/lisp.php b/application/libraries/geshi/lisp.php index 3ca20fdc5..3ca20fdc5 100644 --- a/system/application/libraries/geshi/lisp.php +++ b/application/libraries/geshi/lisp.php diff --git a/system/application/libraries/geshi/locobasic.php b/application/libraries/geshi/locobasic.php index e0cceea3d..e0cceea3d 100644 --- a/system/application/libraries/geshi/locobasic.php +++ b/application/libraries/geshi/locobasic.php diff --git a/system/application/libraries/geshi/logtalk.php b/application/libraries/geshi/logtalk.php index 3321e0de4..3321e0de4 100644 --- a/system/application/libraries/geshi/logtalk.php +++ b/application/libraries/geshi/logtalk.php diff --git a/system/application/libraries/geshi/lolcode.php b/application/libraries/geshi/lolcode.php index 26e486d3a..26e486d3a 100644 --- a/system/application/libraries/geshi/lolcode.php +++ b/application/libraries/geshi/lolcode.php diff --git a/system/application/libraries/geshi/lotusformulas.php b/application/libraries/geshi/lotusformulas.php index 67fd4fa0a..67fd4fa0a 100644 --- a/system/application/libraries/geshi/lotusformulas.php +++ b/application/libraries/geshi/lotusformulas.php diff --git a/system/application/libraries/geshi/lotusscript.php b/application/libraries/geshi/lotusscript.php index 5c1d61f92..5c1d61f92 100644 --- a/system/application/libraries/geshi/lotusscript.php +++ b/application/libraries/geshi/lotusscript.php diff --git a/system/application/libraries/geshi/lscript.php b/application/libraries/geshi/lscript.php index 33cd0163d..33cd0163d 100644 --- a/system/application/libraries/geshi/lscript.php +++ b/application/libraries/geshi/lscript.php diff --git a/system/application/libraries/geshi/lsl2.php b/application/libraries/geshi/lsl2.php index 8b62fc219..8b62fc219 100644 --- a/system/application/libraries/geshi/lsl2.php +++ b/application/libraries/geshi/lsl2.php diff --git a/system/application/libraries/geshi/lua.php b/application/libraries/geshi/lua.php index 2a630b2c8..2a630b2c8 100644 --- a/system/application/libraries/geshi/lua.php +++ b/application/libraries/geshi/lua.php diff --git a/system/application/libraries/geshi/m68k.php b/application/libraries/geshi/m68k.php index 9aae868af..9aae868af 100644 --- a/system/application/libraries/geshi/m68k.php +++ b/application/libraries/geshi/m68k.php diff --git a/system/application/libraries/geshi/make.php b/application/libraries/geshi/make.php index 021265548..021265548 100644 --- a/system/application/libraries/geshi/make.php +++ b/application/libraries/geshi/make.php diff --git a/system/application/libraries/geshi/mapbasic.php b/application/libraries/geshi/mapbasic.php index 74be1f673..74be1f673 100644 --- a/system/application/libraries/geshi/mapbasic.php +++ b/application/libraries/geshi/mapbasic.php diff --git a/system/application/libraries/geshi/matlab.php b/application/libraries/geshi/matlab.php index f3ad34968..f3ad34968 100644 --- a/system/application/libraries/geshi/matlab.php +++ b/application/libraries/geshi/matlab.php diff --git a/system/application/libraries/geshi/mirc.php b/application/libraries/geshi/mirc.php index a27c6c265..a27c6c265 100644 --- a/system/application/libraries/geshi/mirc.php +++ b/application/libraries/geshi/mirc.php diff --git a/system/application/libraries/geshi/mmix.php b/application/libraries/geshi/mmix.php index efdb932f1..efdb932f1 100644 --- a/system/application/libraries/geshi/mmix.php +++ b/application/libraries/geshi/mmix.php diff --git a/system/application/libraries/geshi/modula3.php b/application/libraries/geshi/modula3.php index caff92788..caff92788 100644 --- a/system/application/libraries/geshi/modula3.php +++ b/application/libraries/geshi/modula3.php diff --git a/system/application/libraries/geshi/mpasm.php b/application/libraries/geshi/mpasm.php index d97f0b17f..d97f0b17f 100644 --- a/system/application/libraries/geshi/mpasm.php +++ b/application/libraries/geshi/mpasm.php diff --git a/system/application/libraries/geshi/mxml.php b/application/libraries/geshi/mxml.php index a2073d3ab..a2073d3ab 100644 --- a/system/application/libraries/geshi/mxml.php +++ b/application/libraries/geshi/mxml.php diff --git a/system/application/libraries/geshi/mysql.php b/application/libraries/geshi/mysql.php index 3bc6f9504..3bc6f9504 100644 --- a/system/application/libraries/geshi/mysql.php +++ b/application/libraries/geshi/mysql.php diff --git a/system/application/libraries/geshi/newlisp.php b/application/libraries/geshi/newlisp.php index ee2589a07..ee2589a07 100644 --- a/system/application/libraries/geshi/newlisp.php +++ b/application/libraries/geshi/newlisp.php diff --git a/system/application/libraries/geshi/nsis.php b/application/libraries/geshi/nsis.php index d5f631101..d5f631101 100644 --- a/system/application/libraries/geshi/nsis.php +++ b/application/libraries/geshi/nsis.php diff --git a/system/application/libraries/geshi/oberon2.php b/application/libraries/geshi/oberon2.php index 35152b55f..35152b55f 100644 --- a/system/application/libraries/geshi/oberon2.php +++ b/application/libraries/geshi/oberon2.php diff --git a/system/application/libraries/geshi/objc.php b/application/libraries/geshi/objc.php index 084be7124..084be7124 100644 --- a/system/application/libraries/geshi/objc.php +++ b/application/libraries/geshi/objc.php diff --git a/system/application/libraries/geshi/ocaml-brief.php b/application/libraries/geshi/ocaml-brief.php index d9e3124f0..d9e3124f0 100644 --- a/system/application/libraries/geshi/ocaml-brief.php +++ b/application/libraries/geshi/ocaml-brief.php diff --git a/system/application/libraries/geshi/ocaml.php b/application/libraries/geshi/ocaml.php index a14d2dec1..a14d2dec1 100644 --- a/system/application/libraries/geshi/ocaml.php +++ b/application/libraries/geshi/ocaml.php diff --git a/system/application/libraries/geshi/oobas.php b/application/libraries/geshi/oobas.php index b3a5a0b6d..b3a5a0b6d 100644 --- a/system/application/libraries/geshi/oobas.php +++ b/application/libraries/geshi/oobas.php diff --git a/system/application/libraries/geshi/oracle11.php b/application/libraries/geshi/oracle11.php index 08c25b66d..08c25b66d 100644 --- a/system/application/libraries/geshi/oracle11.php +++ b/application/libraries/geshi/oracle11.php diff --git a/system/application/libraries/geshi/oracle8.php b/application/libraries/geshi/oracle8.php index 5ac18786d..5ac18786d 100644 --- a/system/application/libraries/geshi/oracle8.php +++ b/application/libraries/geshi/oracle8.php diff --git a/system/application/libraries/geshi/pascal.php b/application/libraries/geshi/pascal.php index 948c00ce4..948c00ce4 100644 --- a/system/application/libraries/geshi/pascal.php +++ b/application/libraries/geshi/pascal.php diff --git a/system/application/libraries/geshi/per.php b/application/libraries/geshi/per.php index 06cf2e41b..06cf2e41b 100644 --- a/system/application/libraries/geshi/per.php +++ b/application/libraries/geshi/per.php diff --git a/system/application/libraries/geshi/perl.php b/application/libraries/geshi/perl.php index 57b8971e8..57b8971e8 100644 --- a/system/application/libraries/geshi/perl.php +++ b/application/libraries/geshi/perl.php diff --git a/system/application/libraries/geshi/perl6.php b/application/libraries/geshi/perl6.php index 1c04098c0..1c04098c0 100644 --- a/system/application/libraries/geshi/perl6.php +++ b/application/libraries/geshi/perl6.php diff --git a/system/application/libraries/geshi/php-brief.php b/application/libraries/geshi/php-brief.php index ceaf423af..ceaf423af 100644 --- a/system/application/libraries/geshi/php-brief.php +++ b/application/libraries/geshi/php-brief.php diff --git a/system/application/libraries/geshi/php.php b/application/libraries/geshi/php.php index 9b0bc822d..9b0bc822d 100644 --- a/system/application/libraries/geshi/php.php +++ b/application/libraries/geshi/php.php diff --git a/system/application/libraries/geshi/pic16.php b/application/libraries/geshi/pic16.php index 88d4a6745..88d4a6745 100644 --- a/system/application/libraries/geshi/pic16.php +++ b/application/libraries/geshi/pic16.php diff --git a/system/application/libraries/geshi/pike.php b/application/libraries/geshi/pike.php index e67975fe2..e67975fe2 100644 --- a/system/application/libraries/geshi/pike.php +++ b/application/libraries/geshi/pike.php diff --git a/system/application/libraries/geshi/pixelbender.php b/application/libraries/geshi/pixelbender.php index d19754f3e..d19754f3e 100644 --- a/system/application/libraries/geshi/pixelbender.php +++ b/application/libraries/geshi/pixelbender.php diff --git a/system/application/libraries/geshi/plsql.php b/application/libraries/geshi/plsql.php index 0779ca04f..0779ca04f 100644 --- a/system/application/libraries/geshi/plsql.php +++ b/application/libraries/geshi/plsql.php diff --git a/system/application/libraries/geshi/povray.php b/application/libraries/geshi/povray.php index 80bf5a478..80bf5a478 100644 --- a/system/application/libraries/geshi/povray.php +++ b/application/libraries/geshi/povray.php diff --git a/system/application/libraries/geshi/powerbuilder.php b/application/libraries/geshi/powerbuilder.php index e276d85ee..e276d85ee 100644 --- a/system/application/libraries/geshi/powerbuilder.php +++ b/application/libraries/geshi/powerbuilder.php diff --git a/system/application/libraries/geshi/powershell.php b/application/libraries/geshi/powershell.php index fe8a5da07..fe8a5da07 100644 --- a/system/application/libraries/geshi/powershell.php +++ b/application/libraries/geshi/powershell.php diff --git a/system/application/libraries/geshi/progress.php b/application/libraries/geshi/progress.php index 3824e7b0b..3824e7b0b 100644 --- a/system/application/libraries/geshi/progress.php +++ b/application/libraries/geshi/progress.php diff --git a/system/application/libraries/geshi/prolog.php b/application/libraries/geshi/prolog.php index 1f35a1b82..1f35a1b82 100644 --- a/system/application/libraries/geshi/prolog.php +++ b/application/libraries/geshi/prolog.php diff --git a/system/application/libraries/geshi/properties.php b/application/libraries/geshi/properties.php index 231dd6e8b..231dd6e8b 100644 --- a/system/application/libraries/geshi/properties.php +++ b/application/libraries/geshi/properties.php diff --git a/system/application/libraries/geshi/providex.php b/application/libraries/geshi/providex.php index aaa02e797..aaa02e797 100644 --- a/system/application/libraries/geshi/providex.php +++ b/application/libraries/geshi/providex.php diff --git a/system/application/libraries/geshi/purebasic.php b/application/libraries/geshi/purebasic.php index b644af3fe..b644af3fe 100644 --- a/system/application/libraries/geshi/purebasic.php +++ b/application/libraries/geshi/purebasic.php diff --git a/system/application/libraries/geshi/python.php b/application/libraries/geshi/python.php index a482d6928..a482d6928 100644 --- a/system/application/libraries/geshi/python.php +++ b/application/libraries/geshi/python.php diff --git a/system/application/libraries/geshi/qbasic.php b/application/libraries/geshi/qbasic.php index c83cb188e..c83cb188e 100644 --- a/system/application/libraries/geshi/qbasic.php +++ b/application/libraries/geshi/qbasic.php diff --git a/system/application/libraries/geshi/rails.php b/application/libraries/geshi/rails.php index 777fdd814..777fdd814 100644 --- a/system/application/libraries/geshi/rails.php +++ b/application/libraries/geshi/rails.php diff --git a/system/application/libraries/geshi/rebol.php b/application/libraries/geshi/rebol.php index 1a2e95824..1a2e95824 100644 --- a/system/application/libraries/geshi/rebol.php +++ b/application/libraries/geshi/rebol.php diff --git a/system/application/libraries/geshi/reg.php b/application/libraries/geshi/reg.php index d70189cc9..d70189cc9 100644 --- a/system/application/libraries/geshi/reg.php +++ b/application/libraries/geshi/reg.php diff --git a/system/application/libraries/geshi/robots.php b/application/libraries/geshi/robots.php index 82ff18f4f..82ff18f4f 100644 --- a/system/application/libraries/geshi/robots.php +++ b/application/libraries/geshi/robots.php diff --git a/system/application/libraries/geshi/rsplus.php b/application/libraries/geshi/rsplus.php index 10fa5a89e..10fa5a89e 100644 --- a/system/application/libraries/geshi/rsplus.php +++ b/application/libraries/geshi/rsplus.php diff --git a/system/application/libraries/geshi/ruby.php b/application/libraries/geshi/ruby.php index 57d379d66..57d379d66 100644 --- a/system/application/libraries/geshi/ruby.php +++ b/application/libraries/geshi/ruby.php diff --git a/system/application/libraries/geshi/sas.php b/application/libraries/geshi/sas.php index 16617b58e..16617b58e 100644 --- a/system/application/libraries/geshi/sas.php +++ b/application/libraries/geshi/sas.php diff --git a/system/application/libraries/geshi/scala.php b/application/libraries/geshi/scala.php index 5ebe9ed96..5ebe9ed96 100644 --- a/system/application/libraries/geshi/scala.php +++ b/application/libraries/geshi/scala.php diff --git a/system/application/libraries/geshi/scheme.php b/application/libraries/geshi/scheme.php index dac7c6f06..dac7c6f06 100644 --- a/system/application/libraries/geshi/scheme.php +++ b/application/libraries/geshi/scheme.php diff --git a/system/application/libraries/geshi/scilab.php b/application/libraries/geshi/scilab.php index 9bd0658db..9bd0658db 100644 --- a/system/application/libraries/geshi/scilab.php +++ b/application/libraries/geshi/scilab.php diff --git a/system/application/libraries/geshi/sdlbasic.php b/application/libraries/geshi/sdlbasic.php index 1f1440bf5..1f1440bf5 100644 --- a/system/application/libraries/geshi/sdlbasic.php +++ b/application/libraries/geshi/sdlbasic.php diff --git a/system/application/libraries/geshi/smalltalk.php b/application/libraries/geshi/smalltalk.php index 9bc351d8e..9bc351d8e 100644 --- a/system/application/libraries/geshi/smalltalk.php +++ b/application/libraries/geshi/smalltalk.php diff --git a/system/application/libraries/geshi/smarty.php b/application/libraries/geshi/smarty.php index f59d9fbf3..f59d9fbf3 100644 --- a/system/application/libraries/geshi/smarty.php +++ b/application/libraries/geshi/smarty.php diff --git a/system/application/libraries/geshi/sql.php b/application/libraries/geshi/sql.php index ea2965a8e..ea2965a8e 100644 --- a/system/application/libraries/geshi/sql.php +++ b/application/libraries/geshi/sql.php diff --git a/system/application/libraries/geshi/systemverilog.php b/application/libraries/geshi/systemverilog.php index 832769f9e..832769f9e 100644 --- a/system/application/libraries/geshi/systemverilog.php +++ b/application/libraries/geshi/systemverilog.php diff --git a/system/application/libraries/geshi/tcl.php b/application/libraries/geshi/tcl.php index 0b52a2687..0b52a2687 100644 --- a/system/application/libraries/geshi/tcl.php +++ b/application/libraries/geshi/tcl.php diff --git a/system/application/libraries/geshi/teraterm.php b/application/libraries/geshi/teraterm.php index b4ac619df..b4ac619df 100644 --- a/system/application/libraries/geshi/teraterm.php +++ b/application/libraries/geshi/teraterm.php diff --git a/system/application/libraries/geshi/text.php b/application/libraries/geshi/text.php index 24d3f10ee..24d3f10ee 100644 --- a/system/application/libraries/geshi/text.php +++ b/application/libraries/geshi/text.php diff --git a/system/application/libraries/geshi/thinbasic.php b/application/libraries/geshi/thinbasic.php index 6a0b72f9f..6a0b72f9f 100644 --- a/system/application/libraries/geshi/thinbasic.php +++ b/application/libraries/geshi/thinbasic.php diff --git a/system/application/libraries/geshi/tsql.php b/application/libraries/geshi/tsql.php index 4750997a3..4750997a3 100644 --- a/system/application/libraries/geshi/tsql.php +++ b/application/libraries/geshi/tsql.php diff --git a/system/application/libraries/geshi/typoscript.php b/application/libraries/geshi/typoscript.php index be809e856..be809e856 100644 --- a/system/application/libraries/geshi/typoscript.php +++ b/application/libraries/geshi/typoscript.php diff --git a/system/application/libraries/geshi/vb.php b/application/libraries/geshi/vb.php index 9849b3e86..9849b3e86 100644 --- a/system/application/libraries/geshi/vb.php +++ b/application/libraries/geshi/vb.php diff --git a/system/application/libraries/geshi/vbnet.php b/application/libraries/geshi/vbnet.php index 683b744f9..683b744f9 100644 --- a/system/application/libraries/geshi/vbnet.php +++ b/application/libraries/geshi/vbnet.php diff --git a/system/application/libraries/geshi/verilog.php b/application/libraries/geshi/verilog.php index 6fc469487..6fc469487 100644 --- a/system/application/libraries/geshi/verilog.php +++ b/application/libraries/geshi/verilog.php diff --git a/system/application/libraries/geshi/vhdl.php b/application/libraries/geshi/vhdl.php index ea93cf87b..ea93cf87b 100644 --- a/system/application/libraries/geshi/vhdl.php +++ b/application/libraries/geshi/vhdl.php diff --git a/system/application/libraries/geshi/vim.php b/application/libraries/geshi/vim.php index a95dc244c..a95dc244c 100644 --- a/system/application/libraries/geshi/vim.php +++ b/application/libraries/geshi/vim.php diff --git a/system/application/libraries/geshi/visualfoxpro.php b/application/libraries/geshi/visualfoxpro.php index 4d9f649ce..4d9f649ce 100644 --- a/system/application/libraries/geshi/visualfoxpro.php +++ b/application/libraries/geshi/visualfoxpro.php diff --git a/system/application/libraries/geshi/visualprolog.php b/application/libraries/geshi/visualprolog.php index 5c9bbd4d0..5c9bbd4d0 100644 --- a/system/application/libraries/geshi/visualprolog.php +++ b/application/libraries/geshi/visualprolog.php diff --git a/system/application/libraries/geshi/whitespace.php b/application/libraries/geshi/whitespace.php index a27a7b920..a27a7b920 100644 --- a/system/application/libraries/geshi/whitespace.php +++ b/application/libraries/geshi/whitespace.php diff --git a/system/application/libraries/geshi/whois.php b/application/libraries/geshi/whois.php index 019e91450..019e91450 100644 --- a/system/application/libraries/geshi/whois.php +++ b/application/libraries/geshi/whois.php diff --git a/system/application/libraries/geshi/winbatch.php b/application/libraries/geshi/winbatch.php index 5b5dcc1df..5b5dcc1df 100644 --- a/system/application/libraries/geshi/winbatch.php +++ b/application/libraries/geshi/winbatch.php diff --git a/system/application/libraries/geshi/xml.php b/application/libraries/geshi/xml.php index 608c99f00..608c99f00 100644 --- a/system/application/libraries/geshi/xml.php +++ b/application/libraries/geshi/xml.php diff --git a/system/application/libraries/geshi/xorg_conf.php b/application/libraries/geshi/xorg_conf.php index cdb6c36c9..cdb6c36c9 100644 --- a/system/application/libraries/geshi/xorg_conf.php +++ b/application/libraries/geshi/xorg_conf.php diff --git a/system/application/libraries/geshi/xpp.php b/application/libraries/geshi/xpp.php index 5f009ec8c..5f009ec8c 100644 --- a/system/application/libraries/geshi/xpp.php +++ b/application/libraries/geshi/xpp.php diff --git a/system/application/libraries/geshi/z80.php b/application/libraries/geshi/z80.php index b41e80c74..b41e80c74 100644 --- a/system/application/libraries/geshi/z80.php +++ b/application/libraries/geshi/z80.php diff --git a/system/cache/index.html b/application/libraries/index.html index c942a79ce..c942a79ce 100644 --- a/system/cache/index.html +++ b/application/libraries/index.html diff --git a/system/codeigniter/index.html b/application/logs/index.html index c942a79ce..c942a79ce 100644..100755 --- a/system/codeigniter/index.html +++ b/application/logs/index.html diff --git a/system/application/models/file_mod.php b/application/models/file_mod.php index 48ae5696b..c85bfe56d 100644 --- a/system/application/models/file_mod.php +++ b/application/models/file_mod.php @@ -7,11 +7,11 @@ * */ -class File_mod extends Model { +class File_mod extends CI_Model { function __construct() { - parent::Model(); + parent::__construct(); } // Returns an unused ID diff --git a/system/logs/index.html b/application/models/index.html index c942a79ce..c942a79ce 100644 --- a/system/logs/index.html +++ b/application/models/index.html diff --git a/system/plugins/index.html b/application/third_party/index.html index c942a79ce..c942a79ce 100644..100755 --- a/system/plugins/index.html +++ b/application/third_party/index.html diff --git a/system/application/views/file/client.php b/application/views/file/client.php index 0ebc20791..0ebc20791 100644 --- a/system/application/views/file/client.php +++ b/application/views/file/client.php diff --git a/system/application/views/file/delete_form.php b/application/views/file/delete_form.php index 7d4f2329f..7d4f2329f 100644 --- a/system/application/views/file/delete_form.php +++ b/application/views/file/delete_form.php diff --git a/system/application/views/file/deleted.php b/application/views/file/deleted.php index 865b5304a..865b5304a 100644 --- a/system/application/views/file/deleted.php +++ b/application/views/file/deleted.php diff --git a/system/application/views/file/footer.php b/application/views/file/footer.php index eda863585..eda863585 100644 --- a/system/application/views/file/footer.php +++ b/application/views/file/footer.php diff --git a/system/application/views/file/header.php b/application/views/file/header.php index f6073707a..f6073707a 100644 --- a/system/application/views/file/header.php +++ b/application/views/file/header.php diff --git a/system/application/views/file/html_footer.php b/application/views/file/html_footer.php index ddc460a39..ddc460a39 100644 --- a/system/application/views/file/html_footer.php +++ b/application/views/file/html_footer.php diff --git a/system/application/views/file/html_header.php b/application/views/file/html_header.php index 52ffab007..52ffab007 100644 --- a/system/application/views/file/html_header.php +++ b/application/views/file/html_header.php diff --git a/system/application/views/file/non_existent.php b/application/views/file/non_existent.php index 9f4a79913..9f4a79913 100644 --- a/system/application/views/file/non_existent.php +++ b/application/views/file/non_existent.php diff --git a/system/application/views/file/show_url.php b/application/views/file/show_url.php index e0e3dc8a6..e0e3dc8a6 100644 --- a/system/application/views/file/show_url.php +++ b/application/views/file/show_url.php diff --git a/system/application/views/file/too_big.php b/application/views/file/too_big.php index aa5c42835..aa5c42835 100644 --- a/system/application/views/file/too_big.php +++ b/application/views/file/too_big.php diff --git a/system/application/views/file/upload_error.php b/application/views/file/upload_error.php index e757b58c1..e757b58c1 100644 --- a/system/application/views/file/upload_error.php +++ b/application/views/file/upload_error.php diff --git a/system/application/views/file/upload_form.php b/application/views/file/upload_form.php index 4b23783dd..4b23783dd 100644 --- a/system/application/views/file/upload_form.php +++ b/application/views/file/upload_form.php diff --git a/system/scaffolding/images/index.html b/application/views/index.html index c942a79ce..c942a79ce 100644 --- a/system/scaffolding/images/index.html +++ b/application/views/index.html diff --git a/index.php b/index.php index dc8ca6cf8..5bb53d2f2 100644..100755 --- a/index.php +++ b/index.php @@ -1,118 +1,166 @@ <?php + /* -|--------------------------------------------------------------- -| PHP ERROR REPORTING LEVEL -|--------------------------------------------------------------- -| -| By default CI runs with error reporting set to ALL. For security -| reasons you are encouraged to change this when your site goes live. -| For more info visit: http://www.php.net/error_reporting -| -*/ - error_reporting(E_ALL^E_NOTICE); + *--------------------------------------------------------------- + * PHP ERROR REPORTING LEVEL + *--------------------------------------------------------------- + * + * By default CI runs with error reporting set to ALL. For security + * reasons you are encouraged to change this to 0 when your site goes live. + * For more info visit: http://www.php.net/error_reporting + * + */ + error_reporting(E_ALL); /* -|--------------------------------------------------------------- -| SYSTEM FOLDER NAME -|--------------------------------------------------------------- -| -| This variable must contain the name of your "system" folder. -| Include the path if the folder is not in the same directory -| as this file. -| -| NO TRAILING SLASH! -| -*/ - $system_folder = "system"; + *--------------------------------------------------------------- + * SYSTEM FOLDER NAME + *--------------------------------------------------------------- + * + * This variable must contain the name of your "system" folder. + * Include the path if the folder is not in the same directory + * as this file. + * + */ + $system_path = "system"; /* -|--------------------------------------------------------------- -| APPLICATION FOLDER NAME -|--------------------------------------------------------------- -| -| If you want this front controller to use a different "application" -| folder then the default one you can set its name here. The folder -| can also be renamed or relocated anywhere on your server. -| For more info please see the user guide: -| http://codeigniter.com/user_guide/general/managing_apps.html -| -| -| NO TRAILING SLASH! -| -*/ + *--------------------------------------------------------------- + * APPLICATION FOLDER NAME + *--------------------------------------------------------------- + * + * If you want this front controller to use a different "application" + * folder then the default one you can set its name here. The folder + * can also be renamed or relocated anywhere on your server. If + * you do, use a full server path. For more info please see the user guide: + * http://codeigniter.com/user_guide/general/managing_apps.html + * + * NO TRAILING SLASH! + * + */ $application_folder = "application"; /* -|=============================================================== -| END OF USER CONFIGURABLE SETTINGS -|=============================================================== -*/ + * -------------------------------------------------------------------- + * DEFAULT CONTROLLER + * -------------------------------------------------------------------- + * + * Normally you will set your default controller in the routes.php file. + * You can, however, force a custom routing by hard-coding a + * specific controller class/function here. For most applications, you + * WILL NOT set your routing here, but it's an option for those + * special instances where you might want to override the standard + * routing in a specific front controller that shares a common CI installation. + * + * IMPORTANT: If you set the routing here, NO OTHER controller will be + * callable. In essence, this preference limits your application to ONE + * specific controller. Leave the function name blank if you need + * to call functions dynamically via the URI. + * + * Un-comment the $routing array below to use this feature + * + */ + // The directory name, relative to the "controllers" folder. Leave blank + // if your controller is not in a sub-folder within the "controllers" folder + // $routing['directory'] = ''; + + // The controller class file name. Example: Mycontroller.php + // $routing['controller'] = ''; + + // The controller function you wish to be called. + // $routing['function'] = ''; + + +/* + * ------------------------------------------------------------------- + * CUSTOM CONFIG VALUES + * ------------------------------------------------------------------- + * + * The $assign_to_config array below will be passed dynamically to the + * config class when initialized. This allows you to set custom config + * items or override any default config values found in the config.php file. + * This can be handy as it permits you to share one application between + * multiple front controller files, with each file containing different + * config values. + * + * Un-comment the $assign_to_config array below to use this feature + * + */ + // $assign_to_config['name_of_config_item'] = 'value of config item'; + + + +// -------------------------------------------------------------------- +// END OF USER CONFIGURABLE SETTINGS. DO NOT EDIT BELOW THIS LINE +// -------------------------------------------------------------------- + + /* -|--------------------------------------------------------------- -| SET THE SERVER PATH -|--------------------------------------------------------------- -| -| Let's attempt to determine the full-server path to the "system" -| folder in order to reduce the possibility of path problems. -| Note: We only attempt this if the user hasn't specified a -| full server path. -| -*/ -if (strpos($system_folder, '/') === FALSE) -{ - if (function_exists('realpath') AND @realpath(dirname(__FILE__)) !== FALSE) + * --------------------------------------------------------------- + * Resolve the system path for increased reliability + * --------------------------------------------------------------- + */ + if (realpath($system_path) !== FALSE) { - $system_folder = realpath(dirname(__FILE__)).'/'.$system_folder; + $system_path = realpath($system_path).'/'; + } + + // ensure there's a trailing slash + $system_path = rtrim($system_path, '/').'/'; + + // Is the system path correct? + if ( ! is_dir($system_path)) + { + exit("Your system folder path does not appear to be set correctly. Please open the following file and correct this: ".pathinfo(__FILE__, PATHINFO_BASENAME)); } -} -else -{ - // Swap directory separators to Unix style for consistency - $system_folder = str_replace("\\", "/", $system_folder); -} /* -|--------------------------------------------------------------- -| DEFINE APPLICATION CONSTANTS -|--------------------------------------------------------------- -| -| EXT - The file extension. Typically ".php" -| SELF - The name of THIS file (typically "index.php") -| FCPATH - The full server path to THIS file -| BASEPATH - The full server path to the "system" folder -| APPPATH - The full server path to the "application" folder -| -*/ -define('EXT', '.php'); -define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME)); -define('FCPATH', str_replace(SELF, '', __FILE__)); -define('BASEPATH', $system_folder.'/'); - -if (is_dir($application_folder)) -{ - define('APPPATH', $application_folder.'/'); -} -else -{ - if ($application_folder == '') + * ------------------------------------------------------------------- + * Now that we know the path, set the main path constants + * ------------------------------------------------------------------- + */ + // The name of THIS file + define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME)); + + // The PHP file extension + define('EXT', '.php'); + + // Path to the system folder + define('BASEPATH', str_replace("\\", "/", $system_path)); + + // Path to the front controller (this file) + define('FCPATH', str_replace(SELF, '', __FILE__)); + + // Name of the "system folder" + define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/')); + + + // The path to the "application" folder + if (is_dir($application_folder)) { - $application_folder = 'application'; + define('APPPATH', $application_folder.'/'); } + else + { + if ( ! is_dir(BASEPATH.$application_folder.'/')) + { + exit("Your application folder path does not appear to be set correctly. Please open the following file and correct this: ".SELF); + } - define('APPPATH', BASEPATH.$application_folder.'/'); -} + define('APPPATH', BASEPATH.$application_folder.'/'); + } /* -|--------------------------------------------------------------- -| LOAD THE FRONT CONTROLLER -|--------------------------------------------------------------- -| -| And away we go... -| -*/ -require_once BASEPATH.'codeigniter/CodeIgniter'.EXT; + * -------------------------------------------------------------------- + * LOAD THE BOOTSTRAP FILE + * -------------------------------------------------------------------- + * + * And away we go... + * + */ +require_once BASEPATH.'core/CodeIgniter'.EXT; /* End of file index.php */ /* Location: ./index.php */
\ No newline at end of file diff --git a/system/.htaccess b/system/.htaccess index 8d2f25636..14249c50b 100644..100755 --- a/system/.htaccess +++ b/system/.htaccess @@ -1 +1 @@ -deny from all +Deny from all
\ No newline at end of file diff --git a/system/codeigniter/Base4.php b/system/codeigniter/Base4.php deleted file mode 100644 index 3561c2564..000000000 --- a/system/codeigniter/Base4.php +++ /dev/null @@ -1,69 +0,0 @@ -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); -/** - * CodeIgniter - * - * An open source application development framework for PHP 4.3.2 or newer - * - * @package CodeIgniter - * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. - * @license http://codeigniter.com/user_guide/license.html - * @link http://codeigniter.com - * @since Version 1.3 - * @filesource - */ - -// ------------------------------------------------------------------------ - -/** - * CI_BASE - For PHP 4 - * - * This file is used only when CodeIgniter is being run under PHP 4. - * - * In order to allow CI to work under PHP 4 we had to make the Loader class - * the parent of the Controller Base class. It's the only way we can - * enable functions like $this->load->library('email') to instantiate - * classes that can then be used within controllers as $this->email->send() - * - * PHP 4 also has trouble referencing the CI super object within application - * constructors since objects do not exist until the class is fully - * instantiated. Basically PHP 4 sucks... - * - * Since PHP 5 doesn't suffer from this problem so we load one of - * two files based on the version of PHP being run. - * - * @package CodeIgniter - * @subpackage codeigniter - * @category front-controller - * @author ExpressionEngine Dev Team - * @link http://codeigniter.com/user_guide/ - */ - class CI_Base extends CI_Loader { - - function CI_Base() - { - // This allows syntax like $this->load->foo() to work - parent::CI_Loader(); - $this->load =& $this; - - // This allows resources used within controller constructors to work - global $OBJ; - $OBJ = $this->load; // Do NOT use a reference. - } -} - -function &get_instance() -{ - global $CI, $OBJ; - - if (is_object($CI)) - { - return $CI; - } - - return $OBJ->load; -} - - -/* End of file Base4.php */ -/* Location: ./system/codeigniter/Base4.php */
\ No newline at end of file diff --git a/system/codeigniter/Base5.php b/system/codeigniter/Base5.php deleted file mode 100644 index 5d944ae5a..000000000 --- a/system/codeigniter/Base5.php +++ /dev/null @@ -1,56 +0,0 @@ -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); -/** - * CodeIgniter - * - * An open source application development framework for PHP 4.3.2 or newer - * - * @package CodeIgniter - * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. - * @license http://codeigniter.com/user_guide/license.html - * @link http://codeigniter.com - * @since Version 1.3 - * @filesource - */ - - -// ------------------------------------------------------------------------ - -/** - * CI_BASE - For PHP 5 - * - * This file contains some code used only when CodeIgniter is being - * run under PHP 5. It allows us to manage the CI super object more - * gracefully than what is possible with PHP 4. - * - * @package CodeIgniter - * @subpackage codeigniter - * @category front-controller - * @author ExpressionEngine Dev Team - * @link http://codeigniter.com/user_guide/ - */ - -class CI_Base { - - private static $instance; - - public function CI_Base() - { - self::$instance =& $this; - } - - public static function &get_instance() - { - return self::$instance; - } -} - -function &get_instance() -{ - return CI_Base::get_instance(); -} - - - -/* End of file Base5.php */ -/* Location: ./system/codeigniter/Base5.php */
\ No newline at end of file diff --git a/system/codeigniter/CodeIgniter.php b/system/codeigniter/CodeIgniter.php deleted file mode 100644 index 5d5bb144b..000000000 --- a/system/codeigniter/CodeIgniter.php +++ /dev/null @@ -1,280 +0,0 @@ -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); -/** - * CodeIgniter - * - * An open source application development framework for PHP 4.3.2 or newer - * - * @package CodeIgniter - * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. - * @license http://codeigniter.com/user_guide/license.html - * @link http://codeigniter.com - * @since Version 1.0 - * @filesource - */ - -// ------------------------------------------------------------------------ - -/** - * System Front Controller - * - * Loads the base classes and executes the request. - * - * @package CodeIgniter - * @subpackage codeigniter - * @category Front-controller - * @author ExpressionEngine Dev Team - * @link http://codeigniter.com/user_guide/ - */ - -// CI Version -define('CI_VERSION', '1.7.2'); - -/* - * ------------------------------------------------------ - * Load the global functions - * ------------------------------------------------------ - */ -require(BASEPATH.'codeigniter/Common'.EXT); - -/* - * ------------------------------------------------------ - * Load the compatibility override functions - * ------------------------------------------------------ - */ -require(BASEPATH.'codeigniter/Compat'.EXT); - -/* - * ------------------------------------------------------ - * Load the framework constants - * ------------------------------------------------------ - */ -require(APPPATH.'config/constants'.EXT); - -/* - * ------------------------------------------------------ - * Define a custom error handler so we can log PHP errors - * ------------------------------------------------------ - */ -set_error_handler('_exception_handler'); - -if ( ! is_php('5.3')) -{ - @set_magic_quotes_runtime(0); // Kill magic quotes -} - -/* - * ------------------------------------------------------ - * Start the timer... tick tock tick tock... - * ------------------------------------------------------ - */ - -$BM =& load_class('Benchmark'); -$BM->mark('total_execution_time_start'); -$BM->mark('loading_time_base_classes_start'); - -/* - * ------------------------------------------------------ - * Instantiate the hooks class - * ------------------------------------------------------ - */ - -$EXT =& load_class('Hooks'); - -/* - * ------------------------------------------------------ - * Is there a "pre_system" hook? - * ------------------------------------------------------ - */ -$EXT->_call_hook('pre_system'); - -/* - * ------------------------------------------------------ - * Instantiate the base classes - * ------------------------------------------------------ - */ - -$CFG =& load_class('Config'); -$URI =& load_class('URI'); -$RTR =& load_class('Router'); -$OUT =& load_class('Output'); - -/* - * ------------------------------------------------------ - * Is there a valid cache file? If so, we're done... - * ------------------------------------------------------ - */ - -if ($EXT->_call_hook('cache_override') === FALSE) -{ - if ($OUT->_display_cache($CFG, $URI) == TRUE) - { - exit; - } -} - -/* - * ------------------------------------------------------ - * Load the remaining base classes - * ------------------------------------------------------ - */ - -$IN =& load_class('Input'); -$LANG =& load_class('Language'); - -/* - * ------------------------------------------------------ - * Load the app controller and local controller - * ------------------------------------------------------ - * - * Note: Due to the poor object handling in PHP 4 we'll - * conditionally load different versions of the base - * class. Retaining PHP 4 compatibility requires a bit of a hack. - * - * Note: The Loader class needs to be included first - * - */ -if ( ! is_php('5.0.0')) -{ - load_class('Loader', FALSE); - require(BASEPATH.'codeigniter/Base4'.EXT); -} -else -{ - require(BASEPATH.'codeigniter/Base5'.EXT); -} - -// Load the base controller class -load_class('Controller', FALSE); - -// Load the local application controller -// Note: The Router class automatically validates the controller path. If this include fails it -// means that the default controller in the Routes.php file is not resolving to something valid. -if ( ! file_exists(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT)) -{ - show_error('Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.'); -} - -include(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT); - -// Set a mark point for benchmarking -$BM->mark('loading_time_base_classes_end'); - - -/* - * ------------------------------------------------------ - * Security check - * ------------------------------------------------------ - * - * None of the functions in the app controller or the - * loader class can be called via the URI, nor can - * controller functions that begin with an underscore - */ -$class = $RTR->fetch_class(); -$method = $RTR->fetch_method(); - -if ( ! class_exists($class) - OR $method == 'controller' - OR strncmp($method, '_', 1) == 0 - OR in_array(strtolower($method), array_map('strtolower', get_class_methods('Controller'))) - ) -{ - show_404("{$class}/{$method}"); -} - -/* - * ------------------------------------------------------ - * Is there a "pre_controller" hook? - * ------------------------------------------------------ - */ -$EXT->_call_hook('pre_controller'); - -/* - * ------------------------------------------------------ - * Instantiate the controller and call requested method - * ------------------------------------------------------ - */ - -// Mark a start point so we can benchmark the controller -$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_start'); - -$CI = new $class(); - -// Is this a scaffolding request? -if ($RTR->scaffolding_request === TRUE) -{ - if ($EXT->_call_hook('scaffolding_override') === FALSE) - { - $CI->_ci_scaffolding(); - } -} -else -{ - /* - * ------------------------------------------------------ - * Is there a "post_controller_constructor" hook? - * ------------------------------------------------------ - */ - $EXT->_call_hook('post_controller_constructor'); - - // Is there a "remap" function? - if (method_exists($CI, '_remap')) - { - $CI->_remap($method); - } - else - { - // is_callable() returns TRUE on some versions of PHP 5 for private and protected - // methods, so we'll use this workaround for consistent behavior - if ( ! in_array(strtolower($method), array_map('strtolower', get_class_methods($CI)))) - { - show_404("{$class}/{$method}"); - } - - // Call the requested method. - // Any URI segments present (besides the class/function) will be passed to the method for convenience - call_user_func_array(array(&$CI, $method), array_slice($URI->rsegments, 2)); - } -} - -// Mark a benchmark end point -$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_end'); - -/* - * ------------------------------------------------------ - * Is there a "post_controller" hook? - * ------------------------------------------------------ - */ -$EXT->_call_hook('post_controller'); - -/* - * ------------------------------------------------------ - * Send the final rendered output to the browser - * ------------------------------------------------------ - */ - -if ($EXT->_call_hook('display_override') === FALSE) -{ - $OUT->_display(); -} - -/* - * ------------------------------------------------------ - * Is there a "post_system" hook? - * ------------------------------------------------------ - */ -$EXT->_call_hook('post_system'); - -/* - * ------------------------------------------------------ - * Close the DB connection if one exists - * ------------------------------------------------------ - */ -if (class_exists('CI_DB') AND isset($CI->db)) -{ - $CI->db->close(); -} - - -/* End of file CodeIgniter.php */ -/* Location: ./system/codeigniter/CodeIgniter.php */
\ No newline at end of file diff --git a/system/codeigniter/Common.php b/system/codeigniter/Common.php deleted file mode 100644 index 3b84ffcc1..000000000 --- a/system/codeigniter/Common.php +++ /dev/null @@ -1,421 +0,0 @@ -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); -/** - * CodeIgniter - * - * An open source application development framework for PHP 4.3.2 or newer - * - * @package CodeIgniter - * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. - * @license http://codeigniter.com/user_guide/license.html - * @link http://codeigniter.com - * @since Version 1.0 - * @filesource - */ - -// ------------------------------------------------------------------------ - -/** -* Determines if the current version of PHP is greater then the supplied value -* -* Since there are a few places where we conditionally test for PHP > 5 -* we'll set a static variable. -* -* @access public -* @param string -* @return bool -*/ -function is_php($version = '5.0.0') -{ - static $_is_php; - $version = (string)$version; - - if ( ! isset($_is_php[$version])) - { - $_is_php[$version] = (version_compare(PHP_VERSION, $version) < 0) ? FALSE : TRUE; - } - - return $_is_php[$version]; -} - -// ------------------------------------------------------------------------ - -/** - * Tests for file writability - * - * is_writable() returns TRUE on Windows servers when you really can't write to - * the file, based on the read-only attribute. is_writable() is also unreliable - * on Unix servers if safe_mode is on. - * - * @access private - * @return void - */ -function is_really_writable($file) -{ - // If we're on a Unix server with safe_mode off we call is_writable - if (DIRECTORY_SEPARATOR == '/' AND @ini_get("safe_mode") == FALSE) - { - return is_writable($file); - } - - // For windows servers and safe_mode "on" installations we'll actually - // write a file then read it. Bah... - if (is_dir($file)) - { - $file = rtrim($file, '/').'/'.md5(rand(1,100)); - - if (($fp = @fopen($file, FOPEN_WRITE_CREATE)) === FALSE) - { - return FALSE; - } - - fclose($fp); - @chmod($file, DIR_WRITE_MODE); - @unlink($file); - return TRUE; - } - elseif (($fp = @fopen($file, FOPEN_WRITE_CREATE)) === FALSE) - { - return FALSE; - } - - fclose($fp); - return TRUE; -} - -// ------------------------------------------------------------------------ - -/** -* Class registry -* -* This function acts as a singleton. If the requested class does not -* exist it is instantiated and set to a static variable. If it has -* previously been instantiated the variable is returned. -* -* @access public -* @param string the class name being requested -* @param bool optional flag that lets classes get loaded but not instantiated -* @return object -*/ -function &load_class($class, $instantiate = TRUE) -{ - static $objects = array(); - - // Does the class exist? If so, we're done... - if (isset($objects[$class])) - { - return $objects[$class]; - } - - // If the requested class does not exist in the application/libraries - // folder we'll load the native class from the system/libraries folder. - if (file_exists(APPPATH.'libraries/'.config_item('subclass_prefix').$class.EXT)) - { - require(BASEPATH.'libraries/'.$class.EXT); - require(APPPATH.'libraries/'.config_item('subclass_prefix').$class.EXT); - $is_subclass = TRUE; - } - else - { - if (file_exists(APPPATH.'libraries/'.$class.EXT)) - { - require(APPPATH.'libraries/'.$class.EXT); - $is_subclass = FALSE; - } - else - { - require(BASEPATH.'libraries/'.$class.EXT); - $is_subclass = FALSE; - } - } - - if ($instantiate == FALSE) - { - $objects[$class] = TRUE; - return $objects[$class]; - } - - if ($is_subclass == TRUE) - { - $name = config_item('subclass_prefix').$class; - - $objects[$class] =& instantiate_class(new $name()); - return $objects[$class]; - } - - $name = ($class != 'Controller') ? 'CI_'.$class : $class; - - $objects[$class] =& instantiate_class(new $name()); - return $objects[$class]; -} - -/** - * Instantiate Class - * - * Returns a new class object by reference, used by load_class() and the DB class. - * Required to retain PHP 4 compatibility and also not make PHP 5.3 cry. - * - * Use: $obj =& instantiate_class(new Foo()); - * - * @access public - * @param object - * @return object - */ -function &instantiate_class(&$class_object) -{ - return $class_object; -} - -/** -* Loads the main config.php file -* -* @access private -* @return array -*/ -function &get_config() -{ - static $main_conf; - - if ( ! isset($main_conf)) - { - if ( ! file_exists(APPPATH.'config/config'.EXT)) - { - exit('The configuration file config'.EXT.' does not exist.'); - } - - require(APPPATH.'config/config'.EXT); - - if ( ! isset($config) OR ! is_array($config)) - { - exit('Your config file does not appear to be formatted correctly.'); - } - - $main_conf[0] =& $config; - } - return $main_conf[0]; -} - -/** -* Gets a config item -* -* @access public -* @return mixed -*/ -function config_item($item) -{ - static $config_item = array(); - - if ( ! isset($config_item[$item])) - { - $config =& get_config(); - - if ( ! isset($config[$item])) - { - return FALSE; - } - $config_item[$item] = $config[$item]; - } - - return $config_item[$item]; -} - - -/** -* Error Handler -* -* This function lets us invoke the exception class and -* display errors using the standard error template located -* in application/errors/errors.php -* This function will send the error page directly to the -* browser and exit. -* -* @access public -* @return void -*/ -function show_error($message, $status_code = 500) -{ - $error =& load_class('Exceptions'); - echo $error->show_error('An Error Was Encountered', $message, 'error_general', $status_code); - exit; -} - - -/** -* 404 Page Handler -* -* This function is similar to the show_error() function above -* However, instead of the standard error template it displays -* 404 errors. -* -* @access public -* @return void -*/ -function show_404($page = '') -{ - $error =& load_class('Exceptions'); - $error->show_404($page); - exit; -} - - -/** -* Error Logging Interface -* -* We use this as a simple mechanism to access the logging -* class and send messages to be logged. -* -* @access public -* @return void -*/ -function log_message($level = 'error', $message, $php_error = FALSE) -{ - static $LOG; - - $config =& get_config(); - if ($config['log_threshold'] == 0) - { - return; - } - - $LOG =& load_class('Log'); - $LOG->write_log($level, $message, $php_error); -} - - -/** - * Set HTTP Status Header - * - * @access public - * @param int the status code - * @param string - * @return void - */ -function set_status_header($code = 200, $text = '') -{ - $stati = array( - 200 => 'OK', - 201 => 'Created', - 202 => 'Accepted', - 203 => 'Non-Authoritative Information', - 204 => 'No Content', - 205 => 'Reset Content', - 206 => 'Partial Content', - - 300 => 'Multiple Choices', - 301 => 'Moved Permanently', - 302 => 'Found', - 304 => 'Not Modified', - 305 => 'Use Proxy', - 307 => 'Temporary Redirect', - - 400 => 'Bad Request', - 401 => 'Unauthorized', - 403 => 'Forbidden', - 404 => 'Not Found', - 405 => 'Method Not Allowed', - 406 => 'Not Acceptable', - 407 => 'Proxy Authentication Required', - 408 => 'Request Timeout', - 409 => 'Conflict', - 410 => 'Gone', - 411 => 'Length Required', - 412 => 'Precondition Failed', - 413 => 'Request Entity Too Large', - 414 => 'Request-URI Too Long', - 415 => 'Unsupported Media Type', - 416 => 'Requested Range Not Satisfiable', - 417 => 'Expectation Failed', - - 500 => 'Internal Server Error', - 501 => 'Not Implemented', - 502 => 'Bad Gateway', - 503 => 'Service Unavailable', - 504 => 'Gateway Timeout', - 505 => 'HTTP Version Not Supported' - ); - - if ($code == '' OR ! is_numeric($code)) - { - show_error('Status codes must be numeric', 500); - } - - if (isset($stati[$code]) AND $text == '') - { - $text = $stati[$code]; - } - - if ($text == '') - { - show_error('No status text available. Please check your status code number or supply your own message text.', 500); - } - - $server_protocol = (isset($_SERVER['SERVER_PROTOCOL'])) ? $_SERVER['SERVER_PROTOCOL'] : FALSE; - - if (substr(php_sapi_name(), 0, 3) == 'cgi') - { - header("Status: {$code} {$text}", TRUE); - } - elseif ($server_protocol == 'HTTP/1.1' OR $server_protocol == 'HTTP/1.0') - { - header($server_protocol." {$code} {$text}", TRUE, $code); - } - else - { - header("HTTP/1.1 {$code} {$text}", TRUE, $code); - } -} - - -/** -* Exception Handler -* -* This is the custom exception handler that is declaired at the top -* of Codeigniter.php. The main reason we use this is permit -* PHP errors to be logged in our own log files since we may -* not have access to server logs. Since this function -* effectively intercepts PHP errors, however, we also need -* to display errors based on the current error_reporting level. -* We do that with the use of a PHP error template. -* -* @access private -* @return void -*/ -function _exception_handler($severity, $message, $filepath, $line) -{ - // We don't bother with "strict" notices since they will fill up - // the log file with information that isn't normally very - // helpful. For example, if you are running PHP 5 and you - // use version 4 style class functions (without prefixes - // like "public", "private", etc.) you'll get notices telling - // you that these have been deprecated. - - if ($severity == E_STRICT) - { - return; - } - - $error =& load_class('Exceptions'); - - // Should we display the error? - // We'll get the current error_reporting level and add its bits - // with the severity bits to find out. - - if (($severity & error_reporting()) == $severity) - { - $error->show_php_error($severity, $message, $filepath, $line); - } - - // Should we log the error? No? We're done... - $config =& get_config(); - if ($config['log_threshold'] == 0) - { - return; - } - - $error->log_exception($severity, $message, $filepath, $line); -} - - - -/* End of file Common.php */ -/* Location: ./system/codeigniter/Common.php */
\ No newline at end of file diff --git a/system/codeigniter/Compat.php b/system/codeigniter/Compat.php deleted file mode 100644 index 40017a93b..000000000 --- a/system/codeigniter/Compat.php +++ /dev/null @@ -1,93 +0,0 @@ -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); -/** - * CodeIgniter - * - * An open source application development framework for PHP 4.3.2 or newer - * - * @package CodeIgniter - * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. - * @license http://codeigniter.com/user_guide/license.html - * @link http://codeigniter.com - * @since Version 1.0 - * @filesource - */ - -// ------------------------------------------------------------------------ - -/** - * Compatibility Functions - * - * Function overrides for older versions of PHP or PHP environments missing - * certain extensions / libraries - * - * @package CodeIgniter - * @subpackage codeigniter - * @category Compatibility Functions - * @author ExpressionEngine Development Team - * @link http://codeigniter.com/user_guide/ - */ - -// ------------------------------------------------------------------------ - -/* - * PHP versions prior to 5.0 don't support the E_STRICT constant - * so we need to explicitly define it otherwise the Exception class - * will generate errors when running under PHP 4 - * - */ -if ( ! defined('E_STRICT')) -{ - define('E_STRICT', 2048); -} - -/** - * ctype_digit() - * - * Determines if a string is comprised only of digits - * http://us.php.net/manual/en/function.ctype_digit.php - * - * @access public - * @param string - * @return bool - */ -if ( ! function_exists('ctype_digit')) -{ - function ctype_digit($str) - { - if ( ! is_string($str) OR $str == '') - { - return FALSE; - } - - return ! preg_match('/[^0-9]/', $str); - } -} - -// -------------------------------------------------------------------- - -/** - * ctype_alnum() - * - * Determines if a string is comprised of only alphanumeric characters - * http://us.php.net/manual/en/function.ctype-alnum.php - * - * @access public - * @param string - * @return bool - */ -if ( ! function_exists('ctype_alnum')) -{ - function ctype_alnum($str) - { - if ( ! is_string($str) OR $str == '') - { - return FALSE; - } - - return ! preg_match('/[^0-9a-z]/i', $str); - } -} - -/* End of file Compat.php */ -/* Location: ./system/codeigniter/Compat.php */
\ No newline at end of file diff --git a/system/libraries/Benchmark.php b/system/core/Benchmark.php index d485ee21d..515550e9f 100644..100755 --- a/system/libraries/Benchmark.php +++ b/system/core/Benchmark.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -80,13 +80,13 @@ class CI_Benchmark { { $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); } - + // -------------------------------------------------------------------- /** @@ -110,4 +110,4 @@ class CI_Benchmark { // END CI_Benchmark class /* End of file Benchmark.php */ -/* Location: ./system/libraries/Benchmark.php */
\ No newline at end of file +/* Location: ./system/core/Benchmark.php */
\ No newline at end of file diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php new file mode 100755 index 000000000..2d3f24958 --- /dev/null +++ b/system/core/CodeIgniter.php @@ -0,0 +1,340 @@ +<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); +/** + * CodeIgniter + * + * An open source application development framework for PHP 5.1.6 or newer + * + * @package CodeIgniter + * @author ExpressionEngine Dev Team + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. + * @license http://codeigniter.com/user_guide/license.html + * @link http://codeigniter.com + * @since Version 1.0 + * @filesource + */ + +// ------------------------------------------------------------------------ + +/** + * System Initialization File + * + * Loads the base classes and executes the request. + * + * @package CodeIgniter + * @subpackage codeigniter + * @category Front-controller + * @author ExpressionEngine Dev Team + * @link http://codeigniter.com/user_guide/ + */ + +/* + * ------------------------------------------------------ + * Define the CodeIgniter Version + * ------------------------------------------------------ + */ + define('CI_VERSION', '2.0'); + +/* + * ------------------------------------------------------ + * Load the global functions + * ------------------------------------------------------ + */ + require(BASEPATH.'core/Common'.EXT); + +/* + * ------------------------------------------------------ + * Load the framework constants + * ------------------------------------------------------ + */ + require(APPPATH.'config/constants'.EXT); + +/* + * ------------------------------------------------------ + * Define a custom error handler so we can log PHP errors + * ------------------------------------------------------ + */ + set_error_handler('_exception_handler'); + + if ( ! is_php('5.3')) + { + @set_magic_quotes_runtime(0); // Kill magic quotes + } + +/* + * ------------------------------------------------------ + * Set the subclass_prefix + * ------------------------------------------------------ + * + * Normally the "subclass_prefix" is set in the config file. + * The subclass prefix allows CI to know if a core class is + * being extended via a library in the local application + * "libraries" folder. Since CI allows config items to be + * overriden via data set in the main index. php file, + * before proceeding we need to know if a subclass_prefix + * override exists. If so, we will set this value now, + * before any classes are loaded + * Note: Since the config file data is cached it doesn't + * hurt to load it here. + */ + if (isset($assign_to_config['subclass_prefix']) AND $assign_to_config['subclass_prefix'] != '') + { + get_config(array('subclass_prefix' => $assign_to_config['subclass_prefix'])); + } + +/* + * ------------------------------------------------------ + * Set a liberal script execution time limit + * ------------------------------------------------------ + */ + if (function_exists("set_time_limit") == TRUE AND @ini_get("safe_mode") == 0) + { + @set_time_limit(300); + } + +/* + * ------------------------------------------------------ + * Start the timer... tick tock tick tock... + * ------------------------------------------------------ + */ + $BM =& load_class('Benchmark', 'core'); + $BM->mark('total_execution_time_start'); + $BM->mark('loading_time:_base_classes_start'); + +/* + * ------------------------------------------------------ + * Instantiate the hooks class + * ------------------------------------------------------ + */ + $EXT =& load_class('Hooks', 'core'); + +/* + * ------------------------------------------------------ + * Is there a "pre_system" hook? + * ------------------------------------------------------ + */ + $EXT->_call_hook('pre_system'); + +/* + * ------------------------------------------------------ + * Instantiate the config class + * ------------------------------------------------------ + */ + $CFG =& load_class('Config', 'core'); + + // Do we have any manually set config items in the index.php file? + if (isset($assign_to_config)) + { + $CFG->_assign_to_config($assign_to_config); + } + +/* + * ------------------------------------------------------ + * Instantiate the UTF-8 class + * ------------------------------------------------------ + * + * Note: Order here is rather important as the UTF-8 + * class needs to be used very early on, but it cannot + * properly determine if UTf-8 can be supported until + * after the Config class is instantiated. + * + */ + + $UNI =& load_class('Utf8', 'core'); + +/* + * ------------------------------------------------------ + * Instantiate the URI class + * ------------------------------------------------------ + */ + $URI =& load_class('URI', 'core'); + +/* + * ------------------------------------------------------ + * Instantiate the routing class and set the routing + * ------------------------------------------------------ + */ + $RTR =& load_class('Router', 'core'); + $RTR->_set_routing(); + + // Set any routing overrides that may exist in the main index file + if (isset($routing)) + { + $RTR->_set_overrides($routing); + } + +/* + * ------------------------------------------------------ + * Instantiate the output class + * ------------------------------------------------------ + */ + $OUT =& load_class('Output', 'core'); + +/* + * ------------------------------------------------------ + * Is there a valid cache file? If so, we're done... + * ------------------------------------------------------ + */ + if ($EXT->_call_hook('cache_override') === FALSE) + { + if ($OUT->_display_cache($CFG, $URI) == TRUE) + { + exit; + } + } + +/* + * ------------------------------------------------------ + * Load the Input class and sanitize globals + * ------------------------------------------------------ + */ + $IN =& load_class('Input', 'core'); + +/* + * ------------------------------------------------------ + * Load the Language class + * ------------------------------------------------------ + */ + $LANG =& load_class('Lang', 'core'); + +/* + * ------------------------------------------------------ + * Load the app controller and local controller + * ------------------------------------------------------ + * + */ + // Load the base controller class + require BASEPATH.'core/Controller'.EXT; + + function &get_instance() + { + return CI_Controller::get_instance(); + } + + + if (file_exists(APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller'.EXT)) + { + require APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller'.EXT; + } + + // Load the local application controller + // Note: The Router class automatically validates the controller path using the router->_validate_request(). + // If this include fails it means that the default controller in the Routes.php file is not resolving to something valid. + if ( ! file_exists(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT)) + { + show_error('Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.'); + } + + include(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT); + + // Set a mark point for benchmarking + $BM->mark('loading_time:_base_classes_end'); + +/* + * ------------------------------------------------------ + * Security check + * ------------------------------------------------------ + * + * None of the functions in the app controller or the + * loader class can be called via the URI, nor can + * controller functions that begin with an underscore + */ + $class = $RTR->fetch_class(); + $method = $RTR->fetch_method(); + + if ( ! class_exists($class) + OR strncmp($method, '_', 1) == 0 + OR in_array(strtolower($method), array_map('strtolower', get_class_methods('CI_Controller'))) + ) + { + show_404("{$class}/{$method}"); + } + +/* + * ------------------------------------------------------ + * Is there a "pre_controller" hook? + * ------------------------------------------------------ + */ + $EXT->_call_hook('pre_controller'); + +/* + * ------------------------------------------------------ + * Instantiate the requested controller + * ------------------------------------------------------ + */ + // Mark a start point so we can benchmark the controller + $BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_start'); + + $CI = new $class(); + +/* + * ------------------------------------------------------ + * Is there a "post_controller_constructor" hook? + * ------------------------------------------------------ + */ + $EXT->_call_hook('post_controller_constructor'); + +/* + * ------------------------------------------------------ + * Call the requested method + * ------------------------------------------------------ + */ + // Is there a "remap" function? If so, we call it instead + if (method_exists($CI, '_remap')) + { + $CI->_remap($method, array_slice($URI->rsegments, 2)); + } + else + { + // is_callable() returns TRUE on some versions of PHP 5 for private and protected + // methods, so we'll use this workaround for consistent behavior + if ( ! in_array(strtolower($method), array_map('strtolower', get_class_methods($CI)))) + { + 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 */
\ No newline at end of file diff --git a/system/core/Common.php b/system/core/Common.php new file mode 100755 index 000000000..b5adfacb3 --- /dev/null +++ b/system/core/Common.php @@ -0,0 +1,503 @@ +<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); +/** + * CodeIgniter + * + * An open source application development framework for PHP 5.1.6 or newer + * + * @package CodeIgniter + * @author ExpressionEngine Dev Team + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. + * @license http://codeigniter.com/user_guide/license.html + * @link http://codeigniter.com + * @since Version 1.0 + * @filesource + */ + +// ------------------------------------------------------------------------ + +/** + * Common Functions + * + * Loads the base classes and executes the request. + * + * @package CodeIgniter + * @subpackage codeigniter + * @category Common Functions + * @author ExpressionEngine Dev Team + * @link http://codeigniter.com/user_guide/ + */ + +// ------------------------------------------------------------------------ + +/** +* Determines if the current version of PHP is greater then the supplied value +* +* Since there are a few places where we conditionally test for PHP > 5 +* we'll set a static variable. +* +* @access public +* @param string +* @return bool TRUE if the current version is $version or higher +*/ + function is_php($version = '5.0.0') + { + static $_is_php; + $version = (string)$version; + + if ( ! isset($_is_php[$version])) + { + $_is_php[$version] = (version_compare(PHP_VERSION, $version) < 0) ? FALSE : TRUE; + } + + return $_is_php[$version]; + } + +// ------------------------------------------------------------------------ + +/** + * Tests for file writability + * + * is_writable() returns TRUE on Windows servers when you really can't write to + * the file, based on the read-only attribute. is_writable() is also unreliable + * on Unix servers if safe_mode is on. + * + * @access private + * @return void + */ + function is_really_writable($file) + { + // If we're on a Unix server with safe_mode off we call is_writable + if (DIRECTORY_SEPARATOR == '/' AND @ini_get("safe_mode") == FALSE) + { + return is_writable($file); + } + + // For windows servers and safe_mode "on" installations we'll actually + // write a file then read it. Bah... + if (is_dir($file)) + { + $file = rtrim($file, '/').'/'.md5(mt_rand(1,100).mt_rand(1,100)); + + if (($fp = @fopen($file, FOPEN_WRITE_CREATE)) === FALSE) + { + return FALSE; + } + + fclose($fp); + @chmod($file, DIR_WRITE_MODE); + @unlink($file); + return TRUE; + } + elseif (($fp = @fopen($file, FOPEN_WRITE_CREATE)) === FALSE) + { + return FALSE; + } + + fclose($fp); + return TRUE; + } + +// ------------------------------------------------------------------------ + +/** +* Class registry +* +* This function acts as a singleton. If the requested class does not +* exist it is instantiated and set to a static variable. If it has +* previously been instantiated the variable is returned. +* +* @access public +* @param string the class name being requested +* @param string the directory where the class should be found +* @param string the class name prefix +* @return object +*/ + function &load_class($class, $directory = 'libraries', $prefix = 'CI_') + { + static $_classes = array(); + + // Does the class exist? If so, we're done... + if (isset($_classes[$class])) + { + return $_classes[$class]; + } + + $name = FALSE; + + // Look for the class first in the native system/libraries folder + // thenin the local application/libraries folder + foreach (array(BASEPATH, APPPATH) as $path) + { + if (file_exists($path.$directory.'/'.$class.EXT)) + { + $name = $prefix.$class; + + if (class_exists($name) === FALSE) + { + require($path.$directory.'/'.$class.EXT); + } + + break; + } + } + + // Is the request a class extension? If so we load it too + if (file_exists(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.EXT)) + { + $name = config_item('subclass_prefix').$class; + + if (class_exists($name) === FALSE) + { + require(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.EXT); + } + } + + // Did we find the class? + if ($name === FALSE) + { + // Note: We use exit() rather then show_error() in order to avoid a + // self-referencing loop with the Excptions class + exit('Unable to locate the specified class: '.$class.EXT); + } + + // Keep track of what we just loaded + is_loaded($class); + + $_classes[$class] = new $name(); + return $_classes[$class]; + } + +// -------------------------------------------------------------------- + +/** +* Keeps track of which libraries have been loaded. This function is +* called by the load_class() function above +* +* @access public +* @return array +*/ + function is_loaded($class = '') + { + static $_is_loaded = array(); + + if ($class != '') + { + $_is_loaded[strtolower($class)] = $class; + } + + return $_is_loaded; + } + +// ------------------------------------------------------------------------ + +/** +* Loads the main config.php file +* +* This function lets us grab the config file even if the Config class +* hasn't been instantiated yet +* +* @access private +* @return array +*/ + function &get_config($replace = array()) + { + static $_config; + + if (isset($_config)) + { + return $_config[0]; + } + + // Fetch the config file + if ( ! file_exists(APPPATH.'config/config'.EXT)) + { + exit('The configuration file does not exist.'); + } + else + { + require(APPPATH.'config/config'.EXT); + } + + // Does the $config array exist in the file? + if ( ! isset($config) OR ! is_array($config)) + { + exit('Your config file does not appear to be formatted correctly.'); + } + + // Are any values being dynamically replaced? + if (count($replace) > 0) + { + foreach ($replace as $key => $val) + { + if (isset($config[$key])) + { + $config[$key] = $val; + } + } + } + + return $_config[0] =& $config; + } + +// ------------------------------------------------------------------------ + +/** +* Returns the specified config item +* +* @access public +* @return mixed +*/ + function config_item($item) + { + static $_config_item = array(); + + if ( ! isset($_config_item[$item])) + { + $config =& get_config(); + + if ( ! isset($config[$item])) + { + return FALSE; + } + $_config_item[$item] = $config[$item]; + } + + return $_config_item[$item]; + } + +// ------------------------------------------------------------------------ + +/** +* Error Handler +* +* This function lets us invoke the exception class and +* display errors using the standard error template located +* in application/errors/errors.php +* This function will send the error page directly to the +* browser and exit. +* +* @access public +* @return void +*/ + function show_error($message, $status_code = 500, $heading = 'An Error Was Encountered') + { + $_error =& load_class('Exceptions', 'core'); + echo $_error->show_error($heading, $message, 'error_general', $status_code); + exit; + } + +// ------------------------------------------------------------------------ + +/** +* 404 Page Handler +* +* This function is similar to the show_error() function above +* However, instead of the standard error template it displays +* 404 errors. +* +* @access public +* @return void +*/ + function show_404($page = '', $log_error = TRUE) + { + $_error =& load_class('Exceptions', 'core'); + $_error->show_404($page, $log_error); + exit; + } + +// ------------------------------------------------------------------------ + +/** +* Error Logging Interface +* +* We use this as a simple mechanism to access the logging +* class and send messages to be logged. +* +* @access public +* @return void +*/ + function log_message($level = 'error', $message, $php_error = FALSE) + { + static $_log; + + if (config_item('log_threshold') == 0) + { + return; + } + + $_log =& load_class('Log'); + $_log->write_log($level, $message, $php_error); + } + +// ------------------------------------------------------------------------ + +/** + * Set HTTP Status Header + * + * @access public + * @param int the status code + * @param string + * @return void + */ + function set_status_header($code = 200, $text = '') + { + $stati = array( + 200 => 'OK', + 201 => 'Created', + 202 => 'Accepted', + 203 => 'Non-Authoritative Information', + 204 => 'No Content', + 205 => 'Reset Content', + 206 => 'Partial Content', + + 300 => 'Multiple Choices', + 301 => 'Moved Permanently', + 302 => 'Found', + 304 => 'Not Modified', + 305 => 'Use Proxy', + 307 => 'Temporary Redirect', + + 400 => 'Bad Request', + 401 => 'Unauthorized', + 403 => 'Forbidden', + 404 => 'Not Found', + 405 => 'Method Not Allowed', + 406 => 'Not Acceptable', + 407 => 'Proxy Authentication Required', + 408 => 'Request Timeout', + 409 => 'Conflict', + 410 => 'Gone', + 411 => 'Length Required', + 412 => 'Precondition Failed', + 413 => 'Request Entity Too Large', + 414 => 'Request-URI Too Long', + 415 => 'Unsupported Media Type', + 416 => 'Requested Range Not Satisfiable', + 417 => 'Expectation Failed', + + 500 => 'Internal Server Error', + 501 => 'Not Implemented', + 502 => 'Bad Gateway', + 503 => 'Service Unavailable', + 504 => 'Gateway Timeout', + 505 => 'HTTP Version Not Supported' + ); + + if ($code == '' OR ! is_numeric($code)) + { + show_error('Status codes must be numeric', 500); + } + + if (isset($stati[$code]) AND $text == '') + { + $text = $stati[$code]; + } + + if ($text == '') + { + show_error('No status text available. Please check your status code number or supply your own message text.', 500); + } + + $server_protocol = (isset($_SERVER['SERVER_PROTOCOL'])) ? $_SERVER['SERVER_PROTOCOL'] : FALSE; + + if (substr(php_sapi_name(), 0, 3) == 'cgi') + { + header("Status: {$code} {$text}", TRUE); + } + elseif ($server_protocol == 'HTTP/1.1' OR $server_protocol == 'HTTP/1.0') + { + header($server_protocol." {$code} {$text}", TRUE, $code); + } + else + { + header("HTTP/1.1 {$code} {$text}", TRUE, $code); + } + } + +// -------------------------------------------------------------------- + +/** +* Exception Handler +* +* This is the custom exception handler that is declaired at the top +* of Codeigniter.php. The main reason we use this is to permit +* PHP errors to be logged in our own log files since the user may +* not have access to server logs. Since this function +* effectively intercepts PHP errors, however, we also need +* to display errors based on the current error_reporting level. +* We do that with the use of a PHP error template. +* +* @access private +* @return void +*/ + function _exception_handler($severity, $message, $filepath, $line) + { + // We don't bother with "strict" notices since they tend to fill up + // the log file with excess information that isn't normally very helpful. + // For example, if you are running PHP 5 and you use version 4 style + // class functions (without prefixes like "public", "private", etc.) + // you'll get notices telling you that these have been deprecated. + if ($severity == E_STRICT) + { + return; + } + + $_error =& load_class('Exceptions', 'core'); + + // Should we display the error? We'll get the current error_reporting + // level and add its bits with the severity bits to find out. + if (($severity & error_reporting()) == $severity) + { + $_error->show_php_error($severity, $message, $filepath, $line); + } + + // Should we log the error? No? We're done... + if (config_item('log_threshold') == 0) + { + return; + } + + $_error->log_exception($severity, $message, $filepath, $line); + } + + // -------------------------------------------------------------------- + + /** + * Remove Invisible Characters + * + * This prevents sandwiching null characters + * between ascii characters, like Java\0script. + * + * @access public + * @param string + * @return string + */ + function remove_invisible_characters($str) + { + static $non_displayables; + + if ( ! isset($non_displayables)) + { + // every control character except newline (dec 10), carriage return (dec 13), and horizontal tab (dec 09), + $non_displayables = array( + '/%0[0-8bcef]/', // url encoded 00-08, 11, 12, 14, 15 + '/%1[0-9a-f]/', // url encoded 16-31 + '/[\x00-\x08]/', // 00-08 + '/\x0b/', '/\x0c/', // 11, 12 + '/[\x0e-\x1f]/' // 14-31 + ); + } + + do + { + $cleaned = $str; + $str = preg_replace($non_displayables, '', $str); + } + while ($cleaned != $str); + + return $str; + } + + +/* End of file Common.php */ +/* Location: ./system/core/Common.php */
\ No newline at end of file diff --git a/system/libraries/Config.php b/system/core/Config.php index 760120779..bfb60fa44 100644..100755 --- a/system/libraries/Config.php +++ b/system/core/Config.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -30,6 +30,7 @@ class CI_Config { var $config = array(); var $is_loaded = array(); + var $_config_paths = array(APPPATH); /** * Constructor @@ -42,12 +43,30 @@ class CI_Config { * @param boolean true if errors should just return false, false if an error message should be displayed * @return boolean if the file was successfully loaded or not */ - function CI_Config() + 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); + } } - + // -------------------------------------------------------------------- /** @@ -56,59 +75,73 @@ class CI_Config { * @access public * @param string the config file name * @return boolean if the file was loaded correctly - */ + */ function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE) { $file = ($file == '') ? 'config' : str_replace(EXT, '', $file); - - if (in_array($file, $this->is_loaded, TRUE)) - { - return TRUE; - } + $loaded = FALSE; - if ( ! file_exists(APPPATH.'config/'.$file.EXT)) + foreach($this->_config_paths as $path) { - if ($fail_gracefully === TRUE) + $file_path = $path.'config/'.$file.EXT; + + if (in_array($file_path, $this->is_loaded, TRUE)) { - return FALSE; + $loaded = TRUE; + continue; } - show_error('The configuration file '.$file.EXT.' does not exist.'); - } - - include(APPPATH.'config/'.$file.EXT); - if ( ! isset($config) OR ! is_array($config)) - { - if ($fail_gracefully === TRUE) + if ( ! file_exists($path.'config/'.$file.EXT)) { - return FALSE; + continue; } - show_error('Your '.$file.EXT.' file does not appear to contain a valid configuration array.'); - } - if ($use_sections === TRUE) - { - if (isset($this->config[$file])) + include($file_path); + + if ( ! isset($config) OR ! is_array($config)) { - $this->config[$file] = array_merge($this->config[$file], $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[$file] = $config; + $this->config = array_merge($this->config, $config); } + + $this->is_loaded[] = $file_path; + unset($config); + + $loaded = TRUE; + log_message('debug', 'Config file loaded: '.$file_path); } - else + + if ($loaded === FALSE) { - $this->config = array_merge($this->config, $config); + if ($fail_gracefully === TRUE) + { + return FALSE; + } + show_error('The configuration file '.$file.EXT.' does not exist.'); } - $this->is_loaded[] = $file; - unset($config); - - log_message('debug', 'Config file loaded: config/'.$file.EXT); return TRUE; } - + // -------------------------------------------------------------------- /** @@ -122,9 +155,9 @@ class CI_Config { * @return string */ function item($item, $index = '') - { + { if ($index == '') - { + { if ( ! isset($this->config[$item])) { return FALSE; @@ -149,8 +182,8 @@ class CI_Config { return $pref; } - - // -------------------------------------------------------------------- + + // -------------------------------------------------------------------- /** * Fetch a config file item - adds slash after item @@ -170,16 +203,9 @@ class CI_Config { return FALSE; } - $pref = $this->config[$item]; - - if ($pref != '' && substr($pref, -1) != '/') - { - $pref .= '/'; - } - - return $pref; + return rtrim($this->config[$item], '/').'/'; } - + // -------------------------------------------------------------------- /** @@ -191,22 +217,42 @@ class CI_Config { */ function site_url($uri = '') { - if (is_array($uri)) + if ($uri == '') { - $uri = implode('/', $uri); + return $this->slash_item('base_url').$this->item('index_page'); } - if ($uri == '') + if ($this->item('enable_query_strings') == FALSE) { - return $this->slash_item('base_url').$this->item('index_page'); + if (is_array($uri)) + { + $uri = implode('/', $uri); + } + + $index = $this->item('index_page') == '' ? '' : $this->slash_item('index_page'); + $suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix'); + return $this->slash_item('base_url').$index.trim($uri, '/').$suffix; } else { - $suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix'); - return $this->slash_item('base_url').$this->slash_item('index_page').trim($uri, '/').$suffix; + if (is_array($uri)) + { + $i = 0; + $str = ''; + foreach ($uri as $key => $val) + { + $prefix = ($i == 0) ? '' : '&'; + $str .= $prefix.$key.'='.$val; + $i++; + } + + $uri = $str; + } + + return $this->slash_item('base_url').$this->item('index_page').'?'.$uri; } } - + // -------------------------------------------------------------------- /** @@ -220,7 +266,7 @@ class CI_Config { $x = explode("/", preg_replace("|/*(.+?)/*$|", "\\1", BASEPATH)); return $this->slash_item('base_url').end($x).'/'; } - + // -------------------------------------------------------------------- /** @@ -236,9 +282,32 @@ class CI_Config { $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/libraries/Config.php */
\ No newline at end of file +/* Location: ./system/core/Config.php */
\ No newline at end of file diff --git a/system/core/Controller.php b/system/core/Controller.php new file mode 100755 index 000000000..469663f09 --- /dev/null +++ b/system/core/Controller.php @@ -0,0 +1,67 @@ +<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); +/** + * CodeIgniter + * + * An open source application development framework for PHP 5.1.6 or newer + * + * @package CodeIgniter + * @author ExpressionEngine Dev Team + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. + * @license http://codeigniter.com/user_guide/license.html + * @link http://codeigniter.com + * @since Version 1.0 + * @filesource + */ + +// ------------------------------------------------------------------------ + +/** + * CodeIgniter Application Controller Class + * + * This class object is the super class that every library in + * CodeIgniter will be assigned to. + * + * @package CodeIgniter + * @subpackage Libraries + * @category Libraries + * @author ExpressionEngine Dev Team + * @link http://codeigniter.com/user_guide/general/controllers.html + */ +class CI_Controller { + + private static $instance; + + /** + * Constructor + */ + public function __construct() + { + self::$instance =& $this; + + // Assign all the class objects that were instantiated by the + // bootstrap file (CodeIgniter.php) to local class variables + // so that CI can run as one big super object. + foreach (is_loaded() as $var => $class) + { + $this->$var =& load_class($class); + } + + $this->load =& load_class('Loader', 'core'); + + $this->load->_base_classes =& is_loaded(); + + $this->load->_ci_autoloader(); + + log_message('debug', "Controller Class Initialized"); + + } + + public static function &get_instance() + { + return self::$instance; + } +} +// END Controller class + +/* End of file Controller.php */ +/* Location: ./system/core/Controller.php */
\ No newline at end of file diff --git a/system/libraries/Exceptions.php b/system/core/Exceptions.php index bd567ccdc..f5659561c 100644..100755 --- a/system/libraries/Exceptions.php +++ b/system/core/Exceptions.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -50,14 +50,13 @@ class CI_Exceptions { /** * Constructor - * - */ - function CI_Exceptions() + */ + public function __construct() { $this->ob_level = ob_get_level(); // Note: Do not log messages from this constructor. } - + // -------------------------------------------------------------------- /** @@ -73,9 +72,9 @@ class CI_Exceptions { * @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); } @@ -88,16 +87,21 @@ class CI_Exceptions { * @param string * @return string */ - function show_404($page = '') - { + function show_404($page = '', $log_error = TRUE) + { $heading = "404 Page Not Found"; $message = "The page you requested was not found."; - log_message('error', '404 Page Not Found --> '.$page); + // 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; } - + // -------------------------------------------------------------------- /** @@ -116,12 +120,12 @@ class CI_Exceptions { 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_end_flush(); } ob_start(); include(APPPATH.'errors/'.$template.EXT); @@ -143,21 +147,21 @@ class CI_Exceptions { * @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_end_flush(); } ob_start(); include(APPPATH.'errors/error_php'.EXT); @@ -171,4 +175,4 @@ class CI_Exceptions { // END Exceptions Class /* End of file Exceptions.php */ -/* Location: ./system/libraries/Exceptions.php */
\ No newline at end of file +/* Location: ./system/core/Exceptions.php */
\ No newline at end of file diff --git a/system/libraries/Hooks.php b/system/core/Hooks.php index 6d736c3f6..75fd811b0 100644..100755 --- a/system/libraries/Hooks.php +++ b/system/core/Hooks.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -18,8 +18,7 @@ /** * CodeIgniter Hooks Class * - * Provides a mechanism to extend the base system without hacking. Most of - * this class is borrowed from Paul's Extension class in ExpressionEngine. + * Provides a mechanism to extend the base system without hacking. * * @package CodeIgniter * @subpackage Libraries @@ -29,20 +28,20 @@ */ class CI_Hooks { - var $enabled = FALSE; - var $hooks = array(); + var $enabled = FALSE; + var $hooks = array(); var $in_progress = FALSE; /** * Constructor * */ - function CI_Hooks() + function __construct() { $this->_initialize(); log_message('debug', "Hooks Class Initialized"); } - + // -------------------------------------------------------------------- /** @@ -50,10 +49,10 @@ class CI_Hooks { * * @access private * @return void - */ - function _initialize() - { - $CFG =& load_class('Config'); + */ + function _initialize() + { + $CFG =& load_class('Config', 'core'); // If hooks are not enabled in the config file // there is nothing else to do @@ -75,8 +74,8 @@ class CI_Hooks { $this->hooks =& $hook; $this->enabled = TRUE; - } - + } + // -------------------------------------------------------------------- /** @@ -223,4 +222,4 @@ class CI_Hooks { // END CI_Hooks class /* End of file Hooks.php */ -/* Location: ./system/libraries/Hooks.php */
\ No newline at end of file +/* Location: ./system/core/Hooks.php */
\ No newline at end of file diff --git a/system/core/Input.php b/system/core/Input.php new file mode 100755 index 000000000..3e82874fd --- /dev/null +++ b/system/core/Input.php @@ -0,0 +1,652 @@ +<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); +/** + * CodeIgniter + * + * An open source application development framework for PHP 5.1.6 or newer + * + * @package CodeIgniter + * @author ExpressionEngine Dev Team + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. + * @license http://codeigniter.com/user_guide/license.html + * @link http://codeigniter.com + * @since Version 1.0 + * @filesource + */ + +// ------------------------------------------------------------------------ + +/** + * Input Class + * + * Pre-processes global input data for security + * + * @package CodeIgniter + * @subpackage Libraries + * @category Input + * @author ExpressionEngine Dev Team + * @link http://codeigniter.com/user_guide/libraries/input.html + */ +class CI_Input { + + var $ip_address = FALSE; + var $user_agent = FALSE; + var $_allow_get_array = TRUE; + var $_standardize_newlines = TRUE; + var $_enable_xss = FALSE; // Set automatically based on config setting + var $_enable_csrf = FALSE; // Set automatically based on config setting + + protected $headers = array(); + + + /** + * Constructor + * + * Sets whether to globally enable the XSS processing + * and whether to allow the $_GET array + * + */ + public function __construct() + { + log_message('debug', "Input Class Initialized"); + + $this->_allow_get_array = (config_item('allow_get_array') === TRUE); + $this->_enable_xss = (config_item('global_xss_filtering') === TRUE); + $this->_enable_csrf = (config_item('csrf_protection') === TRUE); + + // Do we need to load the security class? + if ($this->_enable_xss == TRUE OR $this->_enable_csrf == TRUE) + { + $this->security =& load_class('Security'); + } + + // Do we need the UTF-8 class? + if (UTF8_ENABLED === TRUE) + { + global $UNI; + $this->uni =& $UNI; + } + + // Sanitize global arrays + $this->_sanitize_globals(); + } + + // -------------------------------------------------------------------- + + /** + * Fetch from array + * + * This is a helper function to retrieve values from global arrays + * + * @access private + * @param array + * @param string + * @param bool + * @return string + */ + function _fetch_from_array(&$array, $index = '', $xss_clean = FALSE) + { + if ( ! isset($array[$index])) + { + return FALSE; + } + + if ($xss_clean === TRUE) + { + $_security =& load_class('Security'); + return $_security->xss_clean($array[$index]); + } + + return $array[$index]; + } + + // -------------------------------------------------------------------- + + /** + * Fetch an item from the GET array + * + * @access public + * @param string + * @param bool + * @return string + */ + function get($index = '', $xss_clean = FALSE) + { + 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 = '', $xss_clean = FALSE) + { + 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 + * @return void + */ + function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '') + { + if (is_array($name)) + { + foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'name') as $item) + { + if (isset($name[$item])) + { + $$item = $name[$item]; + } + } + } + + 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 ( ! is_numeric($expire)) + { + $expire = time() - 86500; + } + else + { + $expire = ($expire > 0) ? time() + $expire : 0; + } + + setcookie($prefix.$name, $value, $expire, $path, $domain, 0); + } + + // -------------------------------------------------------------------- + + /** + * Fetch an item from the SERVER array + * + * @access public + * @param string + * @param bool + * @return string + */ + function server($index = '', $xss_clean = FALSE) + { + return $this->_fetch_from_array($_SERVER, $index, $xss_clean); + } + + // -------------------------------------------------------------------- + + /** + * Fetch the IP Address + * + * @access public + * @return string + */ + function ip_address() + { + if ($this->ip_address !== FALSE) + { + return $this->ip_address; + } + + if (config_item('proxy_ips') != '' && $this->server('HTTP_X_FORWARDED_FOR') && $this->server('REMOTE_ADDR')) + { + $proxies = preg_split('/[\s,]/', config_item('proxy_ips'), -1, PREG_SPLIT_NO_EMPTY); + $proxies = is_array($proxies) ? $proxies : array($proxies); + + $this->ip_address = in_array($_SERVER['REMOTE_ADDR'], $proxies) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; + } + elseif ($this->server('REMOTE_ADDR') AND $this->server('HTTP_CLIENT_IP')) + { + $this->ip_address = $_SERVER['HTTP_CLIENT_IP']; + } + elseif ($this->server('REMOTE_ADDR')) + { + $this->ip_address = $_SERVER['REMOTE_ADDR']; + } + elseif ($this->server('HTTP_CLIENT_IP')) + { + $this->ip_address = $_SERVER['HTTP_CLIENT_IP']; + } + elseif ($this->server('HTTP_X_FORWARDED_FOR')) + { + $this->ip_address = $_SERVER['HTTP_X_FORWARDED_FOR']; + } + + if ($this->ip_address === FALSE) + { + $this->ip_address = '0.0.0.0'; + return $this->ip_address; + } + + if (strpos($this->ip_address, ',') !== FALSE) + { + $x = explode(',', $this->ip_address); + $this->ip_address = trim(end($x)); + } + + if ( ! $this->valid_ip($this->ip_address)) + { + $this->ip_address = '0.0.0.0'; + } + + return $this->ip_address; + } + + // -------------------------------------------------------------------- + + /** + * Validate IP Address + * + * Updated version suggested by Geert De Deckere + * + * @access public + * @param string + * @return string + */ + function valid_ip($ip) + { + $ip_segments = explode('.', $ip); + + // Always 4 segments needed + if (count($ip_segments) != 4) + { + return FALSE; + } + // IP can not start with 0 + if ($ip_segments[0][0] == '0') + { + return FALSE; + } + // Check each segment + foreach ($ip_segments as $segment) + { + // IP segments must be digits and can not be + // longer than 3 digits or greater then 255 + if ($segment == '' OR preg_match("/[^0-9]/", $segment) OR $segment > 255 OR strlen($segment) > 3) + { + return FALSE; + } + } + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * User Agent + * + * @access public + * @return string + */ + function user_agent() + { + if ($this->user_agent !== FALSE) + { + return $this->user_agent; + } + + $this->user_agent = ( ! isset($_SERVER['HTTP_USER_AGENT'])) ? FALSE : $_SERVER['HTTP_USER_AGENT']; + + return $this->user_agent; + } + + // -------------------------------------------------------------------- + + /** + * Sanitize Globals + * + * This function does the following: + * + * Unsets $_GET data (if query strings are not enabled) + * + * Unsets all globals if register_globals is enabled + * + * Standardizes newline characters to \n + * + * @access private + * @return void + */ + function _sanitize_globals() + { + // It would be "wrong" to unset any of these GLOBALS. + $protected = array('_SERVER', '_GET', '_POST', '_FILES', '_REQUEST', + '_SESSION', '_ENV', 'GLOBALS', 'HTTP_RAW_POST_DATA', + 'system_folder', 'application_folder', 'BM', 'EXT', + 'CFG', 'URI', 'RTR', 'OUT', 'IN'); + + // Unset globals for securiy. + // This is effectively the same as register_globals = off + foreach (array($_GET, $_POST, $_COOKIE) as $global) + { + if ( ! is_array($global)) + { + if ( ! in_array($global, $protected)) + { + global $$global; + $$global = NULL; + } + } + else + { + foreach ($global as $key => $val) + { + if ( ! in_array($key, $protected)) + { + global $$key; + $$key = NULL; + } + } + } + } + + // Is $_GET data allowed? If not we'll set the $_GET to an empty array + if ($this->_allow_get_array == FALSE) + { + $_GET = array(); + } + else + { + if (is_array($_GET) AND count($_GET) > 0) + { + foreach($_GET as $key => $val) + { + $_GET[$this->_clean_input_keys($key)] = $this->_clean_input_data($val); + } + } + } + + // Clean $_POST Data + if (is_array($_POST) AND count($_POST) > 0) + { + foreach($_POST as $key => $val) + { + $_POST[$this->_clean_input_keys($key)] = $this->_clean_input_data($val); + } + } + + // Clean $_COOKIE Data + if (is_array($_COOKIE) AND count($_COOKIE) > 0) + { + // Also get rid of specially treated cookies that might be set by a server + // or silly application, that are of no use to a CI application anyway + // but that when present will trip our 'Disallowed Key Characters' alarm + // http://www.ietf.org/rfc/rfc2109.txt + // note that the key names below are single quoted strings, and are not PHP variables + unset($_COOKIE['$Version']); + unset($_COOKIE['$Path']); + unset($_COOKIE['$Domain']); + + foreach($_COOKIE as $key => $val) + { + $_COOKIE[$this->_clean_input_keys($key)] = $this->_clean_input_data($val); + } + } + + // Sanitize PHP_SELF + $_SERVER['PHP_SELF'] = strip_tags($_SERVER['PHP_SELF']); + + + // CSRF Protection check + if ($this->_enable_csrf == TRUE) + { + $this->security->csrf_verify(); + } + + log_message('debug', "Global POST and COOKIE data sanitized"); + } + + // -------------------------------------------------------------------- + + /** + * Clean Input Data + * + * This is a helper function. It escapes data and + * standardizes newline characters to \n + * + * @access private + * @param string + * @return string + */ + function _clean_input_data($str) + { + if (is_array($str)) + { + $new_array = array(); + foreach ($str as $key => $val) + { + $new_array[$this->_clean_input_keys($key)] = $this->_clean_input_data($val); + } + return $new_array; + } + + // We strip slashes if magic quotes is on to keep things consistent + if (function_exists('get_magic_quotes_gpc') AND get_magic_quotes_gpc()) + { + $str = stripslashes($str); + } + + // Clean UTF-8 if supported + if (UTF8_ENABLED === TRUE) + { + $str = $this->uni->clean_string($str); + } + + // Should we filter the input data? + if ($this->_enable_xss === TRUE) + { + $str = $this->security->xss_clean($str); + } + + // Standardize newlines if needed + if ($this->_standardize_newlines == TRUE) + { + if (strpos($str, "\r") !== FALSE) + { + $str = str_replace(array("\r\n", "\r"), PHP_EOL, $str); + } + } + + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Clean Keys + * + * This is a helper function. To prevent malicious users + * from trying to exploit keys we make sure that keys are + * only named with alpha-numeric text and a few other items. + * + * @access private + * @param string + * @return string + */ + function _clean_input_keys($str) + { + if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str)) + { + exit('Disallowed Key Characters.'); + } + + // Clean UTF-8 if supported + if (UTF8_ENABLED === TRUE) + { + $str = $this->uni->clean_string($str); + } + + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Request Headers + * + * In Apache, you can simply call apache_request_headers(), however for + * people running other webservers the function is undefined. + * + * @return array + */ + public function request_headers($xss_clean = FALSE) + { + // Look at Apache go! + if (function_exists('apache_request_headers')) + { + $headers = apache_request_headers(); + } + else + { + $headers['Content-Type'] = (isset($_SERVER['CONTENT_TYPE'])) ? $_SERVER['CONTENT_TYPE'] : @getenv('CONTENT_TYPE'); + + foreach ($_SERVER as $key => $val) + { + if (strncmp($key, 'HTTP_', 5) === 0) + { + $headers[substr($key, 5)] = $this->_fetch_from_array($_SERVER, $key, $xss_clean); + } + } + } + + // take SOME_HEADER and turn it into Some-Header + foreach ($headers as $key => $val) + { + $key = str_replace('_', ' ', strtolower($key)); + $key = str_replace(' ', '-', ucwords($key)); + + $this->headers[$key] = $val; + } + + return $this->headers; + } + + // -------------------------------------------------------------------- + + /** + * Get Request Header + * + * Returns the value of a single member of the headers class member + * + * @param string array key for $this->headers + * @param boolean XSS Clean or not + * @return mixed FALSE on failure, string on success + */ + public function get_request_header($index, $xss_clean = FALSE) + { + if (empty($this->headers)) + { + $this->request_headers(); + } + + if ( ! isset($this->headers[$index])) + { + return FALSE; + } + + if ($xss_clean === TRUE) + { + $_security =& load_class('Security'); + return $_security->xss_clean($this->headers[$index]); + } + + return $this->headers[$index]; + } + + // -------------------------------------------------------------------- + + /** + * Is ajax Request? + * + * Test to see if a request contains the HTTP_X_REQUESTED_WITH header + * + * @return boolean + */ + public function is_ajax_request() + { + return ($this->server('HTTP_X_REQUESTED_WITH') === 'XMLHttpRequest'); + } + + // -------------------------------------------------------------------- + + /** + * Is cli Request? + * + * Test to see if a request was made from the command line + * + * @return boolean + */ + public function is_cli_request() + { + return (bool) defined('STDIN'); + } + +} +// END Input class + +/* End of file Input.php */ +/* Location: ./system/core/Input.php */
\ No newline at end of file diff --git a/system/libraries/Language.php b/system/core/Lang.php index 515d04a40..fb177902e 100644..100755 --- a/system/libraries/Language.php +++ b/system/core/Lang.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -24,7 +24,7 @@ * @author ExpressionEngine Dev Team * @link http://codeigniter.com/user_guide/libraries/language.html */ -class CI_Language { +class CI_Lang { var $language = array(); var $is_loaded = array(); @@ -34,7 +34,7 @@ class CI_Language { * * @access public */ - function CI_Language() + function __construct() { log_message('debug', "Language Class Initialized"); } @@ -49,39 +49,56 @@ class CI_Language { * @param string the language (english, etc.) * @return mixed */ - function load($langfile = '', $idiom = '', $return = FALSE) + function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '') { - $langfile = str_replace(EXT, '', str_replace('_lang.', '', $langfile)).'_lang'.EXT; + $langfile = str_replace(EXT, '', $langfile); + + if ($add_suffix == TRUE) + { + $langfile = str_replace('_lang.', '', $langfile).'_lang'; + } + + $langfile .= EXT; if (in_array($langfile, $this->is_loaded, TRUE)) { return; } + $config =& get_config(); + if ($idiom == '') { - $CI =& get_instance(); - $deft_lang = $CI->config->item('language'); + $deft_lang = ( ! isset($config['language'])) ? 'english' : $config['language']; $idiom = ($deft_lang == '') ? 'english' : $deft_lang; } // Determine where the language file is and load it - if (file_exists(APPPATH.'language/'.$idiom.'/'.$langfile)) + if ($alt_path != '' && file_exists($alt_path.'language/'.$idiom.'/'.$langfile)) { - include(APPPATH.'language/'.$idiom.'/'.$langfile); + include($alt_path.'language/'.$idiom.'/'.$langfile); } else { - if (file_exists(BASEPATH.'language/'.$idiom.'/'.$langfile)) + $found = FALSE; + + foreach (get_instance()->load->get_package_paths(TRUE) as $package_path) { - include(BASEPATH.'language/'.$idiom.'/'.$langfile); + if (file_exists($package_path.'language/'.$idiom.'/'.$langfile)) + { + include($package_path.'language/'.$idiom.'/'.$langfile); + $found = TRUE; + break; + } } - else + + 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); @@ -107,7 +124,7 @@ class CI_Language { * Fetch a single line of text from the language array * * @access public - * @param string $line the language line + * @param string $line the language line * @return string */ function line($line = '') @@ -119,5 +136,5 @@ class CI_Language { } // END Language Class -/* End of file Language.php */ -/* Location: ./system/libraries/Language.php */
\ No newline at end of file +/* End of file Lang.php */ +/* Location: ./system/core/Lang.php */
\ No newline at end of file diff --git a/system/libraries/Loader.php b/system/core/Loader.php index 4a03312c4..07166188e 100644..100755 --- a/system/libraries/Loader.php +++ b/system/core/Loader.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -31,16 +31,17 @@ class CI_Loader { // All these are set automatically. Don't mess with them. var $_ci_ob_level; var $_ci_view_path = ''; - var $_ci_is_php5 = FALSE; - var $_ci_is_instance = FALSE; // Whether we should use $this or $CI =& get_instance() + var $_ci_library_paths = array(); + var $_ci_model_paths = array(); + var $_ci_helper_paths = array(); + var $_base_classes = array(); // Set by the controller class var $_ci_cached_vars = array(); var $_ci_classes = array(); var $_ci_loaded_files = array(); var $_ci_models = array(); var $_ci_helpers = array(); - var $_ci_plugins = array(); var $_ci_varmap = array('unit_test' => 'unit', 'user_agent' => 'agent'); - + /** * Constructor @@ -49,17 +50,19 @@ class CI_Loader { * * @access public */ - function CI_Loader() - { - $this->_ci_is_php5 = (floor(phpversion()) >= 5) ? TRUE : FALSE; + function __construct() + { $this->_ci_view_path = APPPATH.'views/'; $this->_ci_ob_level = ob_get_level(); - + $this->_ci_library_paths = array(APPPATH, BASEPATH); + $this->_ci_helper_paths = array(APPPATH, BASEPATH); + $this->_ci_model_paths = array(APPPATH); + log_message('debug', "Loader Class Initialized"); } - + // -------------------------------------------------------------------- - + /** * Class Loader * @@ -71,15 +74,25 @@ class CI_Loader { * @param mixed the optional parameters * @param string an optional object name * @return void - */ + */ function library($library = '', $params = NULL, $object_name = NULL) { - if ($library == '') + if (is_array($library)) + { + foreach($library as $read) + { + $this->library($read); + } + + return; + } + + if ($library == '' OR isset($this->_base_classes[$library])) { return FALSE; } - if ( ! is_null($params) AND ! is_array($params)) + if ( ! is_null($params) && ! is_array($params)) { $params = NULL; } @@ -95,12 +108,10 @@ class CI_Loader { { $this->_ci_load_class($library, $params, $object_name); } - - $this->_ci_assign_to_models(); } // -------------------------------------------------------------------- - + /** * Model Loader * @@ -111,14 +122,14 @@ class CI_Loader { * @param string name for the model * @param bool database connection * @return void - */ + */ function model($model, $name = '', $db_conn = FALSE) - { + { if (is_array($model)) { foreach($model as $babe) { - $this->model($babe); + $this->model($babe); } return; } @@ -127,68 +138,75 @@ class CI_Loader { { return; } - + + $path = ''; + // Is the model in a sub-folder? If so, parse out the filename and path. - if (strpos($model, '/') === FALSE) + if (($last_slash = strrpos($model, '/')) !== FALSE) { - $path = ''; - } - else - { - $x = explode('/', $model); - $model = end($x); - unset($x[count($x)-1]); - $path = implode('/', $x).'/'; + // The path is in front of the last slash + $path = substr($model, 0, $last_slash + 1); + + // And the model name behind it + $model = substr($model, $last_slash + 1); } - + if ($name == '') { $name = $model; } - + if (in_array($name, $this->_ci_models, TRUE)) { return; } - + $CI =& get_instance(); if (isset($CI->$name)) { show_error('The model name you are loading is the name of a resource that is already being used: '.$name); } - + $model = strtolower($model); - - if ( ! file_exists(APPPATH.'models/'.$path.$model.EXT)) - { - show_error('Unable to locate the model you have specified: '.$model); - } - - if ($db_conn !== FALSE AND ! class_exists('CI_DB')) - { - if ($db_conn === TRUE) - $db_conn = ''; - - $CI->load->database($db_conn, FALSE, TRUE); - } - - if ( ! class_exists('Model')) + + foreach ($this->_ci_model_paths as $mod_path) { - load_class('Model', FALSE); - } + if ( ! file_exists($mod_path.'models/'.$path.$model.EXT)) + { + continue; + } - require_once(APPPATH.'models/'.$path.$model.EXT); + if ($db_conn !== FALSE AND ! class_exists('CI_DB')) + { + if ($db_conn === TRUE) + { + $db_conn = ''; + } + + $CI->load->database($db_conn, FALSE, TRUE); + } + + if ( ! class_exists('CI_Model')) + { + load_class('Model', 'core'); + } + + require_once($mod_path.'models/'.$path.$model.EXT); + + $model = ucfirst($model); - $model = ucfirst($model); - - $CI->$name = new $model(); - $CI->$name->_assign_libraries(); - - $this->_ci_models[] = $name; + $CI->$name = new $model(); + + $this->_ci_models[] = $name; + return; + } + + // couldn't find the model + show_error('Unable to locate the model you have specified: '.$model); } - + // -------------------------------------------------------------------- - + /** * Database Loader * @@ -197,94 +215,87 @@ class CI_Loader { * @param bool whether to return the DB object * @param bool whether to enable active record (this allows us to override the config setting) * @return object - */ - function database($params = '', $return = FALSE, $active_record = FALSE) + */ + function database($params = '', $return = FALSE, $active_record = NULL) { // Grab the super object $CI =& get_instance(); - + // Do we even need to load the database class? - if (class_exists('CI_DB') AND $return == FALSE AND $active_record == FALSE AND isset($CI->db) AND is_object($CI->db)) + if (class_exists('CI_DB') AND $return == FALSE AND $active_record == NULL AND isset($CI->db) AND is_object($CI->db)) { return FALSE; - } - + } + require_once(BASEPATH.'database/DB'.EXT); if ($return === TRUE) { return DB($params, $active_record); } - - // Initialize the db variable. Needed to prevent + + // Initialize the db variable. Needed to prevent // reference errors with some configurations $CI->db = ''; - + // Load the DB class - $CI->db =& DB($params, $active_record); - - // Assign the DB object to any existing models - $this->_ci_assign_to_models(); + $CI->db =& DB($params, $active_record); } - + // -------------------------------------------------------------------- /** * Load the Utilities Class * * @access public - * @return string - */ + * @return string + */ function dbutil() { if ( ! class_exists('CI_DB')) { $this->database(); } - + $CI =& get_instance(); // for backwards compatibility, load dbforge so we can extend dbutils off it // this use is deprecated and strongly discouraged $CI->load->dbforge(); - + require_once(BASEPATH.'database/DB_utility'.EXT); require_once(BASEPATH.'database/drivers/'.$CI->db->dbdriver.'/'.$CI->db->dbdriver.'_utility'.EXT); $class = 'CI_DB_'.$CI->db->dbdriver.'_utility'; - $CI->dbutil =& instantiate_class(new $class()); - - $CI->load->_ci_assign_to_models(); + $CI->dbutil = new $class(); } - + // -------------------------------------------------------------------- /** * Load the Database Forge Class * * @access public - * @return string - */ + * @return string + */ function dbforge() { if ( ! class_exists('CI_DB')) { $this->database(); } - + $CI =& get_instance(); - + require_once(BASEPATH.'database/DB_forge'.EXT); require_once(BASEPATH.'database/drivers/'.$CI->db->dbdriver.'/'.$CI->db->dbdriver.'_forge'.EXT); $class = 'CI_DB_'.$CI->db->dbdriver.'_forge'; $CI->dbforge = new $class(); - - $CI->load->_ci_assign_to_models(); } - + // -------------------------------------------------------------------- - + /** * Load View * @@ -306,9 +317,9 @@ class CI_Loader { { return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return)); } - + // -------------------------------------------------------------------- - + /** * Load File * @@ -323,9 +334,9 @@ class CI_Loader { { return $this->_ci_load(array('_ci_path' => $path, '_ci_return' => $return)); } - + // -------------------------------------------------------------------- - + /** * Set Variables * @@ -342,9 +353,9 @@ class CI_Loader { { $vars = array($vars => $val); } - + $vars = $this->_ci_object_to_array($vars); - + if (is_array($vars) AND count($vars) > 0) { foreach ($vars as $key => $val) @@ -353,9 +364,9 @@ class CI_Loader { } } } - + // -------------------------------------------------------------------- - + /** * Load Helper * @@ -367,58 +378,56 @@ class CI_Loader { */ function helper($helpers = array()) { - if ( ! is_array($helpers)) + foreach ($this->_ci_prep_filename($helpers, '_helper') as $helper) { - $helpers = array($helpers); - } - - foreach ($helpers as $helper) - { - $helper = strtolower(str_replace(EXT, '', str_replace('_helper', '', $helper)).'_helper'); - if (isset($this->_ci_helpers[$helper])) { continue; } - + $ext_helper = APPPATH.'helpers/'.config_item('subclass_prefix').$helper.EXT; - // Is this a helper extension request? + // Is this a helper extension request? if (file_exists($ext_helper)) { $base_helper = BASEPATH.'helpers/'.$helper.EXT; - + if ( ! file_exists($base_helper)) { show_error('Unable to load the requested file: helpers/'.$helper.EXT); } - + include_once($ext_helper); include_once($base_helper); + + $this->_ci_helpers[$helper] = TRUE; + log_message('debug', 'Helper loaded: '.$helper); + continue; } - elseif (file_exists(APPPATH.'helpers/'.$helper.EXT)) - { - include_once(APPPATH.'helpers/'.$helper.EXT); - } - else - { - if (file_exists(BASEPATH.'helpers/'.$helper.EXT)) - { - include_once(BASEPATH.'helpers/'.$helper.EXT); - } - else + + // Try to load the helper + foreach ($this->_ci_helper_paths as $path) + { + if (file_exists($path.'helpers/'.$helper.EXT)) { - show_error('Unable to load the requested file: helpers/'.$helper.EXT); + include_once($path.'helpers/'.$helper.EXT); + + $this->_ci_helpers[$helper] = TRUE; + log_message('debug', 'Helper loaded: '.$helper); + break; } } - $this->_ci_helpers[$helper] = TRUE; - log_message('debug', 'Helper loaded: '.$helper); - } + // unable to load the helper + if ( ! isset($this->_ci_helpers[$helper])) + { + show_error('Unable to load the requested file: helpers/'.$helper.EXT); + } + } } - + // -------------------------------------------------------------------- - + /** * Load Helpers * @@ -433,156 +442,167 @@ class CI_Loader { { $this->helper($helpers); } - + // -------------------------------------------------------------------- - + /** - * Load Plugin - * - * This function loads the specified plugin. + * Loads a language file * * @access public * @param array + * @param string * @return void */ - function plugin($plugins = array()) + function language($file = array(), $lang = '') { - if ( ! is_array($plugins)) + $CI =& get_instance(); + + if ( ! is_array($file)) { - $plugins = array($plugins); + $file = array($file); } - - foreach ($plugins as $plugin) - { - $plugin = strtolower(str_replace(EXT, '', str_replace('_pi', '', $plugin)).'_pi'); - if (isset($this->_ci_plugins[$plugin])) - { - continue; - } - - if (file_exists(APPPATH.'plugins/'.$plugin.EXT)) - { - include_once(APPPATH.'plugins/'.$plugin.EXT); - } - else - { - if (file_exists(BASEPATH.'plugins/'.$plugin.EXT)) - { - include_once(BASEPATH.'plugins/'.$plugin.EXT); - } - else - { - show_error('Unable to load the requested file: plugins/'.$plugin.EXT); - } - } - - $this->_ci_plugins[$plugin] = TRUE; - log_message('debug', 'Plugin loaded: '.$plugin); - } + foreach ($file as $langfile) + { + $CI->lang->load($langfile, $lang); + } } // -------------------------------------------------------------------- - + /** - * Load Plugins - * - * This is simply an alias to the above function in case the - * user has written the plural form of this function. + * Loads a config file * * @access public - * @param array + * @param string * @return void */ - function plugins($plugins = array()) + function config($file = '', $use_sections = FALSE, $fail_gracefully = FALSE) { - $this->plugin($plugins); + $CI =& get_instance(); + $CI->config->load($file, $use_sections, $fail_gracefully); } - + // -------------------------------------------------------------------- - + /** - * Loads a language file + * Driver * - * @access public - * @param array - * @param string + * Loads a driver library + * + * @param string the name of the class + * @param mixed the optional parameters + * @param string an optional object name * @return void */ - function language($file = array(), $lang = '') + function driver($library = '', $params = NULL, $object_name = NULL) { - $CI =& get_instance(); - - if ( ! is_array($file)) + if ( ! class_exists('CI_Driver_Library')) { - $file = array($file); + // we aren't instantiating an object here, that'll be done by the Library itself + require BASEPATH.'libraries/Driver'.EXT; } - foreach ($file as $langfile) - { - $CI->lang->load($langfile, $lang); + // We can save the loader some time since Drivers will *always* be in a subfolder, + // and typically identically named to the library + if ( ! strpos($library, '/')) + { + $library = ucfirst($library).'/'.$library; } + + return $this->library($library, $params, $object_name); } + // -------------------------------------------------------------------- + /** - * Loads language files for scaffolding + * Add Package Path + * + * Prepends a parent path to the library, model, helper, and config path arrays * * @access public * @param string - * @return arra + * @return void */ - function scaffold_language($file = '', $lang = '', $return = FALSE) + function add_package_path($path) { - $CI =& get_instance(); - return $CI->lang->load($file, $lang, $return); + $path = rtrim($path, '/').'/'; + + array_unshift($this->_ci_library_paths, $path); + array_unshift($this->_ci_model_paths, $path); + array_unshift($this->_ci_helper_paths, $path); + + // Add config file path + $config =& $this->_ci_get_component('config'); + array_unshift($config->_config_paths, $path); } - + // -------------------------------------------------------------------- - + /** - * Loads a config file + * Get Package Paths + * + * Return a list of all package paths, by default it will ignore BASEPATH. * * @access public * @param string * @return void */ - function config($file = '', $use_sections = FALSE, $fail_gracefully = FALSE) - { - $CI =& get_instance(); - $CI->config->load($file, $use_sections, $fail_gracefully); + function get_package_paths($include_base = FALSE) + { + return $include_base === TRUE ? $this->_ci_library_paths : $this->_ci_model_paths; } // -------------------------------------------------------------------- - + /** - * Scaffolding Loader + * Remove Package Path * - * This initializing function works a bit different than the - * others. It doesn't load the class. Instead, it simply - * sets a flag indicating that scaffolding is allowed to be - * used. The actual scaffolding function below is - * called by the front controller based on whether the - * second segment of the URL matches the "secret" scaffolding - * word stored in the application/config/routes.php + * Remove a path from the library, model, and helper path arrays if it exists + * If no path is provided, the most recently added path is removed. * * @access public - * @param string - * @return void - */ - function scaffolding($table = '') - { - if ($table === FALSE) + * @param type + * @return type + */ + function remove_package_path($path = '', $remove_config_path = TRUE) + { + $config =& $this->_ci_get_component('config'); + + if ($path == '') { - show_error('You must include the name of the table you would like to access when you initialize scaffolding'); + $void = array_shift($this->_ci_library_paths); + $void = array_shift($this->_ci_model_paths); + $void = array_shift($this->_ci_helper_paths); + $void = array_shift($config->_config_paths); } - - $CI =& get_instance(); - $CI->_ci_scaffolding = TRUE; - $CI->_ci_scaff_table = $table; + else + { + $path = rtrim($path, '/').'/'; + + foreach (array('_ci_library_paths', '_ci_model_paths', '_ci_helper_paths') as $var) + { + if (($key = array_search($path, $this->{$var})) !== FALSE) + { + unset($this->{$var}[$key]); + } + } + + if (($key = array_search($path, $config->_config_paths)) !== FALSE) + { + unset($config->_config_paths[$key]); + } + } + + // make sure the application default paths are still in the array + $this->_ci_library_paths = array_unique(array_merge($this->_ci_library_paths, array(APPPATH, BASEPATH))); + $this->_ci_helper_paths = array_unique(array_merge($this->_ci_helper_paths, array(APPPATH, BASEPATH))); + $this->_ci_model_paths = array_unique(array_merge($this->_ci_model_paths, array(APPPATH))); + $config->_config_paths = array_unique(array_merge($config->_config_paths, array(APPPATH))); } // -------------------------------------------------------------------- - + /** * Loader * @@ -614,25 +634,21 @@ class CI_Loader { $_ci_x = explode('/', $_ci_path); $_ci_file = end($_ci_x); } - + if ( ! file_exists($_ci_path)) { show_error('Unable to load the requested file: '.$_ci_file); } - + // This allows anything loaded using $this->load (views, files, etc.) // to become accessible from within the Controller and Model functions. - // Only needed when running PHP 5 - - if ($this->_ci_is_instance()) + + $_ci_CI =& get_instance(); + foreach (get_object_vars($_ci_CI) as $_ci_key => $_ci_var) { - $_ci_CI =& get_instance(); - foreach (get_object_vars($_ci_CI) as $_ci_key => $_ci_var) + if ( ! isset($this->$_ci_key)) { - if ( ! isset($this->$_ci_key)) - { - $this->$_ci_key =& $_ci_CI->$_ci_key; - } + $this->$_ci_key =& $_ci_CI->$_ci_key; } } @@ -643,13 +659,13 @@ class CI_Loader { * function or via the second parameter of this function. We'll merge * the two types and cache them so that views that are embedded within * other views can have access to these variables. - */ + */ if (is_array($_ci_vars)) { $this->_ci_cached_vars = array_merge($this->_ci_cached_vars, $_ci_vars); } extract($this->_ci_cached_vars); - + /* * Buffer the output * @@ -663,11 +679,11 @@ class CI_Loader { * the browser and then stop the timer it won't be accurate. */ ob_start(); - + // If the PHP installation does not support short tags we'll // do a little string replacement, changing the short tags // to standard PHP echo statements. - + if ((bool) @ini_get('short_open_tag') === FALSE AND config_item('rewrite_short_tags') == TRUE) { echo eval('?>'.preg_replace("/;*\s*\?>/", "; ?>", str_replace('<?=', '<?php echo ', file_get_contents($_ci_path)))); @@ -676,12 +692,12 @@ class CI_Loader { { include($_ci_path); // include() vs include_once() allows for multiple views with the same name } - + log_message('debug', 'File loaded: '.$_ci_path); - + // Return the file data if requested if ($_ci_return === TRUE) - { + { $buffer = ob_get_contents(); @ob_end_clean(); return $buffer; @@ -696,16 +712,14 @@ class CI_Loader { * it can be seen and included properly by the first included * template and any subsequent ones. Oy! * - */ + */ if (ob_get_level() > $this->_ci_ob_level + 1) { ob_end_flush(); } else { - // PHP 4 requires that we use a global - global $OUT; - $OUT->append_output(ob_get_contents()); + $_ci_CI->output->append_output(ob_get_contents()); @ob_end_clean(); } } @@ -718,34 +732,28 @@ class CI_Loader { * This function loads the requested class. * * @access private - * @param string the item that is being loaded + * @param string the item that is being loaded * @param mixed any additional parameters * @param string an optional object name - * @return void + * @return void */ function _ci_load_class($class, $params = NULL, $object_name = NULL) - { - // Get the class name, and while we're at it trim any slashes. - // The directory path can be included as part of the class name, + { + // Get the class name, and while we're at it trim any slashes. + // The directory path can be included as part of the class name, // but we don't want a leading slash $class = str_replace(EXT, '', trim($class, '/')); - + // Was the path included with the class name? // We look for a slash to determine this $subdir = ''; - if (strpos($class, '/') !== FALSE) + if (($last_slash = strrpos($class, '/')) !== FALSE) { - // explode the path so we can separate the filename from the path - $x = explode('/', $class); - - // Reset the $class variable now that we know the actual filename - $class = end($x); - - // Kill the filename from the array - unset($x[count($x)-1]); - - // Glue the path back together, sans filename - $subdir = implode($x, '/').'/'; + // Extract the path + $subdir = substr($class, 0, $last_slash + 1); + + // Get the filename from the path + $class = substr($class, $last_slash + 1); } // We'll test for both lowercase and capitalized versions of the file name @@ -753,11 +761,11 @@ class CI_Loader { { $subclass = APPPATH.'libraries/'.$subdir.config_item('subclass_prefix').$class.EXT; - // Is this a class extension request? + // Is this a class extension request? if (file_exists($subclass)) { $baseclass = BASEPATH.'libraries/'.ucfirst($class).EXT; - + if ( ! file_exists($baseclass)) { log_message('error', "Unable to load the requested class: ".$class); @@ -775,35 +783,34 @@ class CI_Loader { $CI =& get_instance(); if ( ! isset($CI->$object_name)) { - return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name); + return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name); } } - + $is_duplicate = TRUE; log_message('debug', $class." class already loaded. Second attempt ignored."); return; } - - include_once($baseclass); + + include_once($baseclass); include_once($subclass); $this->_ci_loaded_files[] = $subclass; - - return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name); + + return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name); } - + // Lets search for the requested library file and load it. - $is_duplicate = FALSE; - for ($i = 1; $i < 3; $i++) + $is_duplicate = FALSE; + foreach ($this->_ci_library_paths as $path) { - $path = ($i % 2) ? APPPATH : BASEPATH; $filepath = $path.'libraries/'.$subdir.$class.EXT; - + // Does the file exist? No? Bummer... if ( ! file_exists($filepath)) { continue; } - + // Safety: Was the class already loaded by a previous call? if (in_array($filepath, $this->_ci_loaded_files)) { @@ -818,16 +825,17 @@ class CI_Loader { return $this->_ci_init_class($class, '', $params, $object_name); } } - + $is_duplicate = TRUE; log_message('debug', $class." class already loaded. Second attempt ignored."); return; } - + include_once($filepath); $this->_ci_loaded_files[] = $filepath; return $this->_ci_init_class($class, '', $params, $object_name); } + } // END FOREACH // One last attempt. Maybe the library is in a subdirectory, but it wasn't specified? @@ -836,7 +844,7 @@ class CI_Loader { $path = strtolower($class).'/'.$class; return $this->_ci_load_class($path, $params); } - + // If we got this far we were unable to find the requested class. // We do not issue errors if the load call failed due to a duplicate request if ($is_duplicate == FALSE) @@ -845,7 +853,7 @@ class CI_Loader { show_error("Unable to load the requested class: ".$class); } } - + // -------------------------------------------------------------------- /** @@ -858,29 +866,42 @@ class CI_Loader { * @return null */ function _ci_init_class($class, $prefix = '', $config = FALSE, $object_name = NULL) - { - // Is there an associated config file for this class? + { + // Is there an associated config file for this class? Note: these should always be lowercase if ($config === NULL) { - // We test for both uppercase and lowercase, for servers that - // are case-sensitive with regard to file names - if (file_exists(APPPATH.'config/'.strtolower($class).EXT)) - { - include_once(APPPATH.'config/'.strtolower($class).EXT); - } - elseif (file_exists(APPPATH.'config/'.ucfirst(strtolower($class)).EXT)) + // Fetch the config paths containing any package paths + $config_component = $this->_ci_get_component('config'); + + if (is_array($config_component->_config_paths)) { - include_once(APPPATH.'config/'.ucfirst(strtolower($class)).EXT); + // Break on the first found file, thus package files + // are not overridden by default paths + foreach ($config_component->_config_paths as $path) + { + // We test for both uppercase and lowercase, for servers that + // are case-sensitive with regard to file names + if (file_exists($path .'config/'.strtolower($class).EXT)) + { + include_once($path .'config/'.strtolower($class).EXT); + break; + } + elseif (file_exists($path .'config/'.ucfirst(strtolower($class)).EXT)) + { + include_once($path .'config/'.ucfirst(strtolower($class)).EXT); + break; + } + } } } - + if ($prefix == '') - { - if (class_exists('CI_'.$class)) + { + if (class_exists('CI_'.$class)) { $name = 'CI_'.$class; } - elseif (class_exists(config_item('subclass_prefix').$class)) + elseif (class_exists(config_item('subclass_prefix').$class)) { $name = config_item('subclass_prefix').$class; } @@ -893,18 +914,18 @@ class CI_Loader { { $name = $prefix.$class; } - + // Is the class name valid? if ( ! class_exists($name)) { log_message('error', "Non-existent class: ".$name); show_error("Non-existent class: ".$class); } - + // Set the variable name we will assign the class to // Was a custom class name supplied? If so we'll use it $class = strtolower($class); - + if (is_null($object_name)) { $classvar = ( ! isset($this->_ci_varmap[$class])) ? $class : $this->_ci_varmap[$class]; @@ -914,68 +935,77 @@ class CI_Loader { $classvar = $object_name; } - // Save the class name and object name + // Save the class name and object name $this->_ci_classes[$class] = $classvar; - // Instantiate the class + // Instantiate the class $CI =& get_instance(); if ($config !== NULL) { $CI->$classvar = new $name($config); } else - { + { $CI->$classvar = new $name; - } - } - + } + } + // -------------------------------------------------------------------- - + /** * Autoloader * * The config/autoload.php file contains an array that permits sub-systems, - * libraries, plugins, and helpers to be loaded automatically. + * libraries, and helpers to be loaded automatically. * * @access private * @param array * @return void */ function _ci_autoloader() - { + { include_once(APPPATH.'config/autoload'.EXT); - + if ( ! isset($autoload)) { return FALSE; } - + + // Autoload packages + if (isset($autoload['packages'])) + { + foreach ($autoload['packages'] as $package_path) + { + $this->add_package_path($package_path); + } + } + // Load any custom config file if (count($autoload['config']) > 0) - { + { $CI =& get_instance(); foreach ($autoload['config'] as $key => $val) { $CI->config->load($val); } - } + } - // Autoload plugins, helpers and languages - foreach (array('helper', 'plugin', 'language') as $type) - { + // Autoload helpers and languages + foreach (array('helper', 'language') as $type) + { if (isset($autoload[$type]) AND count($autoload[$type]) > 0) { $this->$type($autoload[$type]); - } + } } // A little tweak to remain backward compatible // The $autoload['core'] item was deprecated - if ( ! isset($autoload['libraries'])) + if ( ! isset($autoload['libraries']) AND isset($autoload['core'])) { $autoload['libraries'] = $autoload['core']; } - + // Load libraries if (isset($autoload['libraries']) AND count($autoload['libraries']) > 0) { @@ -986,100 +1016,80 @@ class CI_Loader { $autoload['libraries'] = array_diff($autoload['libraries'], array('database')); } - // Load scaffolding - if (in_array('scaffolding', $autoload['libraries'])) - { - $this->scaffolding(); - $autoload['libraries'] = array_diff($autoload['libraries'], array('scaffolding')); - } - // Load all other libraries foreach ($autoload['libraries'] as $item) { $this->library($item); } - } + } // Autoload models if (isset($autoload['model'])) { $this->model($autoload['model']); } - } - + // -------------------------------------------------------------------- /** - * Assign to Models + * Object to Array * - * Makes sure that anything loaded by the loader class (libraries, plugins, etc.) - * will be available to models, if any exist. + * Takes an object as input and converts the class variables to array key/vals * * @access private * @param object * @return array */ - function _ci_assign_to_models() + function _ci_object_to_array($object) { - if (count($this->_ci_models) == 0) - { - return; - } - - if ($this->_ci_is_instance()) - { - $CI =& get_instance(); - foreach ($this->_ci_models as $model) - { - $CI->$model->_assign_libraries(); - } - } - else - { - foreach ($this->_ci_models as $model) - { - $this->$model->_assign_libraries(); - } - } - } + return (is_object($object)) ? get_object_vars($object) : $object; + } // -------------------------------------------------------------------- /** - * Object to Array - * - * Takes an object as input and converts the class variables to array key/vals + * Get a reference to a specific library or model * * @access private - * @param object - * @return array + * @return bool */ - function _ci_object_to_array($object) + function &_ci_get_component($component) { - return (is_object($object)) ? get_object_vars($object) : $object; + $CI =& get_instance(); + return $CI->$component; } // -------------------------------------------------------------------- /** - * Determines whether we should use the CI instance or $this + * Prep filename + * + * This function preps the name of various items to make loading them more reliable. * * @access private - * @return bool + * @param mixed + * @return array */ - function _ci_is_instance() + function _ci_prep_filename($filename, $extension) { - if ($this->_ci_is_php5 == TRUE) + if ( ! is_array($filename)) { - return TRUE; + return array(strtolower(str_replace(EXT, '', str_replace($extension, '', $filename)).$extension)); + } + else + { + foreach ($filename as $key => $val) + { + $filename[$key] = strtolower(str_replace(EXT, '', str_replace($extension, '', $val)).$extension); + } + + return $filename; } - - global $CI; - return (is_object($CI)) ? TRUE : FALSE; } + } /* End of file Loader.php */ -/* Location: ./system/libraries/Loader.php */
\ No newline at end of file +/* Location: ./system/core/Loader.php */
\ No newline at end of file diff --git a/system/core/Model.php b/system/core/Model.php new file mode 100755 index 000000000..8566a0b66 --- /dev/null +++ b/system/core/Model.php @@ -0,0 +1,56 @@ +<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); +/** + * CodeIgniter + * + * An open source application development framework for PHP 5.1.6 or newer + * + * @package CodeIgniter + * @author ExpressionEngine Dev Team + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. + * @license http://codeigniter.com/user_guide/license.html + * @link http://codeigniter.com + * @since Version 1.0 + * @filesource + */ + +// ------------------------------------------------------------------------ + +/** + * CodeIgniter Model Class + * + * @package CodeIgniter + * @subpackage Libraries + * @category Libraries + * @author ExpressionEngine Dev Team + * @link http://codeigniter.com/user_guide/libraries/config.html + */ +class CI_Model { + + /** + * Constructor + * + * @access public + */ + function __construct() + { + log_message('debug', "Model Class Initialized"); + } + + /** + * __get + * + * Allows models to access CI's loaded classes using the same + * syntax as controllers. + * + * @access private + */ + function __get($key) + { + $CI =& get_instance(); + return $CI->$key; + } +} +// END Model Class + +/* End of file Model.php */ +/* Location: ./system/core/Model.php */
\ No newline at end of file diff --git a/system/libraries/Output.php b/system/core/Output.php index f320b4142..7fb9f7916 100644..100755 --- a/system/libraries/Output.php +++ b/system/core/Output.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -30,17 +30,22 @@ class CI_Output { var $final_output; var $cache_expiration = 0; - var $headers = array(); - var $enable_profiler = FALSE; + var $headers = array(); + var $enable_profiler = FALSE; + var $parse_exec_vars = TRUE; // whether or not to parse variables like {elapsed_time} and {memory_usage} + var $_zlib_oc = FALSE; + var $_profiler_sections = array(); - function CI_Output() + function __construct() { + $this->_zlib_oc = @ini_get('zlib.output_compression'); + log_message('debug', "Output Class Initialized"); } - + // -------------------------------------------------------------------- - + /** * Get Output * @@ -48,14 +53,14 @@ class CI_Output { * * @access public * @return string - */ + */ function get_output() { return $this->final_output; } - + // -------------------------------------------------------------------- - + /** * Set Output * @@ -64,7 +69,7 @@ class CI_Output { * @access public * @param string * @return void - */ + */ function set_output($output) { $this->final_output = $output; @@ -80,7 +85,7 @@ class CI_Output { * @access public * @param string * @return void - */ + */ function append_output($output) { if ($this->final_output == '') @@ -106,58 +111,87 @@ class CI_Output { * @access public * @param string * @return void - */ + */ function set_header($header, $replace = TRUE) { + // If zlib.output_compression is enabled it will compress the output, + // but it will not modify the content-length header to compensate for + // the reduction, causing the browser to hang waiting for more data. + // We'll just skip content-length in those cases. + + if ($this->_zlib_oc && strncasecmp($header, 'content-length', 14) == 0) + { + return; + } + $this->headers[] = array($header, $replace); } // -------------------------------------------------------------------- - + /** * Set HTTP Status Header * moved to Common procedural functions in 1.7.2 - * + * * @access public - * @param int the status code - * @param string + * @param int the status code + * @param string * @return void - */ - function set_status_header($code = '200', $text = '') + */ + function set_status_header($code = 200, $text = '') { set_status_header($code, $text); } - + // -------------------------------------------------------------------- - + /** * Enable/disable Profiler * * @access public * @param bool * @return void - */ + */ function enable_profiler($val = TRUE) { $this->enable_profiler = (is_bool($val)) ? $val : TRUE; } - + + // -------------------------------------------------------------------- + + /** + * 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; + } + } + // -------------------------------------------------------------------- - + /** * Set Cache * * @access public * @param integer * @return void - */ + */ function cache($time) { $this->cache_expiration = ( ! is_numeric($time)) ? 0 : $time; } - + // -------------------------------------------------------------------- - + /** * Display Output * @@ -171,45 +205,57 @@ class CI_Output { * * @access public * @return mixed - */ + */ function _display($output = '') - { + { // Note: We use globals because we can't use $CI =& get_instance() // since this function is sometimes called by the caching mechanism, // which happens before the CI super object is available. global $BM, $CFG; - + + // Grab the super object if we can. + if (class_exists('CI_Controller')) + { + $CI =& get_instance(); + } + // -------------------------------------------------------------------- - + // Set the output data if ($output == '') { $output =& $this->final_output; } - + // -------------------------------------------------------------------- - - // Do we need to write a cache file? - if ($this->cache_expiration > 0) + + // 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'); - $output = str_replace('{elapsed_time}', $elapsed, $output); - - $memory = ( ! function_exists('memory_get_usage')) ? '0' : round(memory_get_usage()/1024/1024, 2).'MB'; - $output = str_replace('{memory_usage}', $memory, $output); + $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) + if ($CFG->item('compress_output') === TRUE && $this->_zlib_oc == FALSE) { if (extension_loaded('zlib')) { @@ -221,7 +267,7 @@ class CI_Output { } // -------------------------------------------------------------------- - + // Are there any server headers to send? if (count($this->headers) > 0) { @@ -229,32 +275,34 @@ class CI_Output { { @header($header[0], $header[1]); } - } + } // -------------------------------------------------------------------- - - // Does the get_instance() function exist? + + // 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 ( ! function_exists('get_instance')) + if ( ! isset($CI)) { echo $output; log_message('debug', "Final output sent to browser"); log_message('debug', "Total execution time: ".$elapsed); return TRUE; } - + // -------------------------------------------------------------------- - // Grab the super object. We'll need it in a moment... - $CI =& get_instance(); - // Do we need to generate profile data? // If so, load the Profile class and run it. if ($this->enable_profiler == TRUE) { - $CI->load->library('profiler'); - + $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)) @@ -268,7 +316,7 @@ class CI_Output { $output .= $CI->profiler->run(); } } - + // -------------------------------------------------------------------- // Does the controller contain a function named _output()? @@ -281,35 +329,36 @@ class CI_Output { { echo $output; // Send it to the browser! } - + log_message('debug', "Final output sent to browser"); - log_message('debug', "Total execution time: ".$elapsed); + log_message('debug', "Total execution time: ".$elapsed); } - + // -------------------------------------------------------------------- - + /** * Write a Cache File * * @access public * @return void - */ + */ function _write_cache($output) { - $CI =& get_instance(); + $CI =& get_instance(); $path = $CI->config->item('cache_path'); - - $cache_path = ($path == '') ? BASEPATH.'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)) @@ -317,9 +366,9 @@ class CI_Output { 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); @@ -331,73 +380,71 @@ class CI_Output { return; } fclose($fp); - @chmod($cache_path, DIR_WRITE_MODE); + @chmod($cache_path, FILE_WRITE_MODE); log_message('debug', "Cache file written: ".$cache_path); } // -------------------------------------------------------------------- - + /** * Update/serve a cached file * * @access public * @return void - */ + */ function _display_cache(&$CFG, &$URI) { - $cache_path = ($CFG->item('cache_path') == '') ? BASEPATH.'cache/' : $CFG->item('cache_path'); - - if ( ! is_dir($cache_path) OR ! is_really_writable($cache_path)) - { - return FALSE; - } - + $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 + + // Strip out the embedded timestamp if ( ! preg_match("/(\d+TS--->)/", $cache, $match)) { return FALSE; } - + // Has the file expired? If so we'll delete it. if (time() >= trim(str_replace('TS--->', '', $match['1']))) - { - @unlink($filepath); - log_message('debug', "Cache file has expired. File deleted"); - return FALSE; + { + 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."); + log_message('debug', "Cache file is current. Sending it to browser."); return TRUE; } @@ -406,4 +453,4 @@ class CI_Output { // END Output Class /* End of file Output.php */ -/* Location: ./system/libraries/Output.php */
\ No newline at end of file +/* Location: ./system/core/Output.php */
\ No newline at end of file diff --git a/system/libraries/Router.php b/system/core/Router.php index 7dbad0374..7be508fef 100644..100755 --- a/system/libraries/Router.php +++ b/system/core/Router.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -28,31 +28,28 @@ */ class CI_Router { - var $config; - var $routes = array(); + var $config; + var $routes = array(); var $error_routes = array(); var $class = ''; var $method = 'index'; var $directory = ''; - var $uri_protocol = 'auto'; var $default_controller; - var $scaffolding_request = FALSE; // Must be set to FALSE - + /** * Constructor * * Runs the route mapping function. */ - function CI_Router() + function __construct() { - $this->config =& load_class('Config'); - $this->uri =& load_class('URI'); - $this->_set_routing(); + $this->config =& load_class('Config', 'core'); + $this->uri =& load_class('URI', 'core'); log_message('debug', "Router Class Initialized"); } - + // -------------------------------------------------------------------- - + /** * Set the route mapping * @@ -64,20 +61,31 @@ class CI_Router { */ function _set_routing() { - // Are query strings enabled in the config file? - // If so, we're done since segment based URIs are not used with query strings. + // 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')])) { - $this->set_class(trim($this->uri->_filter_uri($_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(); } - - return; } - + // Load the routes.php file. @include(APPPATH.'config/routes'.EXT); $this->routes = ( ! isset($route) OR ! is_array($route)) ? array() : $route; @@ -85,57 +93,74 @@ class CI_Router { // 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']); - + $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 == '') { - 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."); - } - - if (strpos($this->default_controller, '/') !== FALSE) - { - $x = explode('/', $this->default_controller); - - $this->set_class(end($x)); - $this->set_method('index'); - $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."); - return; + return $this->_set_default_controller(); } - unset($this->routes['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(); - + $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 * @@ -150,27 +175,18 @@ class CI_Router { function _set_request($segments = array()) { $segments = $this->_validate_request($segments); - + if (count($segments) == 0) { - return; + return $this->_set_default_controller(); } - + $this->set_class($segments[0]); - + if (isset($segments[1])) { - // A scaffolding request. No funny business with the URL - if ($this->routes['scaffolding_trigger'] == $segments[1] AND $segments[1] != '_ci_scaffolding') - { - $this->scaffolding_request = TRUE; - unset($this->routes['scaffolding_trigger']); - } - else - { - // A standard method request - $this->set_method($segments[1]); - } + // A standard method request + $this->set_method($segments[1]); } else { @@ -178,15 +194,15 @@ class CI_Router { // 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. @@ -194,9 +210,14 @@ class CI_Router { * @access private * @param array * @return array - */ + */ function _validate_request($segments) { + if (count($segments) == 0) + { + return $segments; + } + // Does the requested controller exist in the root folder? if (file_exists(APPPATH.'controllers/'.$segments[0].EXT)) { @@ -205,11 +226,11 @@ class CI_Router { // 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? @@ -220,22 +241,47 @@ class CI_Router { } else { - $this->set_class($this->default_controller); - $this->set_method('index'); - + // Is the method being specified in the route? + if (strpos($this->default_controller, '/') !== FALSE) + { + $x = explode('/', $this->default_controller); + + $this->set_class($x[0]); + $this->set_method($x[1]); + } + else + { + $this->set_class($this->default_controller); + $this->set_method('index'); + } + // Does the default controller exist in the sub-folder? if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$this->default_controller.EXT)) { $this->directory = ''; return array(); } - + } return $segments; } - // Can't find the requested controller... + + // 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]); } @@ -253,41 +299,31 @@ class CI_Router { */ function _parse_routes() { - // Do we even have any custom routing to deal with? - // There is a default scaffolding trigger, so we'll look just for 1 - if (count($this->routes) == 1) - { - $this->_set_request($this->uri->segments); - return; - } - // 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])) { - $this->_set_request(explode('/', $this->routes[$uri])); - return; + 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); } - - $this->_set_request(explode('/', $val)); - return; + + return $this->_set_request(explode('/', $val)); } } @@ -297,54 +333,54 @@ class CI_Router { } // -------------------------------------------------------------------- - + /** * 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()) @@ -356,34 +392,68 @@ class CI_Router { } // -------------------------------------------------------------------- - + /** * 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/libraries/Router.php */
\ No newline at end of file +/* Location: ./system/core/Router.php */
\ No newline at end of file diff --git a/system/libraries/URI.php b/system/core/URI.php index 23efb38c1..999015949 100644..100755 --- a/system/libraries/URI.php +++ b/system/core/URI.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -28,7 +28,7 @@ */ class CI_URI { - var $keyval = array(); + var $keyval = array(); var $uri_string; var $segments = array(); var $rsegments = array(); @@ -42,9 +42,9 @@ class CI_URI { * * @access public */ - function CI_URI() + function __construct() { - $this->config =& load_class('Config'); + $this->config =& load_class('Config', 'core'); log_message('debug', "URI Class Initialized"); } @@ -61,13 +61,17 @@ class CI_URI { { if (strtoupper($this->config->item('uri_protocol')) == 'AUTO') { - // If the URL has a question mark then it's simplest to just - // build the URI string from the zero index of the $_GET array. - // This avoids having to deal with $_SERVER variables, which - // can be unreliable in some environments - if (is_array($_GET) && count($_GET) == 1 && trim(key($_GET), '/') != '') + // Arguments exist, it must be a command line request + if ( ! empty($_SERVER['argv'])) { - $this->uri_string = key($_GET); + $this->uri_string = $this->_parse_cli_args(); + return; + } + + // Let's try the REQUEST_URI first, this will work in most situations + if ($uri = $this->_detect_uri()) + { + $this->uri_string = $uri; return; } @@ -88,12 +92,10 @@ class CI_URI { return; } - // No QUERY_STRING?... Maybe the ORIG_PATH_INFO variable exists? - $path = str_replace($_SERVER['SCRIPT_NAME'], '', (isset($_SERVER['ORIG_PATH_INFO'])) ? $_SERVER['ORIG_PATH_INFO'] : @getenv('ORIG_PATH_INFO')); - if (trim($path, '/') != '' && $path != "/".SELF) + // As a last ditch effort lets try using the $_GET array + if (is_array($_GET) && count($_GET) == 1 && trim(key($_GET), '/') != '') { - // remove path and script information so we have good URI data - $this->uri_string = $path; + $this->uri_string = key($_GET); return; } @@ -106,7 +108,12 @@ class CI_URI { if ($uri == 'REQUEST_URI') { - $this->uri_string = $this->_parse_request_uri(); + $this->uri_string = $this->_detect_uri(); + return; + } + elseif ($uri == 'CLI') + { + $this->uri_string = $this->_parse_cli_args(); return; } @@ -123,54 +130,70 @@ class CI_URI { // -------------------------------------------------------------------- /** - * Parse the REQUEST_URI + * Detects the URI * - * Due to the way REQUEST_URI works it usually contains path info - * that makes it unusable as URI data. We'll trim off the unnecessary - * data, hopefully arriving at a valid URI that we can use. + * This function will detect the URI automatically and fix the query string + * if necessary. * * @access private * @return string */ - function _parse_request_uri() + private function _detect_uri() { - if ( ! isset($_SERVER['REQUEST_URI']) OR $_SERVER['REQUEST_URI'] == '') + if ( ! isset($_SERVER['REQUEST_URI'])) { return ''; } - $request_uri = preg_replace("|/(.*)|", "\\1", str_replace("\\", "/", $_SERVER['REQUEST_URI'])); - - if ($request_uri == '' OR $request_uri == SELF) + $uri = $_SERVER['REQUEST_URI']; + if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0) { - return ''; + $uri = substr($uri, strlen($_SERVER['SCRIPT_NAME'])); } - - $fc_path = FCPATH.SELF; - if (strpos($request_uri, '?') !== FALSE) + elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0) { - $fc_path .= '?'; + $uri = substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME']))); } - $parsed_uri = explode("/", $request_uri); - - $i = 0; - foreach(explode("/", $fc_path) as $segment) + // This section ensures that even on servers that require the URI to be in the query string (Nginx) a correct + // URI is found, and also fixes the QUERY_STRING server var and $_GET array. + if (strncmp($uri, '?/', 2) === 0) { - if (isset($parsed_uri[$i]) && $segment == $parsed_uri[$i]) - { - $i++; - } + $uri = substr($uri, 2); } - - $parsed_uri = implode("/", array_slice($parsed_uri, $i)); - - if ($parsed_uri != '') + $parts = preg_split('#\?#i', $uri, 2); + $uri = $parts[0]; + if (isset($parts[1])) + { + $_SERVER['QUERY_STRING'] = $parts[1]; + parse_str($_SERVER['QUERY_STRING'], $_GET); + } + else { - $parsed_uri = '/'.$parsed_uri; + $_SERVER['QUERY_STRING'] = ''; + $_GET = array(); } + $uri = parse_url($uri, PHP_URL_PATH); - return $parsed_uri; + // Do some final cleaning of the URI and return it + return str_replace(array('//', '../'), '/', trim($uri, '/')); + } + + // -------------------------------------------------------------------- + + /** + * Parse cli arguments + * + * Take each command line argument and assume it is a URI segment. + * + * @access private + * @return string + */ + private function _parse_cli_args() + { + $args = array_slice($_SERVER['argv'], 1); + + return $args ? '/' . implode('/', $args) : ''; } // -------------------------------------------------------------------- @@ -195,7 +218,7 @@ class CI_URI { } // Convert programatic characters to entities - $bad = array('$', '(', ')', '%28', '%29'); + $bad = array('$', '(', ')', '%28', '%29'); $good = array('$', '(', ')', '(', ')'); return str_replace($bad, $good, $str); @@ -228,7 +251,7 @@ class CI_URI { */ function _explode_segments() { - foreach(explode("/", preg_replace("|/*(.+?)/*$|", "\\1", $this->uri_string)) as $val) + foreach (explode("/", preg_replace("|/*(.+?)/*$|", "\\1", $this->uri_string)) as $val) { // Filter segments for security $val = trim($this->_filter_uri($val)); @@ -321,7 +344,7 @@ class CI_URI { */ function uri_to_assoc($n = 3, $default = array()) { - return $this->_uri_to_assoc($n, $default, 'segment'); + return $this->_uri_to_assoc($n, $default, 'segment'); } /** * Identical to above only it uses the re-routed segment array @@ -329,7 +352,7 @@ class CI_URI { */ function ruri_to_assoc($n = 3, $default = array()) { - return $this->_uri_to_assoc($n, $default, 'rsegment'); + return $this->_uri_to_assoc($n, $default, 'rsegment'); } // -------------------------------------------------------------------- @@ -482,21 +505,18 @@ class CI_URI { */ function _slash_segment($n, $where = 'trailing', $which = 'segment') { + $leading = '/'; + $trailing = '/'; + if ($where == 'trailing') { - $trailing = '/'; $leading = ''; } elseif ($where == 'leading') { - $leading = '/'; $trailing = ''; } - else - { - $leading = '/'; - $trailing = '/'; - } + return $leading.$this->$which($n).$trailing; } @@ -576,11 +596,11 @@ class CI_URI { */ function ruri_string() { - return '/'.implode('/', $this->rsegment_array()).'/'; + return '/'.implode('/', $this->rsegment_array()); } } // END URI Class /* End of file URI.php */ -/* Location: ./system/libraries/URI.php */
\ No newline at end of file +/* Location: ./system/core/URI.php */
\ No newline at end of file diff --git a/system/core/Utf8.php b/system/core/Utf8.php new file mode 100755 index 000000000..5d5a7ef72 --- /dev/null +++ b/system/core/Utf8.php @@ -0,0 +1,165 @@ +<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); +/** + * CodeIgniter + * + * An open source application development framework for PHP 5.1.6 or newer + * + * @package CodeIgniter + * @author ExpressionEngine Dev Team + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. + * @license http://codeigniter.com/user_guide/license.html + * @link http://codeigniter.com + * @since Version 2.0 + * @filesource + */ + +// ------------------------------------------------------------------------ + +/** + * Utf8 Class + * + * Provides support for UTF-8 environments + * + * @package CodeIgniter + * @subpackage Libraries + * @category UTF-8 + * @author ExpressionEngine Dev Team + * @link http://codeigniter.com/user_guide/libraries/utf8.html + */ +class CI_Utf8 { + + /** + * Constructor + * + * Determines if UTF-8 support is to be enabled + * + */ + function __construct() + { + log_message('debug', "Utf8 Class Initialized"); + + global $CFG; + + if ( + preg_match('/./u', 'é') === 1 // PCRE must support UTF-8 + AND function_exists('iconv') // iconv must be installed + AND ini_get('mbstring.func_overload') != 1 // Multibyte string function overloading cannot be enabled + AND $CFG->item('charset') == 'UTF-8' // Application charset must be UTF-8 + ) + { + log_message('debug', "UTF-8 Support Enabled"); + + define('UTF8_ENABLED', TRUE); + + // set internal encoding for multibyte string functions if necessary + // and set a flag so we don't have to repeatedly use extension_loaded() + // or function_exists() + if (extension_loaded('mbstring')) + { + define('MB_ENABLED', TRUE); + mb_internal_encoding('UTF-8'); + } + else + { + define('MB_ENABLED', FALSE); + } + } + else + { + log_message('debug', "UTF-8 Support Disabled"); + define('UTF8_ENABLED', FALSE); + } + } + + // -------------------------------------------------------------------- + + /** + * Clean UTF-8 strings + * + * Ensures strings are UTF-8 + * + * @access public + * @param string + * @return string + */ + function clean_string($str) + { + if ($this->_is_ascii($str) === FALSE) + { + $str = @iconv('UTF-8', 'UTF-8//IGNORE', $str); + } + + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Remove ASCII control characters + * + * Removes all ASCII control characters except horizontal tabs, + * line feeds, and carriage returns, as all others can cause + * problems in XML + * + * @access public + * @param string + * @return string + */ + function safe_ascii_for_xml($str) + { + return preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S', '', $str); + } + + // -------------------------------------------------------------------- + + /** + * Convert to UTF-8 + * + * Attempts to convert a string to UTF-8 + * + * @access public + * @param string + * @param string - input encoding + * @return string + */ + function convert_to_utf8($str, $encoding) + { + if (function_exists('iconv')) + { + $str = @iconv($encoding, 'UTF-8', $str); + } + elseif (function_exists('mb_convert_encoding')) + { + $str = @mb_convert_encoding($str, 'UTF-8', $encoding); + } + else + { + return FALSE; + } + + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Is ASCII? + * + * Tests if a string is standard 7-bit ASCII or not + * + * @access public + * @param string + * @return bool + */ + function _is_ascii($str) + { + return (preg_match('/[^\x00-\x7F]/S', $str) == 0); + } + + // -------------------------------------------------------------------- + +} +// End Utf8 Class + +/* End of file Utf8.php */ +/* Location: ./system/core/Utf8.php */
\ No newline at end of file diff --git a/system/scaffolding/index.html b/system/core/index.html index c942a79ce..c942a79ce 100644..100755 --- a/system/scaffolding/index.html +++ b/system/core/index.html diff --git a/system/database/DB.php b/system/database/DB.php index f174687ca..fb0516ba4 100644..100755 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -22,45 +22,45 @@ * @author ExpressionEngine Dev Team * @link http://codeigniter.com/user_guide/database/ */ -function &DB($params = '', $active_record_override = FALSE) +function &DB($params = '', $active_record_override = NULL) { // Load the DB config file if a DSN string wasn't passed if (is_string($params) AND strpos($params, '://') === FALSE) { include(APPPATH.'config/database'.EXT); - + if ( ! isset($db) OR count($db) == 0) { show_error('No database connection settings were found in the database config file.'); } - + if ($params != '') { $active_group = $params; } - + if ( ! isset($active_group) OR ! isset($db[$active_group])) { show_error('You have specified an invalid database connection group.'); } - + $params = $db[$active_group]; } elseif (is_string($params)) { - + /* parse the URL from the DSN string - * Database settings can be passed as discreet - * parameters or as a data source name in the first - * parameter. DSNs must have this prototype: - * $dsn = 'driver://username:password@hostname/database'; - */ - + * Database settings can be passed as discreet + * parameters or as a data source name in the first + * parameter. DSNs must have this prototype: + * $dsn = 'driver://username:password@hostname/database'; + */ + if (($dns = @parse_url($params)) === FALSE) { show_error('Invalid DB Connection String'); } - + $params = array( 'dbdriver' => $dns['scheme'], 'hostname' => (isset($dns['host'])) ? rawurldecode($dns['host']) : '', @@ -68,7 +68,7 @@ function &DB($params = '', $active_record_override = FALSE) 'password' => (isset($dns['pass'])) ? rawurldecode($dns['pass']) : '', 'database' => (isset($dns['path'])) ? rawurldecode(substr($dns['path'], 1)) : '' ); - + // were additional config items set? if (isset($dns['query'])) { @@ -90,7 +90,7 @@ function &DB($params = '', $active_record_override = FALSE) } } } - + // No DB specified yet? Beat them senseless... if ( ! isset($params['dbdriver']) OR $params['dbdriver'] == '') { @@ -101,18 +101,18 @@ function &DB($params = '', $active_record_override = FALSE) // we need to dynamically create a class that extends proper parent class // based on whether we're using the active record class or not. // Kudos to Paul for discovering this clever use of eval() - - if ($active_record_override == TRUE) + + if ($active_record_override !== NULL) { - $active_record = TRUE; + $active_record = $active_record_override; } - + require_once(BASEPATH.'database/DB_driver'.EXT); if ( ! isset($active_record) OR $active_record == TRUE) { require_once(BASEPATH.'database/DB_active_rec'.EXT); - + if ( ! class_exists('CI_DB')) { eval('class CI_DB extends CI_DB_active_record { }'); @@ -125,20 +125,25 @@ function &DB($params = '', $active_record_override = FALSE) eval('class CI_DB extends CI_DB_driver { }'); } } - + require_once(BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].'_driver'.EXT); // Instantiate the DB adapter $driver = 'CI_DB_'.$params['dbdriver'].'_driver'; - $DB =& instantiate_class(new $driver($params)); - + $DB = new $driver($params); + if ($DB->autoinit == TRUE) { $DB->initialize(); } - + + if (isset($params['stricton']) && $params['stricton'] == TRUE) + { + $DB->query('SET SESSION sql_mode="STRICT_ALL_TABLES"'); + } + return $DB; -} +} diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php index bf4d5117e..ce9d1c1af 100644..100755 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -36,17 +36,18 @@ class CI_DB_active_record extends CI_DB_driver { var $ar_like = array(); var $ar_groupby = array(); var $ar_having = array(); + var $ar_keys = array(); var $ar_limit = FALSE; var $ar_offset = FALSE; var $ar_order = FALSE; var $ar_orderby = array(); - var $ar_set = array(); + var $ar_set = array(); var $ar_wherein = array(); var $ar_aliased_tables = array(); var $ar_store_array = array(); - + // Active Record Caching variables - var $ar_caching = FALSE; + var $ar_caching = FALSE; var $ar_cache_exists = array(); var $ar_cache_select = array(); var $ar_cache_from = array(); @@ -56,7 +57,7 @@ class CI_DB_active_record extends CI_DB_driver { var $ar_cache_groupby = array(); var $ar_cache_having = array(); var $ar_cache_orderby = array(); - var $ar_cache_set = array(); + var $ar_cache_set = array(); // -------------------------------------------------------------------- @@ -72,12 +73,12 @@ class CI_DB_active_record extends CI_DB_driver { */ function select($select = '*', $escape = NULL) { - // Set the global value if this was sepecified + // Set the global value if this was sepecified if (is_bool($escape)) { $this->_protect_identifiers = $escape; } - + if (is_string($select)) { $select = explode(',', $select); @@ -117,7 +118,7 @@ class CI_DB_active_record extends CI_DB_driver { { return $this->_max_min_avg_sum($select, $alias, 'MAX'); } - + // -------------------------------------------------------------------- /** @@ -178,7 +179,7 @@ class CI_DB_active_record extends CI_DB_driver { * select_min() * select_avg() * select_sum() - * + * * @access public * @param string the field * @param string an alias @@ -190,29 +191,29 @@ class CI_DB_active_record extends CI_DB_driver { { $this->display_error('db_invalid_query'); } - + $type = strtoupper($type); - + if ( ! in_array($type, array('MAX', 'MIN', 'AVG', 'SUM'))) { show_error('Invalid function type: '.$type); } - + if ($alias == '') { $alias = $this->_create_alias_from_table(trim($select)); } - + $sql = $type.'('.$this->_protect_identifiers(trim($select)).') AS '.$alias; $this->ar_select[] = $sql; - + if ($this->ar_caching === TRUE) { $this->ar_cache_select[] = $sql; $this->ar_cache_exists[] = 'select'; } - + return $this; } @@ -231,7 +232,7 @@ class CI_DB_active_record extends CI_DB_driver { { return end(explode('.', $item)); } - + return $item; } @@ -251,7 +252,7 @@ class CI_DB_active_record extends CI_DB_driver { $this->ar_distinct = (is_bool($val)) ? $val : TRUE; return $this; } - + // -------------------------------------------------------------------- /** @@ -275,12 +276,12 @@ class CI_DB_active_record extends CI_DB_driver { $this->_track_aliases($v); $this->ar_from[] = $this->_protect_identifiers($v, TRUE, NULL, FALSE); - + if ($this->ar_caching === TRUE) { $this->ar_cache_from[] = $this->_protect_identifiers($v, TRUE, NULL, FALSE); $this->ar_cache_exists[] = 'from'; - } + } } } @@ -289,11 +290,11 @@ class CI_DB_active_record extends CI_DB_driver { $val = trim($val); // Extract any aliases that might exist. We use this information - // in the _protect_identifiers to know whether to add a table prefix + // in the _protect_identifiers to know whether to add a table prefix $this->_track_aliases($val); - + $this->ar_from[] = $this->_protect_identifiers($val, TRUE, NULL, FALSE); - + if ($this->ar_caching === TRUE) { $this->ar_cache_from[] = $this->_protect_identifiers($val, TRUE, NULL, FALSE); @@ -319,7 +320,7 @@ class CI_DB_active_record extends CI_DB_driver { * @return object */ function join($table, $cond, $type = '') - { + { if ($type != '') { $type = strtoupper(trim($type)); @@ -335,7 +336,7 @@ class CI_DB_active_record extends CI_DB_driver { } // Extract any aliases that might exist. We use this information - // in the _protect_identifiers to know whether to add a table prefix + // in the _protect_identifiers to know whether to add a table prefix $this->_track_aliases($table); // Strip apart the condition and protect the identifiers @@ -343,10 +344,10 @@ class CI_DB_active_record extends CI_DB_driver { { $match[1] = $this->_protect_identifiers($match[1]); $match[3] = $this->_protect_identifiers($match[3]); - - $cond = $match[1].$match[2].$match[3]; + + $cond = $match[1].$match[2].$match[3]; } - + // Assemble the JOIN statement $join = $type.'JOIN '.$this->_protect_identifiers($table, TRUE, NULL, FALSE).' ON '.$cond; @@ -377,7 +378,7 @@ class CI_DB_active_record extends CI_DB_driver { { return $this->_where($key, $value, 'AND ', $escape); } - + // -------------------------------------------------------------------- /** @@ -399,18 +400,6 @@ class CI_DB_active_record extends CI_DB_driver { // -------------------------------------------------------------------- /** - * orwhere() is an alias of or_where() - * this function is here for backwards compatibility, as - * orwhere() has been deprecated - */ - function orwhere($key, $value = NULL, $escape = TRUE) - { - return $this->or_where($key, $value, $escape); - } - - // -------------------------------------------------------------------- - - /** * Where * * Called by where() or orwhere() @@ -427,7 +416,7 @@ class CI_DB_active_record extends CI_DB_driver { { $key = array($key => $value); } - + // If the escape value was not set will will base it on the global setting if ( ! is_bool($escape)) { @@ -443,13 +432,13 @@ class CI_DB_active_record extends CI_DB_driver { // value appears not to have been set, assign the test to IS NULL $k .= ' IS NULL'; } - + if ( ! is_null($v)) { if ($escape === TRUE) { $k = $this->_protect_identifiers($k, FALSE, $escape); - + $v = ' '.$this->escape($v); } @@ -460,19 +449,19 @@ class CI_DB_active_record extends CI_DB_driver { } else { - $k = $this->_protect_identifiers($k, FALSE, $escape); + $k = $this->_protect_identifiers($k, FALSE, $escape); } $this->ar_where[] = $prefix.$k.$v; - + if ($this->ar_caching === TRUE) { $this->ar_cache_where[] = $prefix.$k.$v; $this->ar_cache_exists[] = 'where'; } - + } - + return $this; } @@ -493,7 +482,7 @@ class CI_DB_active_record extends CI_DB_driver { { return $this->_where_in($key, $values); } - + // -------------------------------------------------------------------- /** @@ -529,7 +518,7 @@ class CI_DB_active_record extends CI_DB_driver { { return $this->_where_in($key, $values, TRUE); } - + // -------------------------------------------------------------------- /** @@ -559,7 +548,7 @@ class CI_DB_active_record extends CI_DB_driver { * @param string The field to search * @param array The values searched on * @param boolean If the statement would be IN or NOT IN - * @param string + * @param string * @return object */ function _where_in($key = NULL, $values = NULL, $not = FALSE, $type = 'AND ') @@ -568,12 +557,12 @@ class CI_DB_active_record extends CI_DB_driver { { return; } - + if ( ! is_array($values)) { $values = array($values); } - + $not = ($not) ? ' NOT' : ''; foreach ($values as $value) @@ -582,7 +571,7 @@ class CI_DB_active_record extends CI_DB_driver { } $prefix = (count($this->ar_where) == 0) ? '' : $type; - + $where_in = $prefix . $this->_protect_identifiers($key) . $not . " IN (" . implode(", ", $this->ar_wherein) . ") "; $this->ar_where[] = $where_in; @@ -596,7 +585,7 @@ class CI_DB_active_record extends CI_DB_driver { $this->ar_wherein = array(); return $this; } - + // -------------------------------------------------------------------- /** @@ -632,7 +621,7 @@ class CI_DB_active_record extends CI_DB_driver { { return $this->_like($field, $match, 'AND ', $side, 'NOT'); } - + // -------------------------------------------------------------------- /** @@ -668,19 +657,7 @@ class CI_DB_active_record extends CI_DB_driver { { return $this->_like($field, $match, 'OR ', $side, 'NOT'); } - - // -------------------------------------------------------------------- - /** - * orlike() is an alias of or_like() - * this function is here for backwards compatibility, as - * orlike() has been deprecated - */ - function orlike($field, $match = '', $side = 'both') - { - return $this->or_like($field, $match, $side); - } - // -------------------------------------------------------------------- /** @@ -700,7 +677,7 @@ class CI_DB_active_record extends CI_DB_driver { { $field = array($field => $match); } - + foreach ($field as $k => $v) { $k = $this->_protect_identifiers($k); @@ -721,24 +698,24 @@ class CI_DB_active_record extends CI_DB_driver { { $like_statement = $prefix." $k $not LIKE '%{$v}%'"; } - + // some platforms require an escape sequence definition for LIKE wildcards if ($this->_like_escape_str != '') { - $like_statement = $like_statement.sprintf($this->_like_escape_str, $this->_like_escape_char); + $like_statement = $like_statement.sprintf($this->_like_escape_str, $this->_like_escape_chr); } - + $this->ar_like[] = $like_statement; if ($this->ar_caching === TRUE) { $this->ar_cache_like[] = $like_statement; $this->ar_cache_exists[] = 'like'; } - + } return $this; } - + // -------------------------------------------------------------------- /** @@ -754,15 +731,15 @@ class CI_DB_active_record extends CI_DB_driver { { $by = explode(',', $by); } - + foreach ($by as $val) { $val = trim($val); - + if ($val != '') { $this->ar_groupby[] = $this->_protect_identifiers($val); - + if ($this->ar_caching === TRUE) { $this->ar_cache_groupby[] = $this->_protect_identifiers($val); @@ -776,18 +753,6 @@ class CI_DB_active_record extends CI_DB_driver { // -------------------------------------------------------------------- /** - * groupby() is an alias of group_by() - * this function is here for backwards compatibility, as - * groupby() has been deprecated - */ - function groupby($by) - { - return $this->group_by($by); - } - - // -------------------------------------------------------------------- - - /** * Sets the HAVING value * * Separates multiple calls with AND @@ -805,18 +770,6 @@ class CI_DB_active_record extends CI_DB_driver { // -------------------------------------------------------------------- /** - * orhaving() is an alias of or_having() - * this function is here for backwards compatibility, as - * orhaving() has been deprecated - */ - - function orhaving($key, $value = '', $escape = TRUE) - { - return $this->or_having($key, $value, $escape); - } - // -------------------------------------------------------------------- - - /** * Sets the OR HAVING value * * Separates multiple calls with OR @@ -830,7 +783,7 @@ class CI_DB_active_record extends CI_DB_driver { { return $this->_having($key, $value, 'OR ', $escape); } - + // -------------------------------------------------------------------- /** @@ -849,7 +802,7 @@ class CI_DB_active_record extends CI_DB_driver { { $key = array($key => $value); } - + foreach ($key as $k => $v) { $prefix = (count($this->ar_having) == 0) ? '' : $type; @@ -868,7 +821,7 @@ class CI_DB_active_record extends CI_DB_driver { { $v = ' '.$this->escape_str($v); } - + $this->ar_having[] = $prefix.$k.$v; if ($this->ar_caching === TRUE) { @@ -876,10 +829,10 @@ class CI_DB_active_record extends CI_DB_driver { $this->ar_cache_exists[] = 'having'; } } - + return $this; } - + // -------------------------------------------------------------------- /** @@ -901,8 +854,8 @@ class CI_DB_active_record extends CI_DB_driver { { $direction = (in_array(strtoupper(trim($direction)), array('ASC', 'DESC'), TRUE)) ? ' '.$direction : ' ASC'; } - - + + if (strpos($orderby, ',') !== FALSE) { $temp = array(); @@ -913,19 +866,19 @@ class CI_DB_active_record extends CI_DB_driver { { $part = $this->_protect_identifiers(trim($part)); } - + $temp[] = $part; } - - $orderby = implode(', ', $temp); + + $orderby = implode(', ', $temp); } else if ($direction != $this->_random_keyword) { $orderby = $this->_protect_identifiers($orderby); } - + $orderby_statement = $orderby.$direction; - + $this->ar_orderby[] = $orderby_statement; if ($this->ar_caching === TRUE) { @@ -935,19 +888,7 @@ class CI_DB_active_record extends CI_DB_driver { return $this; } - - // -------------------------------------------------------------------- - /** - * orderby() is an alias of order_by() - * this function is here for backwards compatibility, as - * orderby() has been deprecated - */ - function orderby($orderby, $direction = '') - { - return $this->order_by($orderby, $direction); - } - // -------------------------------------------------------------------- /** @@ -966,10 +907,10 @@ class CI_DB_active_record extends CI_DB_driver { { $this->ar_offset = $offset; } - + return $this; } - + // -------------------------------------------------------------------- /** @@ -984,7 +925,7 @@ class CI_DB_active_record extends CI_DB_driver { $this->ar_offset = $offset; return $this; } - + // -------------------------------------------------------------------- /** @@ -999,11 +940,11 @@ class CI_DB_active_record extends CI_DB_driver { function set($key, $value = '', $escape = TRUE) { $key = $this->_object_to_array($key); - + if ( ! is_array($key)) { $key = array($key => $value); - } + } foreach ($key as $k => $v) { @@ -1016,10 +957,10 @@ class CI_DB_active_record extends CI_DB_driver { $this->ar_set[$this->_protect_identifiers($k)] = $this->escape($v); } } - + return $this; } - + // -------------------------------------------------------------------- /** @@ -1041,12 +982,12 @@ class CI_DB_active_record extends CI_DB_driver { $this->_track_aliases($table); $this->from($table); } - + if ( ! is_null($limit)) { $this->limit($limit, $offset); } - + $sql = $this->_compile_select(); $result = $this->query($sql); @@ -1057,7 +998,7 @@ class CI_DB_active_record extends CI_DB_driver { /** * "Count All Results" query * - * Generates a platform-specific query string that counts all records + * Generates a platform-specific query string that counts all records * returned by an Active Record query. * * @access public @@ -1071,12 +1012,12 @@ class CI_DB_active_record extends CI_DB_driver { $this->_track_aliases($table); $this->from($table); } - + $sql = $this->_compile_select($this->_count_string . $this->_protect_identifiers('numrows')); $query = $this->query($sql); $this->_reset_select(); - + if ($query->num_rows() == 0) { return '0'; @@ -1110,12 +1051,12 @@ class CI_DB_active_record extends CI_DB_driver { { $this->where($where); } - + if ( ! is_null($limit)) { $this->limit($limit, $offset); } - + $sql = $this->_compile_select(); $result = $this->query($sql); @@ -1126,15 +1067,123 @@ class CI_DB_active_record extends CI_DB_driver { // -------------------------------------------------------------------- /** - * getwhere() is an alias of get_where() - * this function is here for backwards compatibility, as - * getwhere() has been deprecated + * Insert_Batch + * + * Compiles batch insert strings and runs the queries + * + * @access public + * @param string the table to retrieve the results from + * @param array an associative array of insert values + * @return object */ - function getwhere($table = '', $where = null, $limit = null, $offset = null) + function insert_batch($table = '', $set = NULL) { - return $this->get_where($table, $where, $limit, $offset); + if ( ! is_null($set)) + { + $this->set_insert_batch($set); + } + + if (count($this->ar_set) == 0) + { + if ($this->db_debug) + { + //No valid data array. Folds in cases where keys and values did not match up + return $this->display_error('db_must_use_set'); + } + return FALSE; + } + + if ($table == '') + { + if ( ! isset($this->ar_from[0])) + { + if ($this->db_debug) + { + return $this->display_error('db_must_set_table'); + } + return FALSE; + } + + $table = $this->ar_from[0]; + } + + // Batch this baby + for ($i = 0, $total = count($this->ar_set); $i < $total; $i = $i + 100) + { + + $sql = $this->_insert_batch($this->_protect_identifiers($table, TRUE, NULL, FALSE), $this->ar_keys, array_slice($this->ar_set, $i, 100)); + + //echo $sql; + + $this->query($sql); + } + + $this->_reset_write(); + + + return TRUE; } - + + // -------------------------------------------------------------------- + + /** + * The "set_insert_batch" function. Allows key/value pairs to be set for batch inserts + * + * @access public + * @param mixed + * @param string + * @param boolean + * @return object + */ + + function set_insert_batch($key, $value = '', $escape = TRUE) + { + $key = $this->_object_to_array_batch($key); + + if ( ! is_array($key)) + { + $key = array($key => $value); + } + + $keys = array_keys(current($key)); + sort($keys); + + foreach ($key as $row) + { + if (count(array_diff($keys, array_keys($row))) > 0 OR count(array_diff(array_keys($row), $keys)) > 0) + { + // batch function above returns an error on an empty array + $this->ar_set[] = array(); + return; + } + + ksort($row); // puts $row in the same order as our keys + + if ($escape === FALSE) + { + $this->ar_set[] = '('.implode(',', $row).')'; + } + else + { + $clean = array(); + + foreach($row as $value) + { + $clean[] = $this->escape($value); + } + + $this->ar_set[] = '('.implode(',', $clean).')'; + } + } + + foreach ($keys as $k) + { + $this->ar_keys[] = $this->_protect_identifiers($k); + } + + return $this; + } + // -------------------------------------------------------------------- /** @@ -1148,12 +1197,12 @@ class CI_DB_active_record extends CI_DB_driver { * @return object */ function insert($table = '', $set = NULL) - { + { if ( ! is_null($set)) { $this->set($set); } - + if (count($this->ar_set) == 0) { if ($this->db_debug) @@ -1173,16 +1222,52 @@ class CI_DB_active_record extends CI_DB_driver { } return FALSE; } - + $table = $this->ar_from[0]; } $sql = $this->_insert($this->_protect_identifiers($table, TRUE, NULL, FALSE), array_keys($this->ar_set), array_values($this->ar_set)); - + $this->_reset_write(); - return $this->query($sql); + return $this->query($sql); } - + + function replace($table = '', $set = NULL) + { + if ( ! is_null($set)) + { + $this->set($set); + } + + if (count($this->ar_set) == 0) + { + if ($this->db_debug) + { + return $this->display_error('db_must_use_set'); + } + return FALSE; + } + + if ($table == '') + { + if ( ! isset($this->ar_from[0])) + { + if ($this->db_debug) + { + return $this->display_error('db_must_set_table'); + } + return FALSE; + } + + $table = $this->ar_from[0]; + } + + $sql = $this->_replace($this->_protect_identifiers($table, TRUE, NULL, FALSE), array_keys($this->ar_set), array_values($this->ar_set)); + + $this->_reset_write(); + return $this->query($sql); + } + // -------------------------------------------------------------------- /** @@ -1205,7 +1290,7 @@ class CI_DB_active_record extends CI_DB_driver { { $this->set($set); } - + if (count($this->ar_set) == 0) { if ($this->db_debug) @@ -1225,10 +1310,10 @@ class CI_DB_active_record extends CI_DB_driver { } return FALSE; } - + $table = $this->ar_from[0]; } - + if ($where != NULL) { $this->where($where); @@ -1238,13 +1323,140 @@ class CI_DB_active_record extends CI_DB_driver { { $this->limit($limit); } - + $sql = $this->_update($this->_protect_identifiers($table, TRUE, NULL, FALSE), $this->ar_set, $this->ar_where, $this->ar_orderby, $this->ar_limit); - + $this->_reset_write(); return $this->query($sql); } + + // -------------------------------------------------------------------- + + /** + * Update_Batch + * + * Compiles an update string and runs the query + * + * @access public + * @param string the table to retrieve the results from + * @param array an associative array of update values + * @param string the where key + * @return object + */ + function update_batch($table = '', $set = NULL, $index = NULL) + { + // Combine any cached components with the current statements + $this->_merge_cache(); + + if (is_null($index)) + { + if ($this->db_debug) + { + return $this->display_error('db_myst_use_index'); + } + + return FALSE; + } + + if ( ! is_null($set)) + { + $this->set_update_batch($set, $index); + } + + if (count($this->ar_set) == 0) + { + if ($this->db_debug) + { + return $this->display_error('db_must_use_set'); + } + + return FALSE; + } + + if ($table == '') + { + if ( ! isset($this->ar_from[0])) + { + if ($this->db_debug) + { + return $this->display_error('db_must_set_table'); + } + return FALSE; + } + + $table = $this->ar_from[0]; + } + + // Batch this baby + for ($i = 0, $total = count($this->ar_set); $i < $total; $i = $i + 100) + { + $sql = $this->_update_batch($this->_protect_identifiers($table, TRUE, NULL, FALSE), array_slice($this->ar_set, $i, 100), $this->_protect_identifiers($index), $this->ar_where); + + $this->query($sql); + } + + $this->_reset_write(); + } + + // -------------------------------------------------------------------- + + /** + * The "set_update_batch" function. Allows key/value pairs to be set for batch updating + * + * @access public + * @param array + * @param string + * @param boolean + * @return object + */ + + function set_update_batch($key, $index = '', $escape = TRUE) + { + $key = $this->_object_to_array_batch($key); + + if ( ! is_array($key)) + { + // @todo error + } + + foreach ($key as $k => $v) + { + $index_set = FALSE; + $clean = array(); + + foreach($v as $k2 => $v2) + { + if ($k2 == $index) + { + $index_set = TRUE; + } + else + { + $not[] = $k.'-'.$v; + } + + if ($escape === FALSE) + { + $clean[$this->_protect_identifiers($k2)] = $v2; + } + else + { + $clean[$this->_protect_identifiers($k2)] = $this->escape($v2); + } + } + + if ($index_set == FALSE) + { + return $this->display_error('db_batch_missing_index'); + } + + $this->ar_set[] = $clean; + } + + return $this; + } + // -------------------------------------------------------------------- /** @@ -1279,7 +1491,7 @@ class CI_DB_active_record extends CI_DB_driver { $sql = $this->_delete($table); $this->_reset_write(); - + return $this->query($sql); } @@ -1319,10 +1531,10 @@ class CI_DB_active_record extends CI_DB_driver { $sql = $this->_truncate($table); $this->_reset_write(); - + return $this->query($sql); } - + // -------------------------------------------------------------------- /** @@ -1388,7 +1600,7 @@ class CI_DB_active_record extends CI_DB_driver { } return FALSE; - } + } $sql = $this->_delete($table, $this->ar_where, $this->ar_like, $this->ar_limit); @@ -1396,7 +1608,7 @@ class CI_DB_active_record extends CI_DB_driver { { $this->_reset_write(); } - + return $this->query($sql); } @@ -1431,7 +1643,7 @@ class CI_DB_active_record extends CI_DB_driver { * @access private * @param string The table to inspect * @return string - */ + */ function _track_aliases($table) { if (is_array($table)) @@ -1442,23 +1654,23 @@ class CI_DB_active_record extends CI_DB_driver { } return; } - + // Does the string contain a comma? If so, we need to separate // the string into discreet statements if (strpos($table, ',') !== FALSE) { return $this->_track_aliases(explode(',', $table)); } - + // if a table alias is used we can recognize it by a space if (strpos($table, " ") !== FALSE) { // if the alias is written with the AS keyword, remove it $table = preg_replace('/ AS /i', ' ', $table); - + // Grab the alias $table = trim(strrchr($table, " ")); - + // Store the alias, if it doesn't already exist if ( ! in_array($table, $this->ar_aliased_tables)) { @@ -1484,7 +1696,7 @@ class CI_DB_active_record extends CI_DB_driver { $this->_merge_cache(); // ---------------------------------------------------------------- - + // Write the "select" portion of the query if ($select_override !== FALSE) @@ -1494,13 +1706,13 @@ class CI_DB_active_record extends CI_DB_driver { else { $sql = ( ! $this->ar_distinct) ? 'SELECT ' : 'SELECT DISTINCT '; - + if (count($this->ar_select) == 0) { - $sql .= '*'; + $sql .= '*'; } else - { + { // Cycle through the "select" portion of the query and prep each column name. // The reason we protect identifiers here rather then in the select() function // is because until the user calls the from() function we don't know if there are aliases @@ -1508,13 +1720,13 @@ class CI_DB_active_record extends CI_DB_driver { { $this->ar_select[$key] = $this->_protect_identifiers($val); } - + $sql .= implode(', ', $this->ar_select); } } // ---------------------------------------------------------------- - + // Write the "FROM" portion of the query if (count($this->ar_from) > 0) @@ -1525,7 +1737,7 @@ class CI_DB_active_record extends CI_DB_driver { } // ---------------------------------------------------------------- - + // Write the "JOIN" portion of the query if (count($this->ar_join) > 0) @@ -1536,7 +1748,7 @@ class CI_DB_active_record extends CI_DB_driver { } // ---------------------------------------------------------------- - + // Write the "WHERE" portion of the query if (count($this->ar_where) > 0 OR count($this->ar_like) > 0) @@ -1549,9 +1761,9 @@ class CI_DB_active_record extends CI_DB_driver { $sql .= implode("\n", $this->ar_where); // ---------------------------------------------------------------- - + // Write the "LIKE" portion of the query - + if (count($this->ar_like) > 0) { if (count($this->ar_where) > 0) @@ -1563,20 +1775,20 @@ class CI_DB_active_record extends CI_DB_driver { } // ---------------------------------------------------------------- - + // Write the "GROUP BY" portion of the query - + if (count($this->ar_groupby) > 0) { $sql .= "\nGROUP BY "; - + $sql .= implode(', ', $this->ar_groupby); } // ---------------------------------------------------------------- - + // Write the "HAVING" portion of the query - + if (count($this->ar_having) > 0) { $sql .= "\nHAVING "; @@ -1584,24 +1796,24 @@ class CI_DB_active_record extends CI_DB_driver { } // ---------------------------------------------------------------- - + // Write the "ORDER BY" portion of the query if (count($this->ar_orderby) > 0) { $sql .= "\nORDER BY "; $sql .= implode(', ', $this->ar_orderby); - + if ($this->ar_order !== FALSE) { $sql .= ($this->ar_order == 'desc') ? ' DESC' : ' ASC'; - } + } } // ---------------------------------------------------------------- - + // Write the "LIMIT" portion of the query - + if (is_numeric($this->ar_limit)) { $sql .= "\n"; @@ -1628,20 +1840,60 @@ class CI_DB_active_record extends CI_DB_driver { { return $object; } - + $array = array(); foreach (get_object_vars($object) as $key => $val) { // There are some built in keys we need to ignore for this conversion - if ( ! is_object($val) && ! is_array($val) && $key != '_parent_name' && $key != '_ci_scaffolding' && $key != '_ci_scaff_table') + if ( ! is_object($val) && ! is_array($val) && $key != '_parent_name') { $array[$key] = $val; } } - + + return $array; + } + + // -------------------------------------------------------------------- + + /** + * Object to Array + * + * Takes an object as input and converts the class variables to array key/vals + * + * @access public + * @param object + * @return array + */ + function _object_to_array_batch($object) + { + if ( ! is_object($object)) + { + return $object; + } + + $array = array(); + $out = get_object_vars($object); + $fields = array_keys($out); + + foreach ($fields as $val) + { + // There are some built in keys we need to ignore for this conversion + if ($val != '_parent_name') + { + + $i = 0; + foreach ($out[$val] as $data) + { + $array[$i][$val] = $data; + $i++; + } + } + } + return $array; } - + // -------------------------------------------------------------------- /** @@ -1651,7 +1903,7 @@ class CI_DB_active_record extends CI_DB_driver { * * @access public * @return void - */ + */ function start_cache() { $this->ar_caching = TRUE; @@ -1666,7 +1918,7 @@ class CI_DB_active_record extends CI_DB_driver { * * @access public * @return void - */ + */ function stop_cache() { $this->ar_caching = FALSE; @@ -1681,23 +1933,23 @@ class CI_DB_active_record extends CI_DB_driver { * * @access public * @return void - */ + */ function flush_cache() - { + { $this->_reset_run( array( - 'ar_cache_select' => array(), - 'ar_cache_from' => array(), + 'ar_cache_select' => array(), + 'ar_cache_from' => array(), 'ar_cache_join' => array(), - 'ar_cache_where' => array(), - 'ar_cache_like' => array(), - 'ar_cache_groupby' => array(), - 'ar_cache_having' => array(), - 'ar_cache_orderby' => array(), + 'ar_cache_where' => array(), + 'ar_cache_like' => array(), + 'ar_cache_groupby' => array(), + 'ar_cache_having' => array(), + 'ar_cache_orderby' => array(), 'ar_cache_set' => array(), 'ar_cache_exists' => array() ) - ); + ); } // -------------------------------------------------------------------- @@ -1705,7 +1957,7 @@ class CI_DB_active_record extends CI_DB_driver { /** * Merge Cache * - * When called, this function merges any cached AR arrays with + * When called, this function merges any cached AR arrays with * locally called ones. * * @access private @@ -1770,50 +2022,51 @@ class CI_DB_active_record extends CI_DB_driver { function _reset_select() { $ar_reset_items = array( - 'ar_select' => array(), - 'ar_from' => array(), - 'ar_join' => array(), - 'ar_where' => array(), - 'ar_like' => array(), - 'ar_groupby' => array(), - 'ar_having' => array(), - 'ar_orderby' => array(), - 'ar_wherein' => array(), + 'ar_select' => array(), + 'ar_from' => array(), + 'ar_join' => array(), + 'ar_where' => array(), + 'ar_like' => array(), + 'ar_groupby' => array(), + 'ar_having' => array(), + 'ar_orderby' => array(), + 'ar_wherein' => array(), 'ar_aliased_tables' => array(), - 'ar_distinct' => FALSE, - 'ar_limit' => FALSE, - 'ar_offset' => FALSE, + 'ar_distinct' => FALSE, + 'ar_limit' => FALSE, + 'ar_offset' => FALSE, 'ar_order' => FALSE, ); - + $this->_reset_run($ar_reset_items); } - + // -------------------------------------------------------------------- /** * Resets the active record "write" values. * - * Called by the insert() update() and delete() functions + * Called by the insert() update() insert_batch() update_batch() and delete() functions * * @access private * @return void */ function _reset_write() - { + { $ar_reset_items = array( - 'ar_set' => array(), - 'ar_from' => array(), - 'ar_where' => array(), + 'ar_set' => array(), + 'ar_from' => array(), + 'ar_where' => array(), 'ar_like' => array(), - 'ar_orderby' => array(), - 'ar_limit' => FALSE, + 'ar_orderby' => array(), + 'ar_keys' => array(), + 'ar_limit' => FALSE, 'ar_order' => FALSE ); $this->_reset_run($ar_reset_items); } - + } /* End of file DB_active_rec.php */ diff --git a/system/database/DB_cache.php b/system/database/DB_cache.php index d3968b315..3bf065ca5 100644..100755 --- a/system/database/DB_cache.php +++ b/system/database/DB_cache.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -32,14 +32,14 @@ class CI_DB_Cache { * * Grabs the CI super object instance so we can access it. * - */ + */ function CI_DB_Cache(&$db) { // Assign the main CI object to $this->CI // and load the file helper since we use it a lot $this->CI =& get_instance(); $this->db =& $db; - $this->CI->load->helper('file'); + $this->CI->load->helper('file'); } // -------------------------------------------------------------------- @@ -50,7 +50,7 @@ class CI_DB_Cache { * @access public * @param string the path to the cache directory * @return bool - */ + */ function check_path($path = '') { if ($path == '') @@ -59,10 +59,10 @@ class CI_DB_Cache { { return $this->db->cache_off(); } - + $path = $this->db->cachedir; } - + // Add a trailing slash to the path if needed $path = preg_replace("/(.+?)\/*$/", "\\1/", $path); @@ -71,11 +71,11 @@ class CI_DB_Cache { // If the path is wrong we'll turn off caching return $this->db->cache_off(); } - + $this->db->cachedir = $path; return TRUE; } - + // -------------------------------------------------------------------- /** @@ -95,18 +95,18 @@ class CI_DB_Cache { } $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); - + + $filepath = $this->db->cachedir.$segment_one.'+'.$segment_two.'/'.md5($sql); + if (FALSE === ($cachedata = read_file($filepath))) - { + { return FALSE; } - - return unserialize($cachedata); - } + + return unserialize($cachedata); + } // -------------------------------------------------------------------- @@ -124,29 +124,29 @@ class CI_DB_Cache { } $segment_one = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1); - + $segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2); - + $dir_path = $this->db->cachedir.$segment_one.'+'.$segment_two.'/'; - + $filename = md5($sql); - + if ( ! @is_dir($dir_path)) { if ( ! @mkdir($dir_path, DIR_WRITE_MODE)) { return FALSE; } - - @chmod($dir_path, DIR_WRITE_MODE); + + @chmod($dir_path, DIR_WRITE_MODE); } - + if (write_file($dir_path.$filename, serialize($object)) === FALSE) { return FALSE; } - - @chmod($dir_path.$filename, DIR_WRITE_MODE); + + @chmod($dir_path.$filename, FILE_WRITE_MODE); return TRUE; } @@ -159,19 +159,19 @@ class CI_DB_Cache { * @return bool */ function delete($segment_one = '', $segment_two = '') - { + { if ($segment_one == '') { $segment_one = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1); } - + if ($segment_two == '') { $segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2); } - + $dir_path = $this->db->cachedir.$segment_one.'+'.$segment_two.'/'; - + delete_files($dir_path, TRUE); } diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index b2a3c2ebd..2d8f592e3 100644..100755 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -71,13 +71,13 @@ class CI_DB_driver { var $limit_used; - + /** * Constructor. Accepts one parameter containing the database * connection settings. * * @param array - */ + */ function CI_DB_driver($params) { if (is_array($params)) @@ -90,7 +90,7 @@ class CI_DB_driver { log_message('debug', 'Database Driver Class Initialized'); } - + // -------------------------------------------------------------------- /** @@ -99,7 +99,7 @@ class CI_DB_driver { * @access private Called by the constructor * @param mixed * @return void - */ + */ function initialize() { // If an existing connection resource is available @@ -108,9 +108,9 @@ class CI_DB_driver { { return TRUE; } - + // ---------------------------------------------------------------- - + // Connect to the database and set the connection ID $this->conn_id = ($this->pconnect == FALSE) ? $this->db_connect() : $this->db_pconnect(); @@ -118,7 +118,7 @@ class CI_DB_driver { if ( ! $this->conn_id) { log_message('error', 'Unable to connect to the database'); - + if ($this->db_debug) { $this->display_error('db_unable_to_connect'); @@ -134,12 +134,12 @@ class CI_DB_driver { if ( ! $this->db_select()) { log_message('error', 'Unable to select database: '.$this->database); - + if ($this->db_debug) { $this->display_error('db_unable_to_select', $this->database); } - return FALSE; + return FALSE; } else { @@ -148,14 +148,14 @@ class CI_DB_driver { { return FALSE; } - + return TRUE; } } return TRUE; } - + // -------------------------------------------------------------------- /** @@ -171,26 +171,26 @@ class CI_DB_driver { if ( ! $this->_db_set_charset($this->char_set, $this->dbcollat)) { log_message('error', 'Unable to set database connection charset: '.$this->char_set); - + if ($this->db_debug) { $this->display_error('db_unable_to_set_charset', $this->char_set); } - + return FALSE; } - + return TRUE; } - + // -------------------------------------------------------------------- /** * The name of the platform in use (mysql, mssql, etc...) * * @access public - * @return string - */ + * @return string + */ function platform() { return $this->dbdriver; @@ -203,8 +203,8 @@ class CI_DB_driver { * version of the database being used * * @access public - * @return string - */ + * @return string + */ function version() { if (FALSE === ($sql = $this->_version())) @@ -215,16 +215,22 @@ class CI_DB_driver { } return FALSE; } - - if ($this->dbdriver == 'oci8') + + // Some DBs have functions that return the version, and don't run special + // SQL queries per se. In these instances, just return the result. + $driver_version_exceptions = array('oci8', 'sqlite'); + + if (in_array($this->dbdriver, $driver_version_exceptions)) { return $sql; } - - $query = $this->query($sql); - return $query->row('ver'); + else + { + $query = $this->query($sql); + return $query->row('ver'); + } } - + // -------------------------------------------------------------------- /** @@ -239,8 +245,8 @@ class CI_DB_driver { * @access public * @param string An SQL query string * @param array An array of binding data - * @return mixed - */ + * @return mixed + */ function query($sql, $binds = FALSE, $return_object = TRUE) { if ($sql == '') @@ -255,10 +261,10 @@ class CI_DB_driver { // Verify table prefix and replace if necessary if ( ($this->dbprefix != '' AND $this->swap_pre != '') AND ($this->dbprefix != $this->swap_pre) ) - { + { $sql = preg_replace("/(\W)".$this->swap_pre."(\S+?)/", "\\1".$this->dbprefix."\\2", $sql); } - + // Is query caching enabled? If the query is a "read type" // we will load the caching class and return the previously // cached query if it exists @@ -273,7 +279,7 @@ class CI_DB_driver { } } } - + // Compile binds if needed if ($binds !== FALSE) { @@ -285,10 +291,10 @@ class CI_DB_driver { { $this->queries[] = $sql; } - + // Start the Query Timer $time_start = list($sm, $ss) = explode(' ', microtime()); - + // Run the Query if (FALSE === ($this->result_id = $this->simple_query($sql))) { @@ -296,7 +302,7 @@ class CI_DB_driver { { $this->query_times[] = 0; } - + // This will trigger a rollback if transactions are being used $this->_trans_status = FALSE; @@ -306,10 +312,10 @@ class CI_DB_driver { // additional queries before displaying the error $error_no = $this->_error_number(); $error_msg = $this->_error_message(); - + // We call this function in order to roll-back queries // if transactions are enabled. If we don't call this here - // the error message will trigger an exit, causing the + // the error message will trigger an exit, causing the // transactions to remain in limbo. $this->trans_complete(); @@ -323,10 +329,10 @@ class CI_DB_driver { ) ); } - + return FALSE; } - + // Stop and aggregate the query time results $time_end = list($em, $es) = explode(' ', microtime()); $this->benchmark += ($em + $es) - ($sm + $ss); @@ -335,10 +341,10 @@ class CI_DB_driver { { $this->query_times[] = ($em + $es) - ($sm + $ss); } - + // Increment the query counter $this->query_count++; - + // Was the query a "write" type? // If so we'll simply return true if ($this->is_write_type($sql) === TRUE) @@ -349,10 +355,10 @@ class CI_DB_driver { { $this->CACHE->delete(); } - + return TRUE; } - + // Return TRUE if we don't need to create a result object // Currently only the Oracle driver uses this when stored // procedures are used @@ -360,11 +366,11 @@ class CI_DB_driver { { return TRUE; } - - // Load and instantiate the result driver - - $driver = $this->load_rdriver(); - $RES = new $driver(); + + // Load and instantiate the result driver + + $driver = $this->load_rdriver(); + $RES = new $driver(); $RES->conn_id = $this->conn_id; $RES->result_id = $this->result_id; @@ -375,10 +381,10 @@ class CI_DB_driver { $RES->limit_used = $this->limit_used; $this->stmt_id = FALSE; } - + // oci8 vars must be set before calling this $RES->num_rows = $RES->num_rows(); - + // Is query caching enabled? If so, we'll serialize the // result object and save it to a cache file. if ($this->cache_on == TRUE AND $this->_cache_init()) @@ -390,17 +396,17 @@ class CI_DB_driver { // result object, so we'll have to compile the data // and save it) $CR = new CI_DB_result(); - $CR->num_rows = $RES->num_rows(); + $CR->num_rows = $RES->num_rows(); $CR->result_object = $RES->result_object(); $CR->result_array = $RES->result_array(); - + // Reset these since cached objects can not utilize resource IDs. $CR->conn_id = NULL; $CR->result_id = NULL; $this->CACHE->write($sql, $CR); } - + return $RES; } @@ -410,8 +416,8 @@ class CI_DB_driver { * Load the result drivers * * @access public - * @return string the name of the result class - */ + * @return string the name of the result class + */ function load_rdriver() { $driver = 'CI_DB_'.$this->dbdriver.'_result'; @@ -421,10 +427,10 @@ class CI_DB_driver { include_once(BASEPATH.'database/DB_result'.EXT); include_once(BASEPATH.'database/drivers/'.$this->dbdriver.'/'.$this->dbdriver.'_result'.EXT); } - + return $driver; } - + // -------------------------------------------------------------------- /** @@ -435,8 +441,8 @@ class CI_DB_driver { * * @access public * @param string the sql query - * @return mixed - */ + * @return mixed + */ function simple_query($sql) { if ( ! $this->conn_id) @@ -446,7 +452,7 @@ class CI_DB_driver { return $this->_execute($sql); } - + // -------------------------------------------------------------------- /** @@ -454,8 +460,8 @@ class CI_DB_driver { * This permits transactions to be disabled at run-time. * * @access public - * @return void - */ + * @return void + */ function trans_off() { $this->trans_enabled = FALSE; @@ -471,23 +477,23 @@ class CI_DB_driver { * a failure of one group will not affect any others * * @access public - * @return void - */ + * @return void + */ function trans_strict($mode = TRUE) { $this->trans_strict = is_bool($mode) ? $mode : TRUE; } - + // -------------------------------------------------------------------- /** * Start Transaction * * @access public - * @return void - */ + * @return void + */ function trans_start($test_mode = FALSE) - { + { if ( ! $this->trans_enabled) { return FALSE; @@ -499,7 +505,7 @@ class CI_DB_driver { $this->_trans_depth += 1; return; } - + $this->trans_begin($test_mode); } @@ -509,27 +515,27 @@ class CI_DB_driver { * Complete Transaction * * @access public - * @return bool - */ + * @return bool + */ function trans_complete() { if ( ! $this->trans_enabled) { return FALSE; } - + // When transactions are nested we only begin/commit/rollback the outermost ones if ($this->_trans_depth > 1) { $this->_trans_depth -= 1; return TRUE; } - + // The query() function will set this flag to FALSE in the event that a query failed if ($this->_trans_status === FALSE) { $this->trans_rollback(); - + // If we are NOT running in strict mode, we will reset // the _trans_status flag so that subsequent groups of transactions // will be permitted. @@ -541,7 +547,7 @@ class CI_DB_driver { log_message('debug', 'DB Transaction Failure'); return FALSE; } - + $this->trans_commit(); return TRUE; } @@ -552,8 +558,8 @@ class CI_DB_driver { * Lets you retrieve the transaction flag to determine if it has failed * * @access public - * @return bool - */ + * @return bool + */ function trans_status() { return $this->_trans_status; @@ -567,20 +573,20 @@ class CI_DB_driver { * @access public * @param string the sql statement * @param array an array of bind data - * @return string - */ + * @return string + */ function compile_binds($sql, $binds) { if (strpos($sql, $this->bind_marker) === FALSE) { return $sql; } - + if ( ! is_array($binds)) { $binds = array($binds); } - + // Get the sql segments around the bind markers $segments = explode($this->bind_marker, $sql); @@ -601,7 +607,7 @@ class CI_DB_driver { return $result; } - + // -------------------------------------------------------------------- /** @@ -609,8 +615,8 @@ class CI_DB_driver { * * @access public * @param string An SQL query string - * @return boolean - */ + * @return boolean + */ function is_write_type($sql) { if ( ! preg_match('/^\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD DATA|COPY|ALTER|GRANT|REVOKE|LOCK|UNLOCK)\s+/i', $sql)) @@ -619,7 +625,7 @@ class CI_DB_driver { } return TRUE; } - + // -------------------------------------------------------------------- /** @@ -627,34 +633,34 @@ class CI_DB_driver { * * @access public * @param integer The number of decimal places - * @return integer - */ + * @return integer + */ function elapsed_time($decimals = 6) { return number_format($this->benchmark, $decimals); } - + // -------------------------------------------------------------------- /** * Returns the total number of queries * * @access public - * @return integer - */ + * @return integer + */ function total_queries() { return $this->query_count; } - + // -------------------------------------------------------------------- /** * Returns the last query that was executed * * @access public - * @return void - */ + * @return void + */ function last_query() { return end($this->queries); @@ -670,8 +676,8 @@ class CI_DB_driver { * * @access public * @param string - * @return mixed - */ + * @return mixed + */ function escape($str) { if (is_string($str)) @@ -691,24 +697,24 @@ class CI_DB_driver { } // -------------------------------------------------------------------- - + /** * Escape LIKE String * * Calls the individual driver for platform * specific escaping for LIKE conditions - * + * * @access public * @param string * @return mixed */ - function escape_like_str($str) - { - return $this->escape_str($str, TRUE); + function escape_like_str($str) + { + return $this->escape_str($str, TRUE); } // -------------------------------------------------------------------- - + /** * Primary * @@ -717,12 +723,12 @@ class CI_DB_driver { * * @access public * @param string the table name - * @return string - */ + * @return string + */ function primary($table = '') - { + { $fields = $this->list_fields($table); - + if ( ! is_array($fields)) { return FALSE; @@ -737,8 +743,8 @@ class CI_DB_driver { * Returns an array of table names * * @access public - * @return array - */ + * @return array + */ function list_tables($constrain_by_prefix = FALSE) { // Is there a cached result? @@ -746,7 +752,7 @@ class CI_DB_driver { { return $this->data_cache['table_names']; } - + if (FALSE === ($sql = $this->_list_tables($constrain_by_prefix))) { if ($this->db_debug) @@ -758,7 +764,7 @@ class CI_DB_driver { $retval = array(); $query = $this->query($sql); - + if ($query->num_rows() > 0) { foreach($query->result_array() as $row) @@ -777,7 +783,7 @@ class CI_DB_driver { $this->data_cache['table_names'] = $retval; return $this->data_cache['table_names']; } - + // -------------------------------------------------------------------- /** @@ -786,10 +792,10 @@ class CI_DB_driver { * @return boolean */ function table_exists($table_name) - { + { return ( ! in_array($this->_protect_identifiers($table_name, TRUE, FALSE, FALSE), $this->list_tables())) ? FALSE : TRUE; } - + // -------------------------------------------------------------------- /** @@ -797,7 +803,7 @@ class CI_DB_driver { * * @access public * @param string the table name - * @return array + * @return array */ function list_fields($table = '') { @@ -806,7 +812,7 @@ class CI_DB_driver { { return $this->data_cache['field_names'][$table]; } - + if ($table == '') { if ($this->db_debug) @@ -815,8 +821,8 @@ class CI_DB_driver { } return FALSE; } - - if (FALSE === ($sql = $this->_list_columns($this->_protect_identifiers($table, TRUE, NULL, FALSE)))) + + if (FALSE === ($sql = $this->_list_columns($table))) { if ($this->db_debug) { @@ -824,9 +830,9 @@ class CI_DB_driver { } return FALSE; } - + $query = $this->query($sql); - + $retval = array(); foreach($query->result_array() as $row) { @@ -837,9 +843,9 @@ class CI_DB_driver { else { $retval[] = current($row); - } + } } - + $this->data_cache['field_names'][$table] = $retval; return $this->data_cache['field_names'][$table]; } @@ -854,10 +860,10 @@ class CI_DB_driver { * @return boolean */ function field_exists($field_name, $table_name) - { + { return ( ! in_array($field_name, $this->list_fields($table_name))) ? FALSE : TRUE; } - + // -------------------------------------------------------------------- /** @@ -865,8 +871,8 @@ class CI_DB_driver { * * @access public * @param string the table name - * @return object - */ + * @return object + */ function field_data($table = '') { if ($table == '') @@ -877,36 +883,36 @@ class CI_DB_driver { } return FALSE; } - + $query = $this->query($this->_field_data($this->_protect_identifiers($table, TRUE, NULL, FALSE))); return $query->field_data(); - } + } // -------------------------------------------------------------------- - + /** * Generate an insert string * * @access public * @param string the table upon which the query will be performed * @param array an associative array data of key/values - * @return string - */ + * @return string + */ function insert_string($table, $data) { $fields = array(); $values = array(); - + foreach($data as $key => $val) { $fields[] = $this->_escape_identifiers($key); $values[] = $this->escape($val); } - + return $this->_insert($this->_protect_identifiers($table, TRUE, NULL, FALSE), $fields, $values); - } - + } + // -------------------------------------------------------------------- /** @@ -916,15 +922,15 @@ class CI_DB_driver { * @param string the table upon which the query will be performed * @param array an associative array data of key/values * @param mixed the "where" statement - * @return string - */ + * @return string + */ function update_string($table, $data, $where) { if ($where == '') { return false; } - + $fields = array(); foreach($data as $key => $val) { @@ -941,23 +947,23 @@ class CI_DB_driver { foreach ($where as $key => $val) { $prefix = (count($dest) == 0) ? '' : ' AND '; - + if ($val !== '') { if ( ! $this->_has_operator($key)) { $key .= ' ='; } - + $val = ' '.$this->escape($val); } - + $dest[] = $prefix.$key.$val; } - } + } return $this->_update($this->_protect_identifiers($table, TRUE, NULL, FALSE), $fields, $dest); - } + } // -------------------------------------------------------------------- @@ -987,17 +993,17 @@ class CI_DB_driver { * @access public * @param string the function name * @param mixed any parameters needed by the function - * @return mixed - */ + * @return mixed + */ function call_function($function) { $driver = ($this->dbdriver == 'postgre') ? 'pg_' : $this->dbdriver.'_'; - + if (FALSE === strpos($driver, $function)) { $function = $driver.$function; } - + if ( ! function_exists($function)) { if ($this->db_debug) @@ -1022,7 +1028,7 @@ class CI_DB_driver { * @access public * @param string the path to the cache directory * @return void - */ + */ function cache_set_path($path = '') { $this->cachedir = $path; @@ -1035,7 +1041,7 @@ class CI_DB_driver { * * @access public * @return void - */ + */ function cache_on() { $this->cache_on = TRUE; @@ -1049,13 +1055,13 @@ class CI_DB_driver { * * @access public * @return void - */ + */ function cache_off() { $this->cache_on = FALSE; return FALSE; } - + // -------------------------------------------------------------------- @@ -1064,7 +1070,7 @@ class CI_DB_driver { * * @access public * @return void - */ + */ function cache_delete($segment_one = '', $segment_two = '') { if ( ! $this->_cache_init()) @@ -1081,7 +1087,7 @@ class CI_DB_driver { * * @access public * @return void - */ + */ function cache_delete_all() { if ( ! $this->_cache_init()) @@ -1099,7 +1105,7 @@ class CI_DB_driver { * * @access private * @return void - */ + */ function _cache_init() { if (is_object($this->CACHE) AND class_exists('CI_DB_Cache')) @@ -1125,8 +1131,8 @@ class CI_DB_driver { * Close DB Connection * * @access public - * @return void - */ + * @return void + */ function close() { if (is_resource($this->conn_id) OR is_object($this->conn_id)) @@ -1135,7 +1141,7 @@ class CI_DB_driver { } $this->conn_id = FALSE; } - + // -------------------------------------------------------------------- /** @@ -1145,11 +1151,11 @@ class CI_DB_driver { * @param string the error message * @param string any "swap" values * @param boolean whether to localize the message - * @return string sends the application/error_db.php template - */ + * @return string sends the application/error_db.php template + */ function display_error($error = '', $swap = '', $native = FALSE) { - $LANG =& load_class('Language'); + $LANG =& load_class('Lang', 'core'); $LANG->load('db'); $heading = $LANG->line('db_error_heading'); @@ -1162,8 +1168,26 @@ class CI_DB_driver { { $message = ( ! is_array($error)) ? array(str_replace('%s', $swap, $LANG->line($error))) : $error; } - - $error =& load_class('Exceptions'); + + // Find the most likely culprit of the error by going through + // the backtrace until the source file is no longer in the + // database folder. + + $trace = debug_backtrace(); + + foreach($trace as $call) + { + if (isset($call['file']) && strpos($call['file'], BASEPATH.'database') === FALSE) + { + // Found it - use a relative path for safety + $message[] = 'Filename: '.str_replace(array(BASEPATH, APPPATH), '', $call['file']); + $message[] = 'Line Number: '.$call['line']; + + break; + } + } + + $error =& load_class('Exceptions', 'core'); echo $error->show_error($heading, $message, 'error_db'); exit; } @@ -1190,7 +1214,7 @@ class CI_DB_driver { * Protect Identifiers * * This function is used extensively by the Active Record class, and by - * a couple functions in this class. + * a couple functions in this class. * It takes a column or table name (optionally with an alias) and inserts * the table prefix onto it. Some logic is necessary in order to deal with * column names that include the path. Consider a query like this: @@ -1212,7 +1236,7 @@ class CI_DB_driver { * @param mixed * @param bool * @return string - */ + */ function _protect_identifiers($item, $prefix_single = FALSE, $protect_identifiers = NULL, $field_exists = TRUE) { if ( ! is_bool($protect_identifiers)) @@ -1234,7 +1258,7 @@ class CI_DB_driver { // Convert tabs or multiple spaces into single spaces $item = preg_replace('/[\t ]+/', ' ', $item); - + // If the item has an alias declaration we remove it and set it aside. // Basically we remove everything to the right of the first space $alias = ''; @@ -1245,7 +1269,7 @@ class CI_DB_driver { } // This is basically a bug fix for queries that use MAX, MIN, etc. - // If a parenthesis is found we know that we do not need to + // If a parenthesis is found we know that we do not need to // escape the data or add a prefix. There's probably a more graceful // way to deal with this, but I'm not thinking of it -- Rick if (strpos($item, '(') !== FALSE) @@ -1259,7 +1283,7 @@ class CI_DB_driver { if (strpos($item, '.') !== FALSE) { $parts = explode('.', $item); - + // Does the first segment of the exploded item match // one of the aliases previously identified? If so, // we have nothing more to do other than escape the item @@ -1274,12 +1298,12 @@ class CI_DB_driver { $parts[$key] = $this->_escape_identifiers($val); } } - + $item = implode('.', $parts); - } + } return $item.$alias; } - + // Is there a table prefix defined in the config file? If not, no need to do anything if ($this->dbprefix != '') { @@ -1302,7 +1326,7 @@ class CI_DB_driver { { $i = 0; } - + // This flag is set when the supplied $item does not contain a field name. // This can happen when this function is being called from a JOIN. if ($field_exists == FALSE) @@ -1315,22 +1339,22 @@ class CI_DB_driver { { $parts[$i] = preg_replace("/^".$this->swap_pre."(\S+?)/", $this->dbprefix."\\1", $parts[$i]); } - + // We only add the table prefix if it does not already exist if (substr($parts[$i], 0, strlen($this->dbprefix)) != $this->dbprefix) { $parts[$i] = $this->dbprefix.$parts[$i]; } - + // Put the parts back together $item = implode('.', $parts); } - + if ($protect_identifiers === TRUE) { $item = $this->_escape_identifiers($item); } - + return $item.$alias; } @@ -1347,14 +1371,14 @@ class CI_DB_driver { if ($prefix_single == TRUE AND substr($item, 0, strlen($this->dbprefix)) != $this->dbprefix) { $item = $this->dbprefix.$item; - } + } } if ($protect_identifiers === TRUE AND ! in_array($item, $this->_reserved_identifiers)) { $item = $this->_escape_identifiers($item); } - + return $item.$alias; } diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php index c5931db27..27f2c372d 100644..100755 --- a/system/database/DB_forge.php +++ b/system/database/DB_forge.php @@ -2,11 +2,11 @@ /** * Code Igniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -24,9 +24,9 @@ */ class CI_DB_forge { - var $fields = array(); + var $fields = array(); var $keys = array(); - var $primary_keys = array(); + var $primary_keys = array(); var $db_char_set = ''; /** @@ -34,7 +34,7 @@ class CI_DB_forge { * * Grabs the CI super object instance so we can access it. * - */ + */ function CI_DB_forge() { // Assign the main database object to $this->db @@ -55,12 +55,12 @@ class CI_DB_forge { function create_database($db_name) { $sql = $this->_create_database($db_name); - + if (is_bool($sql)) { return $sql; } - + return $this->db->query($sql); } @@ -76,12 +76,12 @@ class CI_DB_forge { function drop_database($db_name) { $sql = $this->_drop_database($db_name); - + if (is_bool($sql)) { return $sql; } - + return $this->db->query($sql); } @@ -103,15 +103,15 @@ class CI_DB_forge { { $this->add_key($one, $primary); } - + return; } - + if ($key == '') { show_error('Key information is required for that operation.'); } - + if ($primary === TRUE) { $this->primary_keys[] = $key; @@ -137,7 +137,7 @@ class CI_DB_forge { { show_error('Field information is required.'); } - + if (is_string($field)) { if ($field == 'id') @@ -157,16 +157,16 @@ class CI_DB_forge { { show_error('Field information is required for that operation.'); } - + $this->fields[] = $field; } } - + if (is_array($field)) { $this->fields = array_merge($this->fields, $field); } - + } // -------------------------------------------------------------------- @@ -179,19 +179,19 @@ class CI_DB_forge { * @return bool */ function create_table($table = '', $if_not_exists = FALSE) - { + { if ($table == '') { show_error('A table name is required for that operation.'); } - + if (count($this->fields) == 0) - { + { show_error('Field information is required.'); } $sql = $this->_create_table($this->db->dbprefix.$table, $this->fields, $this->primary_keys, $this->keys, $if_not_exists); - + $this->_reset(); return $this->db->query($sql); } @@ -208,12 +208,12 @@ class CI_DB_forge { function drop_table($table_name) { $sql = $this->_drop_table($this->db->dbprefix.$table_name); - + if (is_bool($sql)) { return $sql; } - + return $this->db->query($sql); } @@ -233,7 +233,7 @@ class CI_DB_forge { { show_error('A table name is required for that operation.'); } - + $sql = $this->_rename_table($table_name, $new_table_name); return $this->db->query($sql); } @@ -261,24 +261,25 @@ class CI_DB_forge { foreach ($field as $k => $v) { - $this->add_field(array($k => $field[$k])); + $this->add_field(array($k => $field[$k])); if (count($this->fields) == 0) - { + { show_error('Field information is required.'); } - + $sql = $this->_alter_table('ADD', $this->db->dbprefix.$table, $this->fields, $after_field); $this->_reset(); - + if ($this->db->query($sql) === FALSE) { return FALSE; } } - + return TRUE; + } // -------------------------------------------------------------------- @@ -293,7 +294,7 @@ class CI_DB_forge { */ function drop_column($table = '', $column_name = '') { - + if ($table == '') { show_error('A table name is required for that operation.'); @@ -305,7 +306,7 @@ class CI_DB_forge { } $sql = $this->_alter_table('DROP', $this->db->dbprefix.$table, $column_name); - + return $this->db->query($sql); } @@ -332,23 +333,29 @@ class CI_DB_forge { foreach ($field as $k => $v) { + // If no name provided, use the current name + if ( ! isset($field[$k]['name'])) + { + $field[$k]['name'] = $k; + } + $this->add_field(array($k => $field[$k])); if (count($this->fields) == 0) - { + { show_error('Field information is required.'); } - + $sql = $this->_alter_table('CHANGE', $this->db->dbprefix.$table, $this->fields); $this->_reset(); - + if ($this->db->query($sql) === FALSE) { return FALSE; } } - + return TRUE; } @@ -364,9 +371,9 @@ class CI_DB_forge { */ function _reset() { - $this->fields = array(); + $this->fields = array(); $this->keys = array(); - $this->primary_keys = array(); + $this->primary_keys = array(); } } diff --git a/system/database/DB_result.php b/system/database/DB_result.php index b9e64feeb..fb4268c21 100644..100755 --- a/system/database/DB_result.php +++ b/system/database/DB_result.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -28,13 +28,14 @@ */ class CI_DB_result { - var $conn_id = NULL; - var $result_id = NULL; - var $result_array = array(); - var $result_object = array(); - var $current_row = 0; - var $num_rows = 0; - var $row_data = NULL; + var $conn_id = NULL; + var $result_id = NULL; + var $result_array = array(); + var $result_object = array(); + var $custom_result_object = array(); + var $current_row = 0; + var $num_rows = 0; + var $row_data = NULL; /** @@ -42,30 +43,67 @@ class CI_DB_result { * * @access public * @param string can be "object" or "array" - * @return mixed either a result object or array - */ + * @return mixed either a result object or array + */ function result($type = 'object') - { - return ($type == 'object') ? $this->result_object() : $this->result_array(); + { + if ($type == 'array') return $this->result_array(); + else if ($type == 'object') return $this->result_object(); + else return $this->custom_result_object($type); } // -------------------------------------------------------------------- + /** + * Custom query result. + * + * @param class_name A string that represents the type of object you want back + * @return array of objects + */ + function custom_result_object($class_name) + { + if (array_key_exists($class_name, $this->custom_result_object)) + { + return $this->custom_result_object[$class_name]; + } + + if ($this->result_id === FALSE OR $this->num_rows() == 0) + { + return array(); + } + + // add the data to the object + $this->_data_seek(0); + $result_object = array(); + while ($row = $this->_fetch_object()) + { + $object = new $class_name(); + foreach($row as $key => $value) + { + $object->$key = $value; + } + $result_object[] = $object; + } + + // return the array + return $this->custom_result_object[$class_name] = $result_object; + } + /** * Query result. "object" version. * * @access public * @return object - */ + */ function result_object() { if (count($this->result_object) > 0) { return $this->result_object; } - - // In the event that query caching is on the result_id variable - // will return FALSE since there isn't a valid SQL resource so + + // In the event that query caching is on the result_id variable + // will return FALSE since there isn't a valid SQL resource so // we'll simply return an empty array. if ($this->result_id === FALSE OR $this->num_rows() == 0) { @@ -77,10 +115,10 @@ class CI_DB_result { { $this->result_object[] = $row; } - + return $this->result_object; } - + // -------------------------------------------------------------------- /** @@ -88,7 +126,7 @@ class CI_DB_result { * * @access public * @return array - */ + */ function result_array() { if (count($this->result_array) > 0) @@ -96,8 +134,8 @@ class CI_DB_result { return $this->result_array; } - // In the event that query caching is on the result_id variable - // will return FALSE since there isn't a valid SQL resource so + // In the event that query caching is on the result_id variable + // will return FALSE since there isn't a valid SQL resource so // we'll simply return an empty array. if ($this->result_id === FALSE OR $this->num_rows() == 0) { @@ -109,7 +147,7 @@ class CI_DB_result { { $this->result_array[] = $row; } - + return $this->result_array; } @@ -121,8 +159,8 @@ class CI_DB_result { * @access public * @param string * @param string can be "object" or "array" - * @return mixed either a result object or array - */ + * @return mixed either a result object or array + */ function row($n = 0, $type = 'object') { if ( ! is_numeric($n)) @@ -132,17 +170,19 @@ class CI_DB_result { { $this->row_data = $this->row_array(0); } - + // array_key_exists() instead of isset() to allow for MySQL NULL values if (array_key_exists($n, $this->row_data)) { return $this->row_data[$n]; } - // reset the $n variable if the result was not achieved + // reset the $n variable if the result was not achieved $n = 0; } - - return ($type == 'object') ? $this->row_object($n) : $this->row_array($n); + + if ($type == 'object') return $this->row_object($n); + else if ($type == 'array') return $this->row_array($n); + else return $this->custom_row_object($n, $type); } // -------------------------------------------------------------------- @@ -152,7 +192,7 @@ class CI_DB_result { * * @access public * @return object - */ + */ function set_row($key, $value = NULL) { // We cache the row data for subsequent uses @@ -160,17 +200,17 @@ class CI_DB_result { { $this->row_data = $this->row_array(0); } - + if (is_array($key)) { foreach ($key as $k => $v) { $this->row_data[$k] = $v; } - + return; } - + if ($key != '' AND ! is_null($value)) { $this->row_data[$key] = $value; @@ -179,16 +219,39 @@ class CI_DB_result { // -------------------------------------------------------------------- - /** + /** + * Returns a single result row - custom object version + * + * @access public + * @return object + */ + function custom_row_object($n, $type) + { + $result = $this->custom_result_object($type); + + if (count($result) == 0) + { + return $result; + } + + if ($n != $this->current_row AND isset($result[$n])) + { + $this->current_row = $n; + } + + return $result[$this->current_row]; + } + + /** * Returns a single result row - object version * * @access public * @return object - */ + */ function row_object($n = 0) { $result = $this->result_object(); - + if (count($result) == 0) { return $result; @@ -209,7 +272,7 @@ class CI_DB_result { * * @access public * @return array - */ + */ function row_array($n = 0) { $result = $this->result_array(); @@ -218,16 +281,16 @@ class CI_DB_result { { return $result; } - + if ($n != $this->current_row AND isset($result[$n])) { $this->current_row = $n; } - + return $result[$this->current_row]; } - + // -------------------------------------------------------------------- /** @@ -235,7 +298,7 @@ class CI_DB_result { * * @access public * @return object - */ + */ function first_row($type = 'object') { $result = $this->result($type); @@ -246,7 +309,7 @@ class CI_DB_result { } return $result[0]; } - + // -------------------------------------------------------------------- /** @@ -254,7 +317,7 @@ class CI_DB_result { * * @access public * @return object - */ + */ function last_row($type = 'object') { $result = $this->result($type); @@ -264,7 +327,7 @@ class CI_DB_result { return $result; } return $result[count($result) -1]; - } + } // -------------------------------------------------------------------- @@ -273,7 +336,7 @@ class CI_DB_result { * * @access public * @return object - */ + */ function next_row($type = 'object') { $result = $this->result($type); @@ -287,10 +350,10 @@ class CI_DB_result { { ++$this->current_row; } - + return $result[$this->current_row]; } - + // -------------------------------------------------------------------- /** @@ -298,7 +361,7 @@ class CI_DB_result { * * @access public * @return object - */ + */ function previous_row($type = 'object') { $result = $this->result($type); @@ -329,14 +392,14 @@ class CI_DB_result { function num_rows() { return $this->num_rows; } function num_fields() { return 0; } function list_fields() { return array(); } - function field_data() { return array(); } + function field_data() { return array(); } function free_result() { return TRUE; } function _data_seek() { return TRUE; } - function _fetch_assoc() { return array(); } + function _fetch_assoc() { return array(); } function _fetch_object() { return array(); } - + } // END DB_result class /* End of file DB_result.php */ -/* Location: ./system/database/DB_result.php */
\ No newline at end of file +/* Location: ./system/database/DB_result.php */ diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index 94e7a0bda..a5f174f0a 100644..100755 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -2,11 +2,11 @@ /** * Code Igniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -25,20 +25,20 @@ class CI_DB_utility extends CI_DB_forge { var $db; - var $data_cache = array(); + var $data_cache = array(); /** * Constructor * * Grabs the CI super object instance so we can access it. * - */ + */ function CI_DB_utility() { // Assign the main database object to $this->db $CI =& get_instance(); $this->db =& $CI->db; - + log_message('debug', "Database Utility Class Initialized"); } @@ -51,13 +51,13 @@ class CI_DB_utility extends CI_DB_forge { * @return bool */ function list_databases() - { + { // Is there a cached result? if (isset($this->data_cache['db_names'])) { return $this->data_cache['db_names']; } - + $query = $this->db->query($this->_list_databases()); $dbs = array(); if ($query->num_rows() > 0) @@ -67,7 +67,7 @@ class CI_DB_utility extends CI_DB_forge { $dbs[] = current($row); } } - + $this->data_cache['db_names'] = $dbs; return $this->data_cache['db_names']; } @@ -75,6 +75,31 @@ class CI_DB_utility extends CI_DB_forge { // -------------------------------------------------------------------- /** + * Determine if a particular database exists + * + * @access public + * @param string + * @return boolean + */ + function database_exists($database_name) + { + // Some databases won't have access to the list_databases() function, so + // this is intended to allow them to override with their own functions as + // defined in $driver_utility.php + if (method_exists($this, '_database_exists')) + { + return $this->_database_exists($database_name); + } + else + { + return ( ! in_array($database_name, $this->list_databases())) ? FALSE : TRUE; + } + } + + + // -------------------------------------------------------------------- + + /** * Optimize Table * * @access public @@ -84,15 +109,15 @@ class CI_DB_utility extends CI_DB_forge { function optimize_table($table_name) { $sql = $this->_optimize_table($table_name); - + if (is_bool($sql)) { show_error('db_must_use_set'); } - + $query = $this->db->query($sql); $res = $query->result_array(); - + // Note: Due to a bug in current() that affects some versions // of PHP we can not pass function call directly into it return current($res); @@ -112,14 +137,14 @@ class CI_DB_utility extends CI_DB_forge { foreach ($this->db->list_tables() as $table_name) { $sql = $this->_optimize_table($table_name); - + if (is_bool($sql)) { return $sql; } - + $query = $this->db->query($sql); - + // Build the result array... // Note: Due to a bug in current() that affects some versions // of PHP we can not pass function call directly into it @@ -128,7 +153,7 @@ class CI_DB_utility extends CI_DB_forge { $key = str_replace($this->db->database.'.', '', current($res)); $keys = array_keys($res); unset($res[$keys[0]]); - + $result[$key] = $res; } @@ -147,20 +172,20 @@ class CI_DB_utility extends CI_DB_forge { function repair_table($table_name) { $sql = $this->_repair_table($table_name); - + if (is_bool($sql)) { return $sql; } - + $query = $this->db->query($sql); - + // Note: Due to a bug in current() that affects some versions // of PHP we can not pass function call directly into it $res = $query->result_array(); return current($res); } - + // -------------------------------------------------------------------- /** @@ -178,25 +203,25 @@ class CI_DB_utility extends CI_DB_forge { if ( ! is_object($query) OR ! method_exists($query, 'list_fields')) { show_error('You must submit a valid result object'); - } - + } + $out = ''; - + // First generate the headings from the table column names foreach ($query->list_fields() as $name) { $out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $name).$enclosure.$delim; } - + $out = rtrim($out); $out .= $newline; - + // Next blast through the result array and build out the rows foreach ($query->result_array() as $row) { foreach ($row as $item) { - $out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $item).$enclosure.$delim; + $out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $item).$enclosure.$delim; } $out = rtrim($out); $out .= $newline; @@ -204,7 +229,7 @@ class CI_DB_utility extends CI_DB_forge { return $out; } - + // -------------------------------------------------------------------- /** @@ -221,7 +246,7 @@ class CI_DB_utility extends CI_DB_forge { { 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) { @@ -230,10 +255,10 @@ class CI_DB_utility extends CI_DB_forge { $params[$key] = $val; } } - + // Create variables for convenience extract($params); - + // Load the xml helper $CI =& get_instance(); $CI->load->helper('xml'); @@ -243,7 +268,7 @@ class CI_DB_utility extends CI_DB_forge { foreach ($query->result_array() as $row) { $xml .= $tab."<{$element}>".$newline; - + foreach ($row as $key => $val) { $xml .= $tab.$tab."<{$key}>".xml_convert($val)."</{$key}>".$newline; @@ -251,7 +276,7 @@ class CI_DB_utility extends CI_DB_forge { $xml .= $tab."</{$element}>".$newline; } $xml .= "</$root>".$newline; - + return $xml; } @@ -272,9 +297,9 @@ class CI_DB_utility extends CI_DB_forge { { $params = array('tables' => $params); } - + // ------------------------------------------------------ - + // Set up our default preferences $prefs = array( 'tables' => array(), @@ -300,13 +325,13 @@ class CI_DB_utility extends CI_DB_forge { // ------------------------------------------------------ - // Are we backing up a complete database or individual tables? + // 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 @@ -320,13 +345,13 @@ class CI_DB_utility extends CI_DB_forge { // Is the encoder supported? If not, we'll either issue an // error or use plain text depending on the debug settings if (($prefs['format'] == 'gzip' AND ! @function_exists('gzencode')) - OR ($prefs['format'] == 'zip' AND ! @function_exists('gzcompress'))) + OR ($prefs['format'] == 'zip' AND ! @function_exists('gzcompress'))) { if ($this->db->db_debug) { return $this->db->display_error('db_unsuported_compression'); } - + $prefs['format'] = 'txt'; } @@ -340,7 +365,7 @@ class CI_DB_utility extends CI_DB_forge { } // ------------------------------------------------------ - + // Was a Gzip file requested? if ($prefs['format'] == 'gzip') { @@ -348,7 +373,7 @@ class CI_DB_utility extends CI_DB_forge { } // ------------------------------------------------------ - + // Was a text file requested? if ($prefs['format'] == 'txt') { @@ -357,7 +382,7 @@ class CI_DB_utility extends CI_DB_forge { // ------------------------------------------------------ - // Was a Zip file requested? + // Was a Zip file requested? if ($prefs['format'] == 'zip') { // If they included the .zip file extension we'll remove it @@ -365,7 +390,7 @@ class CI_DB_utility extends CI_DB_forge { { $prefs['filename'] = str_replace('.zip', '', $prefs['filename']); } - + // Tack on the ".sql" file extension if needed if ( ! preg_match("|.+?\.sql$|", $prefs['filename'])) { @@ -373,13 +398,13 @@ class CI_DB_utility extends CI_DB_forge { } // Load the Zip class and output it - + $CI =& get_instance(); $CI->load->library('zip'); - $CI->zip->add_data($prefs['filename'], $this->_backup($prefs)); + $CI->zip->add_data($prefs['filename'], $this->_backup($prefs)); return $CI->zip->get_zip(); } - + } } diff --git a/system/database/drivers/index.html b/system/database/drivers/index.html index c942a79ce..c942a79ce 100644..100755 --- a/system/database/drivers/index.html +++ b/system/database/drivers/index.html diff --git a/system/database/drivers/mssql/index.html b/system/database/drivers/mssql/index.html index c942a79ce..c942a79ce 100644..100755 --- a/system/database/drivers/mssql/index.html +++ b/system/database/drivers/mssql/index.html diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php index f301ba533..5a69132cd 100644..100755 --- a/system/database/drivers/mssql/mssql_driver.php +++ b/system/database/drivers/mssql/mssql_driver.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -31,14 +31,14 @@ class CI_DB_mssql_driver extends CI_DB { var $dbdriver = 'mssql'; - + // The character used for escaping var $_escape_char = ''; // clause and character used for LIKE escape sequences var $_like_escape_str = " ESCAPE '%s' "; var $_like_escape_chr = '!'; - + /** * The syntax to count rows is slightly different across different * database engines, so this string appears in each driver and is @@ -52,7 +52,7 @@ class CI_DB_mssql_driver extends CI_DB { * * @access private called by the base class * @return resource - */ + */ function db_connect() { if ($this->port != '') @@ -62,7 +62,7 @@ class CI_DB_mssql_driver extends CI_DB { return @mssql_connect($this->hostname, $this->username, $this->password); } - + // -------------------------------------------------------------------- /** @@ -70,7 +70,7 @@ class CI_DB_mssql_driver extends CI_DB { * * @access private called by the base class * @return resource - */ + */ function db_pconnect() { if ($this->port != '') @@ -80,9 +80,9 @@ class CI_DB_mssql_driver extends CI_DB { return @mssql_pconnect($this->hostname, $this->username, $this->password); } - + // -------------------------------------------------------------------- - + /** * Reconnect * @@ -98,13 +98,13 @@ class CI_DB_mssql_driver extends CI_DB { } // -------------------------------------------------------------------- - + /** * Select the database * * @access private called by the base class * @return resource - */ + */ function db_select() { // Note: The brackets are required in the event that the DB name @@ -113,7 +113,7 @@ class CI_DB_mssql_driver extends CI_DB { } // -------------------------------------------------------------------- - + /** * Set client character set * @@ -129,20 +129,20 @@ class CI_DB_mssql_driver extends CI_DB { } // -------------------------------------------------------------------- - + /** * Execute the query * * @access private called by the base class * @param string an SQL query * @return resource - */ + */ function _execute($sql) { $sql = $this->_prep_query($sql); return @mssql_query($sql, $this->conn_id); } - + // -------------------------------------------------------------------- /** @@ -153,7 +153,7 @@ class CI_DB_mssql_driver extends CI_DB { * @access private called by execute() * @param string an SQL query * @return string - */ + */ function _prep_query($sql) { return $sql; @@ -165,15 +165,15 @@ class CI_DB_mssql_driver extends CI_DB { * Begin Transaction * * @access public - * @return bool - */ + * @return bool + */ function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { return TRUE; } - + // When transactions are nested we only begin/commit/rollback the outermost ones if ($this->_trans_depth > 0) { @@ -195,8 +195,8 @@ class CI_DB_mssql_driver extends CI_DB { * Commit Transaction * * @access public - * @return bool - */ + * @return bool + */ function trans_commit() { if ( ! $this->trans_enabled) @@ -220,8 +220,8 @@ class CI_DB_mssql_driver extends CI_DB { * Rollback Transaction * * @access public - * @return bool - */ + * @return bool + */ function trans_rollback() { if ( ! $this->trans_enabled) @@ -238,7 +238,7 @@ class CI_DB_mssql_driver extends CI_DB { $this->simple_query('ROLLBACK TRAN'); return TRUE; } - + // -------------------------------------------------------------------- /** @@ -254,19 +254,16 @@ class CI_DB_mssql_driver extends CI_DB { if (is_array($str)) { foreach($str as $key => $val) - { + { $str[$key] = $this->escape_str($val, $like); - } - - return $str; - } - - // Access the CI object - $CI =& get_instance(); - + } + + return $str; + } + // Escape single quotes - $str = str_replace("'", "''", $CI->input->_remove_invisible_characters($str)); - + $str = str_replace("'", "''", remove_invisible_characters($str)); + // escape LIKE condition wildcards if ($like === TRUE) { @@ -274,10 +271,10 @@ class CI_DB_mssql_driver extends CI_DB { array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr), $str); } - + return $str; } - + // -------------------------------------------------------------------- /** @@ -290,7 +287,7 @@ class CI_DB_mssql_driver extends CI_DB { { return @mssql_rows_affected($this->conn_id); } - + // -------------------------------------------------------------------- /** @@ -315,7 +312,7 @@ class CI_DB_mssql_driver extends CI_DB { /** * Parse major version * - * Grabs the major version number from the + * Grabs the major version number from the * database server version string passed in. * * @access private @@ -385,14 +382,14 @@ class CI_DB_mssql_driver extends CI_DB { function _list_tables($prefix_limit = FALSE) { $sql = "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name"; - + // for future compatibility if ($prefix_limit !== FALSE AND $this->dbprefix != '') { - //$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_char); + //$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); return FALSE; // not currently supported } - + return $sql; } @@ -409,7 +406,7 @@ class CI_DB_mssql_driver extends CI_DB { */ function _list_columns($table = '') { - return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$table."'"; + return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$table."'"; } // -------------------------------------------------------------------- @@ -425,7 +422,7 @@ class CI_DB_mssql_driver extends CI_DB { */ function _field_data($table) { - return "SELECT TOP 1 * FROM ".$table; + return "SELECT TOP 1 * FROM ".$table; } // -------------------------------------------------------------------- @@ -440,7 +437,7 @@ class CI_DB_mssql_driver extends CI_DB { { return mssql_get_last_message(); } - + // -------------------------------------------------------------------- /** @@ -477,26 +474,26 @@ class CI_DB_mssql_driver extends CI_DB { { if (strpos($item, '.'.$id) !== FALSE) { - $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item); - + $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item); + // remove duplicates if the user already included the escape return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); - } + } } if (strpos($item, '.') !== FALSE) { - $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char; + $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char; } else { $str = $this->_escape_char.$item.$this->_escape_char; } - + // remove duplicates if the user already included the escape return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); } - + // -------------------------------------------------------------------- /** @@ -515,12 +512,12 @@ class CI_DB_mssql_driver extends CI_DB { { $tables = array($tables); } - + return implode(', ', $tables); } // -------------------------------------------------------------------- - + /** * Insert statement * @@ -533,10 +530,10 @@ class CI_DB_mssql_driver extends CI_DB { * @return string */ function _insert($table, $keys, $values) - { + { return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; } - + // -------------------------------------------------------------------- /** @@ -558,21 +555,21 @@ class CI_DB_mssql_driver extends CI_DB { { $valstr[] = $key." = ".$val; } - + $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; - + $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):''; - + $sql = "UPDATE ".$table." SET ".implode(', ', $valstr); $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : ''; $sql .= $orderby.$limit; - + return $sql; } - + // -------------------------------------------------------------------- /** @@ -585,12 +582,12 @@ class CI_DB_mssql_driver extends CI_DB { * @access public * @param string the table name * @return string - */ + */ function _truncate($table) { return "TRUNCATE ".$table; } - + // -------------------------------------------------------------------- /** @@ -603,7 +600,7 @@ class CI_DB_mssql_driver extends CI_DB { * @param array the where clause * @param string the limit clause * @return string - */ + */ function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; @@ -621,7 +618,7 @@ class CI_DB_mssql_driver extends CI_DB { } $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; - + return "DELETE FROM ".$table.$conditions.$limit; } @@ -641,8 +638,8 @@ class CI_DB_mssql_driver extends CI_DB { function _limit($sql, $limit, $offset) { $i = $limit + $offset; - - return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$i.' ', $sql); + + return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$i.' ', $sql); } // -------------------------------------------------------------------- @@ -657,7 +654,7 @@ class CI_DB_mssql_driver extends CI_DB { function _close($conn_id) { @mssql_close($conn_id); - } + } } diff --git a/system/database/drivers/mssql/mssql_forge.php b/system/database/drivers/mssql/mssql_forge.php index f6a17811f..70b20ecf8 100644..100755 --- a/system/database/drivers/mssql/mssql_forge.php +++ b/system/database/drivers/mssql/mssql_forge.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -79,12 +79,12 @@ class CI_DB_mssql_forge extends CI_DB_forge { function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; - + if ($if_not_exists === TRUE) { $sql .= 'IF NOT EXISTS '; } - + $sql .= $this->db->_escape_identifiers($table)." ("; $current_field_count = 0; @@ -100,41 +100,41 @@ class CI_DB_mssql_forge extends CI_DB_forge { else { $attributes = array_change_key_case($attributes, CASE_UPPER); - + $sql .= "\n\t".$this->db->_protect_identifiers($field); - + $sql .= ' '.$attributes['TYPE']; - + if (array_key_exists('CONSTRAINT', $attributes)) { $sql .= '('.$attributes['CONSTRAINT'].')'; } - + if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE) { $sql .= ' UNSIGNED'; } - + if (array_key_exists('DEFAULT', $attributes)) { $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\''; } - + if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE) { $sql .= ' NULL'; } else { - $sql .= ' NOT NULL'; + $sql .= ' NOT NULL'; } - + if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE) { $sql .= ' AUTO_INCREMENT'; } } - + // don't add a comma on the end of the last field if (++$current_field_count < count($fields)) { @@ -147,24 +147,24 @@ class CI_DB_mssql_forge extends CI_DB_forge { $primary_keys = $this->db->_protect_identifiers($primary_keys); $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")"; } - + if (is_array($keys) && count($keys) > 0) { foreach ($keys as $key) { if (is_array($key)) { - $key = $this->db->_protect_identifiers($key); + $key = $this->db->_protect_identifiers($key); } else { $key = array($this->db->_protect_identifiers($key)); } - + $sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")"; } } - + $sql .= "\n)"; return $sql; @@ -218,9 +218,9 @@ class CI_DB_mssql_forge extends CI_DB_forge { { $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field); } - + return $sql; - + } // -------------------------------------------------------------------- diff --git a/system/database/drivers/mssql/mssql_result.php b/system/database/drivers/mssql/mssql_result.php index e7b338045..2897ca5a5 100644..100755 --- a/system/database/drivers/mssql/mssql_result.php +++ b/system/database/drivers/mssql/mssql_result.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -25,7 +25,7 @@ * @link http://codeigniter.com/user_guide/database/ */ class CI_DB_mssql_result extends CI_DB_result { - + /** * Number of rows in the result set * @@ -36,7 +36,7 @@ class CI_DB_mssql_result extends CI_DB_result { { return @mssql_num_rows($this->result_id); } - + // -------------------------------------------------------------------- /** @@ -67,7 +67,7 @@ class CI_DB_mssql_result extends CI_DB_result { { $field_names[] = $field->name; } - + return $field_names; } @@ -85,17 +85,17 @@ class CI_DB_mssql_result extends CI_DB_result { { $retval = array(); while ($field = mssql_fetch_field($this->result_id)) - { - $F = new stdClass(); - $F->name = $field->name; - $F->type = $field->type; + { + $F = new stdClass(); + $F->name = $field->name; + $F->type = $field->type; $F->max_length = $field->max_length; $F->primary_key = 0; $F->default = ''; - + $retval[] = $F; } - + return $retval; } @@ -105,7 +105,7 @@ class CI_DB_mssql_result extends CI_DB_result { * Free the result * * @return null - */ + */ function free_result() { if (is_resource($this->result_id)) @@ -131,7 +131,7 @@ class CI_DB_mssql_result extends CI_DB_result { { return mssql_data_seek($this->result_id, $n); } - + // -------------------------------------------------------------------- /** @@ -146,7 +146,7 @@ class CI_DB_mssql_result extends CI_DB_result { { return mssql_fetch_assoc($this->result_id); } - + // -------------------------------------------------------------------- /** diff --git a/system/database/drivers/mssql/mssql_utility.php b/system/database/drivers/mssql/mssql_utility.php index da887b815..48ecbc72a 100644..100755 --- a/system/database/drivers/mssql/mssql_utility.php +++ b/system/database/drivers/mssql/mssql_utility.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -52,7 +52,7 @@ class CI_DB_mssql_utility extends CI_DB_utility { } // -------------------------------------------------------------------- - + /** * Repair table query * @@ -82,42 +82,7 @@ class CI_DB_mssql_utility extends CI_DB_utility { return $this->db->display_error('db_unsuported_feature'); } - /** - * - * The functions below have been deprecated as of 1.6, and are only here for backwards - * compatibility. They now reside in dbforge(). The use of dbutils for database manipulation - * is STRONGLY discouraged in favour if using dbforge. - * - */ - - /** - * Create database - * - * @access private - * @param string the database name - * @return bool - */ - function _create_database($name) - { - return "CREATE DATABASE ".$name; - } - - // -------------------------------------------------------------------- - - /** - * Drop database - * - * @access private - * @param string the database name - * @return bool - */ - function _drop_database($name) - { - return "DROP DATABASE ".$name; - } - } - /* End of file mssql_utility.php */ /* Location: ./system/database/drivers/mssql/mssql_utility.php */
\ No newline at end of file diff --git a/system/database/drivers/mysql/index.html b/system/database/drivers/mysql/index.html index c942a79ce..c942a79ce 100644..100755 --- a/system/database/drivers/mysql/index.html +++ b/system/database/drivers/mysql/index.html diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index 85a6ef4a0..df18c912e 100644..100755 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -43,9 +43,9 @@ class CI_DB_mysql_driver extends CI_DB { * Whether to use the MySQL "delete hack" which allows the number * of affected rows to be shown. Uses a preg_replace when enabled, * adding a bit more processing to all queries. - */ + */ var $delete_hack = TRUE; - + /** * The syntax to count rows is slightly different across different * database engines, so this string appears in each driver and is @@ -59,17 +59,17 @@ class CI_DB_mysql_driver extends CI_DB { * * @access private called by the base class * @return resource - */ + */ function db_connect() { if ($this->port != '') { $this->hostname .= ':'.$this->port; } - + return @mysql_connect($this->hostname, $this->username, $this->password, TRUE); } - + // -------------------------------------------------------------------- /** @@ -77,7 +77,7 @@ class CI_DB_mysql_driver extends CI_DB { * * @access private called by the base class * @return resource - */ + */ function db_pconnect() { if ($this->port != '') @@ -87,7 +87,7 @@ class CI_DB_mysql_driver extends CI_DB { return @mysql_pconnect($this->hostname, $this->username, $this->password); } - + // -------------------------------------------------------------------- /** @@ -108,13 +108,13 @@ class CI_DB_mysql_driver extends CI_DB { } // -------------------------------------------------------------------- - + /** * Select the database * * @access private called by the base class * @return resource - */ + */ function db_select() { return @mysql_select_db($this->database, $this->conn_id); @@ -136,7 +136,7 @@ class CI_DB_mysql_driver extends CI_DB { } // -------------------------------------------------------------------- - + /** * Version number query string * @@ -156,13 +156,13 @@ class CI_DB_mysql_driver extends CI_DB { * @access private called by the base class * @param string an SQL query * @return resource - */ + */ function _execute($sql) { $sql = $this->_prep_query($sql); return @mysql_query($sql, $this->conn_id); } - + // -------------------------------------------------------------------- /** @@ -173,7 +173,7 @@ class CI_DB_mysql_driver extends CI_DB { * @access private called by execute() * @param string an SQL query * @return string - */ + */ function _prep_query($sql) { // "DELETE FROM TABLE" returns 0 affected rows This hack modifies @@ -185,7 +185,7 @@ class CI_DB_mysql_driver extends CI_DB { $sql = preg_replace("/^\s*DELETE\s+FROM\s+(\S+)\s*$/", "DELETE FROM \\1 WHERE 1=1", $sql); } } - + return $sql; } @@ -195,15 +195,15 @@ class CI_DB_mysql_driver extends CI_DB { * Begin Transaction * * @access public - * @return bool - */ + * @return bool + */ function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { return TRUE; } - + // When transactions are nested we only begin/commit/rollback the outermost ones if ($this->_trans_depth > 0) { @@ -214,7 +214,7 @@ class CI_DB_mysql_driver extends CI_DB { // If the $test_mode flag is set to TRUE transactions will be rolled back // even if the queries produce a successful result. $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE; - + $this->simple_query('SET AUTOCOMMIT=0'); $this->simple_query('START TRANSACTION'); // can also be BEGIN or BEGIN WORK return TRUE; @@ -226,8 +226,8 @@ class CI_DB_mysql_driver extends CI_DB { * Commit Transaction * * @access public - * @return bool - */ + * @return bool + */ function trans_commit() { if ( ! $this->trans_enabled) @@ -252,8 +252,8 @@ class CI_DB_mysql_driver extends CI_DB { * Rollback Transaction * * @access public - * @return bool - */ + * @return bool + */ function trans_rollback() { if ( ! $this->trans_enabled) @@ -271,7 +271,7 @@ class CI_DB_mysql_driver extends CI_DB { $this->simple_query('SET AUTOCOMMIT=1'); return TRUE; } - + // -------------------------------------------------------------------- /** @@ -282,17 +282,17 @@ class CI_DB_mysql_driver extends CI_DB { * @param bool whether or not the string will be used in a LIKE condition * @return string */ - function escape_str($str, $like = FALSE) - { + function escape_str($str, $like = FALSE) + { if (is_array($str)) { foreach($str as $key => $val) - { + { $str[$key] = $this->escape_str($val, $like); - } - - return $str; - } + } + + return $str; + } if (function_exists('mysql_real_escape_string') AND is_resource($this->conn_id)) { @@ -306,16 +306,16 @@ class CI_DB_mysql_driver extends CI_DB { { $str = addslashes($str); } - + // escape LIKE condition wildcards if ($like === TRUE) { $str = str_replace(array('%', '_'), array('\\%', '\\_'), $str); } - + return $str; } - + // -------------------------------------------------------------------- /** @@ -328,7 +328,7 @@ class CI_DB_mysql_driver extends CI_DB { { return @mysql_affected_rows($this->conn_id); } - + // -------------------------------------------------------------------- /** @@ -360,7 +360,7 @@ class CI_DB_mysql_driver extends CI_DB { { return 0; } - + $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE)); if ($query->num_rows() == 0) @@ -385,7 +385,7 @@ class CI_DB_mysql_driver extends CI_DB { */ function _list_tables($prefix_limit = FALSE) { - $sql = "SHOW TABLES FROM ".$this->_escape_char.$this->database.$this->_escape_char; + $sql = "SHOW TABLES FROM ".$this->_escape_char.$this->database.$this->_escape_char; if ($prefix_limit !== FALSE AND $this->dbprefix != '') { @@ -394,7 +394,7 @@ class CI_DB_mysql_driver extends CI_DB { return $sql; } - + // -------------------------------------------------------------------- /** @@ -408,7 +408,7 @@ class CI_DB_mysql_driver extends CI_DB { */ function _list_columns($table = '') { - return "SHOW COLUMNS FROM ".$table; + return "SHOW COLUMNS FROM ".$this->_protect_identifiers($table, TRUE, NULL, FALSE); } // -------------------------------------------------------------------- @@ -439,7 +439,7 @@ class CI_DB_mysql_driver extends CI_DB { { return mysql_error($this->conn_id); } - + // -------------------------------------------------------------------- /** @@ -475,26 +475,26 @@ class CI_DB_mysql_driver extends CI_DB { { if (strpos($item, '.'.$id) !== FALSE) { - $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item); - + $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item); + // remove duplicates if the user already included the escape return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); - } + } } - + if (strpos($item, '.') !== FALSE) { - $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char; + $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char; } else { $str = $this->_escape_char.$item.$this->_escape_char; } - + // remove duplicates if the user already included the escape return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); } - + // -------------------------------------------------------------------- /** @@ -513,12 +513,12 @@ class CI_DB_mysql_driver extends CI_DB { { $tables = array($tables); } - + return '('.implode(', ', $tables).')'; } // -------------------------------------------------------------------- - + /** * Insert statement * @@ -531,12 +531,50 @@ class CI_DB_mysql_driver extends CI_DB { * @return string */ function _insert($table, $keys, $values) - { + { return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; } - + // -------------------------------------------------------------------- + + /** + * Replace statement + * + * Generates a platform-specific replace string from the supplied data + * + * @access public + * @param string the table name + * @param array the insert keys + * @param array the insert values + * @return string + */ + function _replace($table, $keys, $values) + { + return "REPLACE INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; + } + + // -------------------------------------------------------------------- + + /** + * Insert_batch statement + * + * Generates a platform-specific insert string from the supplied data + * + * @access public + * @param string the table name + * @param array the insert keys + * @param array the insert values + * @return string + */ + function _insert_batch($table, $keys, $values) + { + return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES ".implode(', ', $values); + } + + // -------------------------------------------------------------------- + + /** * Update statement * @@ -556,22 +594,76 @@ class CI_DB_mysql_driver extends CI_DB { { $valstr[] = $key." = ".$val; } - + $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; - + $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):''; - + $sql = "UPDATE ".$table." SET ".implode(', ', $valstr); $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : ''; $sql .= $orderby.$limit; - + + return $sql; + } + + // -------------------------------------------------------------------- + + + /** + * Update_Batch statement + * + * Generates a platform-specific batch update string from the supplied data + * + * @access public + * @param string the table name + * @param array the update data + * @param array the where clause + * @return string + */ + function _update_batch($table, $values, $index, $where = NULL) + { + $ids = array(); + $where = ($where != '' AND count($where) >=1) ? implode(" ", $where).' AND ' : ''; + + foreach($values as $key => $val) + { + $ids[] = $val[$index]; + + foreach(array_keys($val) as $field) + { + if ($field != $index) + { + $final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field]; + } + } + } + + $sql = "UPDATE ".$table." SET "; + $cases = ''; + + foreach($final as $k => $v) + { + $cases .= $k.' = CASE '."\n"; + foreach ($v as $row) + { + $cases .= $row."\n"; + } + + $cases .= 'ELSE '.$k.' END, '; + } + + $sql .= substr($cases, 0, -2); + + $sql .= ' WHERE '.$where.$index.' IN ('.implode(',', $ids).')'; + return $sql; } // -------------------------------------------------------------------- + /** * Truncate statement * @@ -582,12 +674,12 @@ class CI_DB_mysql_driver extends CI_DB { * @access public * @param string the table name * @return string - */ + */ function _truncate($table) { return "TRUNCATE ".$table; } - + // -------------------------------------------------------------------- /** @@ -600,7 +692,7 @@ class CI_DB_mysql_driver extends CI_DB { * @param array the where clause * @param string the limit clause * @return string - */ + */ function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; @@ -618,7 +710,7 @@ class CI_DB_mysql_driver extends CI_DB { } $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; - + return "DELETE FROM ".$table.$conditions.$limit; } @@ -636,7 +728,7 @@ class CI_DB_mysql_driver extends CI_DB { * @return string */ function _limit($sql, $limit, $offset) - { + { if ($offset == 0) { $offset = ''; @@ -645,7 +737,7 @@ class CI_DB_mysql_driver extends CI_DB { { $offset .= ", "; } - + return $sql."LIMIT ".$offset.$limit; } @@ -662,7 +754,7 @@ class CI_DB_mysql_driver extends CI_DB { { @mysql_close($conn_id); } - + } diff --git a/system/database/drivers/mysql/mysql_forge.php b/system/database/drivers/mysql/mysql_forge.php index ccacf99f8..529ec980d 100644..100755 --- a/system/database/drivers/mysql/mysql_forge.php +++ b/system/database/drivers/mysql/mysql_forge.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -23,7 +23,7 @@ * @link http://codeigniter.com/user_guide/database/ */ class CI_DB_mysql_forge extends CI_DB_forge { - + /** * Create database * @@ -76,52 +76,67 @@ class CI_DB_mysql_forge extends CI_DB_forge { else { $attributes = array_change_key_case($attributes, CASE_UPPER); - + $sql .= "\n\t".$this->db->_protect_identifiers($field); if (array_key_exists('NAME', $attributes)) { $sql .= ' '.$this->db->_protect_identifiers($attributes['NAME']).' '; } - + if (array_key_exists('TYPE', $attributes)) { $sql .= ' '.$attributes['TYPE']; + + if (array_key_exists('CONSTRAINT', $attributes)) + { + switch ($attributes['TYPE']) + { + case 'decimal': + case 'float': + case 'numeric': + $sql .= '('.implode(',', $attributes['CONSTRAINT']).')'; + break; + + case 'enum': + case 'set': + $sql .= '("'.implode('","', $attributes['CONSTRAINT']).'")'; + break; + + default: + $sql .= '('.$attributes['CONSTRAINT'].')'; + } + } } - - if (array_key_exists('CONSTRAINT', $attributes)) - { - $sql .= '('.$attributes['CONSTRAINT'].')'; - } - + if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE) { $sql .= ' UNSIGNED'; } - + if (array_key_exists('DEFAULT', $attributes)) { $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\''; } - + if (array_key_exists('NULL', $attributes)) { $sql .= ($attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL'; } - + if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE) { $sql .= ' AUTO_INCREMENT'; } } - + // don't add a comma on the end of the last field if (++$current_field_count < count($fields)) { $sql .= ','; } } - + return $sql; } @@ -141,12 +156,12 @@ class CI_DB_mysql_forge extends CI_DB_forge { function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; - + if ($if_not_exists === TRUE) { $sql .= 'IF NOT EXISTS '; } - + $sql .= $this->db->_escape_identifiers($table)." ("; $sql .= $this->_process_fields($fields); @@ -165,14 +180,14 @@ class CI_DB_mysql_forge extends CI_DB_forge { if (is_array($key)) { $key_name = $this->db->_protect_identifiers(implode('_', $key)); - $key = $this->db->_protect_identifiers($key); + $key = $this->db->_protect_identifiers($key); } else { $key_name = $this->db->_protect_identifiers($key); $key = array($key_name); } - + $sql .= ",\n\tKEY {$key_name} (" . implode(', ', $key) . ")"; } } @@ -226,7 +241,7 @@ class CI_DB_mysql_forge extends CI_DB_forge { { $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field); } - + return $sql; } diff --git a/system/database/drivers/mysql/mysql_result.php b/system/database/drivers/mysql/mysql_result.php index acc586626..507389603 100644..100755 --- a/system/database/drivers/mysql/mysql_result.php +++ b/system/database/drivers/mysql/mysql_result.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -36,7 +36,7 @@ class CI_DB_mysql_result extends CI_DB_result { { return @mysql_num_rows($this->result_id); } - + // -------------------------------------------------------------------- /** @@ -49,7 +49,7 @@ class CI_DB_mysql_result extends CI_DB_result { { return @mysql_num_fields($this->result_id); } - + // -------------------------------------------------------------------- /** @@ -67,7 +67,7 @@ class CI_DB_mysql_result extends CI_DB_result { { $field_names[] = $field->name; } - + return $field_names; } @@ -85,27 +85,27 @@ class CI_DB_mysql_result extends CI_DB_result { { $retval = array(); while ($field = mysql_fetch_field($this->result_id)) - { + { $F = new stdClass(); - $F->name = $field->name; - $F->type = $field->type; + $F->name = $field->name; + $F->type = $field->type; $F->default = $field->def; $F->max_length = $field->max_length; $F->primary_key = $field->primary_key; - + $retval[] = $F; } - + return $retval; } - + // -------------------------------------------------------------------- /** * Free the result * * @return null - */ + */ function free_result() { if (is_resource($this->result_id)) @@ -146,7 +146,7 @@ class CI_DB_mysql_result extends CI_DB_result { { return mysql_fetch_assoc($this->result_id); } - + // -------------------------------------------------------------------- /** @@ -161,7 +161,7 @@ class CI_DB_mysql_result extends CI_DB_result { { return mysql_fetch_object($this->result_id); } - + } diff --git a/system/database/drivers/mysql/mysql_utility.php b/system/database/drivers/mysql/mysql_utility.php index 3277b0ff7..e9747c540 100644..100755 --- a/system/database/drivers/mysql/mysql_utility.php +++ b/system/database/drivers/mysql/mysql_utility.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -84,7 +84,7 @@ class CI_DB_mysql_utility extends CI_DB_utility { // Extract the prefs for simplicity extract($params); - + // Build the output $output = ''; foreach ((array)$tables as $table) @@ -97,31 +97,31 @@ class CI_DB_mysql_utility extends CI_DB_utility { // Get the table schema $query = $this->db->query("SHOW CREATE TABLE `".$this->db->database.'`.'.$table); - + // No result means the table name was invalid if ($query === FALSE) { continue; } - + // Write out the table schema $output .= '#'.$newline.'# TABLE STRUCTURE FOR: '.$table.$newline.'#'.$newline.$newline; - if ($add_drop == TRUE) - { + if ($add_drop == TRUE) + { $output .= 'DROP TABLE IF EXISTS '.$table.';'.$newline.$newline; } - + $i = 0; $result = $query->result_array(); foreach ($result[0] as $val) { if ($i++ % 2) - { + { $output .= $val.';'.$newline.$newline; } } - + // If inserts are not needed we're done... if ($add_insert == FALSE) { @@ -130,16 +130,16 @@ class CI_DB_mysql_utility extends CI_DB_utility { // Grab all the data from the current table $query = $this->db->query("SELECT * FROM $table"); - + if ($query->num_rows() == 0) { continue; } - + // Fetch the field names and determine if the field is an // integer type. We use this info to decide whether to // surround the data with quotes or not - + $i = 0; $field_str = ''; $is_int = array(); @@ -148,24 +148,24 @@ class CI_DB_mysql_utility extends CI_DB_utility { // Most versions of MySQL store timestamp as a string $is_int[$i] = (in_array( strtolower(mysql_field_type($query->result_id, $i)), - array('tinyint', 'smallint', 'mediumint', 'int', 'bigint'), //, 'timestamp'), + array('tinyint', 'smallint', 'mediumint', 'int', 'bigint'), //, 'timestamp'), TRUE) ) ? TRUE : FALSE; - + // Create a string of field names $field_str .= '`'.$field->name.'`, '; $i++; } - + // Trim off the end comma $field_str = preg_replace( "/, $/" , "" , $field_str); - - + + // Build the insert string foreach ($query->result_array() as $row) { $val_str = ''; - + $i = 0; foreach ($row as $v) { @@ -184,61 +184,26 @@ class CI_DB_mysql_utility extends CI_DB_utility { else { $val_str .= $v; - } - } - + } + } + // Append a comma $val_str .= ', '; $i++; } - + // Remove the comma at the end of the string $val_str = preg_replace( "/, $/" , "" , $val_str); - + // Build the INSERT string $output .= 'INSERT INTO '.$table.' ('.$field_str.') VALUES ('.$val_str.');'.$newline; } - + $output .= $newline.$newline; } return $output; } - - /** - * - * The functions below have been deprecated as of 1.6, and are only here for backwards - * compatibility. They now reside in dbforge(). The use of dbutils for database manipulation - * is STRONGLY discouraged in favour if using dbforge. - * - */ - - /** - * Create database - * - * @access private - * @param string the database name - * @return bool - */ - function _create_database($name) - { - return "CREATE DATABASE ".$name; - } - - // -------------------------------------------------------------------- - - /** - * Drop database - * - * @access private - * @param string the database name - * @return bool - */ - function _drop_database($name) - { - return "DROP DATABASE ".$name; - } - } /* End of file mysql_utility.php */ diff --git a/system/database/drivers/mysqli/index.html b/system/database/drivers/mysqli/index.html index c942a79ce..c942a79ce 100644..100755 --- a/system/database/drivers/mysqli/index.html +++ b/system/database/drivers/mysqli/index.html diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index 5d7200fbd..8942100d4 100644..100755 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -31,7 +31,7 @@ class CI_DB_mysqli_driver extends CI_DB { var $dbdriver = 'mysqli'; - + // The character used for escaping var $_escape_char = '`'; @@ -51,7 +51,7 @@ class CI_DB_mysqli_driver extends CI_DB { * Whether to use the MySQL "delete hack" which allows the number * of affected rows to be shown. Uses a preg_replace when enabled, * adding a bit more processing to all queries. - */ + */ var $delete_hack = TRUE; // -------------------------------------------------------------------- @@ -61,12 +61,12 @@ class CI_DB_mysqli_driver extends CI_DB { * * @access private called by the base class * @return resource - */ + */ function db_connect() { if ($this->port != '') { - return @mysqli_connect($this->hostname, $this->username, $this->password, $this->database, $this->port); + return @mysqli_connect($this->hostname, $this->username, $this->password, $this->database, $this->port); } else { @@ -82,12 +82,12 @@ class CI_DB_mysqli_driver extends CI_DB { * * @access private called by the base class * @return resource - */ + */ function db_pconnect() { return $this->db_connect(); } - + // -------------------------------------------------------------------- /** @@ -114,7 +114,7 @@ class CI_DB_mysqli_driver extends CI_DB { * * @access private called by the base class * @return resource - */ + */ function db_select() { return @mysqli_select_db($this->conn_id, $this->database); @@ -136,7 +136,7 @@ class CI_DB_mysqli_driver extends CI_DB { } // -------------------------------------------------------------------- - + /** * Version number query string * @@ -156,14 +156,14 @@ class CI_DB_mysqli_driver extends CI_DB { * @access private called by the base class * @param string an SQL query * @return resource - */ + */ function _execute($sql) { - $sql = $this->_prep_query($sql); + $sql = $this->_prep_query($sql); $result = @mysqli_query($this->conn_id, $sql); return $result; } - + // -------------------------------------------------------------------- /** @@ -174,7 +174,7 @@ class CI_DB_mysqli_driver extends CI_DB { * @access private called by execute() * @param string an SQL query * @return string - */ + */ function _prep_query($sql) { // "DELETE FROM TABLE" returns 0 affected rows This hack modifies @@ -186,7 +186,7 @@ class CI_DB_mysqli_driver extends CI_DB { $sql = preg_replace("/^\s*DELETE\s+FROM\s+(\S+)\s*$/", "DELETE FROM \\1 WHERE 1=1", $sql); } } - + return $sql; } @@ -196,15 +196,15 @@ class CI_DB_mysqli_driver extends CI_DB { * Begin Transaction * * @access public - * @return bool - */ + * @return bool + */ function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { return TRUE; } - + // When transactions are nested we only begin/commit/rollback the outermost ones if ($this->_trans_depth > 0) { @@ -227,8 +227,8 @@ class CI_DB_mysqli_driver extends CI_DB { * Commit Transaction * * @access public - * @return bool - */ + * @return bool + */ function trans_commit() { if ( ! $this->trans_enabled) @@ -253,8 +253,8 @@ class CI_DB_mysqli_driver extends CI_DB { * Rollback Transaction * * @access public - * @return bool - */ + * @return bool + */ function trans_rollback() { if ( ! $this->trans_enabled) @@ -283,17 +283,17 @@ class CI_DB_mysqli_driver extends CI_DB { * @param bool whether or not the string will be used in a LIKE condition * @return string */ - function escape_str($str, $like = FALSE) + function escape_str($str, $like = FALSE) { if (is_array($str)) { foreach($str as $key => $val) - { + { $str[$key] = $this->escape_str($val, $like); - } - - return $str; - } + } + + return $str; + } if (function_exists('mysqli_real_escape_string') AND is_object($this->conn_id)) { @@ -307,16 +307,16 @@ class CI_DB_mysqli_driver extends CI_DB { { $str = addslashes($str); } - + // escape LIKE condition wildcards if ($like === TRUE) { $str = str_replace(array('%', '_'), array('\\%', '\\_'), $str); } - + return $str; } - + // -------------------------------------------------------------------- /** @@ -329,7 +329,7 @@ class CI_DB_mysqli_driver extends CI_DB { { return @mysqli_affected_rows($this->conn_id); } - + // -------------------------------------------------------------------- /** @@ -386,13 +386,13 @@ class CI_DB_mysqli_driver extends CI_DB { */ function _list_tables($prefix_limit = FALSE) { - $sql = "SHOW TABLES FROM ".$this->_escape_char.$this->database.$this->_escape_char; - + $sql = "SHOW TABLES FROM ".$this->_escape_char.$this->database.$this->_escape_char; + if ($prefix_limit !== FALSE AND $this->dbprefix != '') { $sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%'"; } - + return $sql; } @@ -409,7 +409,7 @@ class CI_DB_mysqli_driver extends CI_DB { */ function _list_columns($table = '') { - return "SHOW COLUMNS FROM ".$table; + return "SHOW COLUMNS FROM ".$this->_protect_identifiers($table, TRUE, NULL, FALSE); } // -------------------------------------------------------------------- @@ -440,7 +440,7 @@ class CI_DB_mysqli_driver extends CI_DB { { return mysqli_error($this->conn_id); } - + // -------------------------------------------------------------------- /** @@ -471,31 +471,31 @@ class CI_DB_mysqli_driver extends CI_DB { { return $item; } - + foreach ($this->_reserved_identifiers as $id) { if (strpos($item, '.'.$id) !== FALSE) { - $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item); - + $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item); + // remove duplicates if the user already included the escape return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); - } + } } - + if (strpos($item, '.') !== FALSE) { - $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char; + $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char; } else { $str = $this->_escape_char.$item.$this->_escape_char; } - + // remove duplicates if the user already included the escape return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); } - + // -------------------------------------------------------------------- /** @@ -514,12 +514,12 @@ class CI_DB_mysqli_driver extends CI_DB { { $tables = array($tables); } - + return '('.implode(', ', $tables).')'; } // -------------------------------------------------------------------- - + /** * Insert statement * @@ -532,9 +532,27 @@ class CI_DB_mysqli_driver extends CI_DB { * @return string */ function _insert($table, $keys, $values) - { + { return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; } + + // -------------------------------------------------------------------- + + /** + * Insert_batch statement + * + * Generates a platform-specific insert string from the supplied data + * + * @access public + * @param string the table name + * @param array the insert keys + * @param array the insert values + * @return string + */ + function _insert_batch($table, $keys, $values) + { + return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES ".implode(', ', $values); + } // -------------------------------------------------------------------- @@ -557,21 +575,72 @@ class CI_DB_mysqli_driver extends CI_DB { { $valstr[] = $key." = ".$val; } - + $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; - + $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):''; - + $sql = "UPDATE ".$table." SET ".implode(', ', $valstr); - + $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : ''; - + $sql .= $orderby.$limit; - + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Update_Batch statement + * + * Generates a platform-specific batch update string from the supplied data + * + * @access public + * @param string the table name + * @param array the update data + * @param array the where clause + * @return string + */ + function _update_batch($table, $values, $index, $where = NULL) + { + $ids = array(); + $where = ($where != '' AND count($where) >=1) ? implode(" ", $where).' AND ' : ''; + + foreach($values as $key => $val) + { + $ids[] = $val[$index]; + + foreach(array_keys($val) as $field) + { + if ($field != $index) + { + $final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field]; + } + } + } + + $sql = "UPDATE ".$table." SET "; + $cases = ''; + + foreach($final as $k => $v) + { + $cases .= $k.' = CASE '."\n"; + foreach ($v as $row) + { + $cases .= $row."\n"; + } + + $cases .= 'ELSE '.$k.' END, '; + } + + $sql .= substr($cases, 0, -2); + + $sql .= ' WHERE '.$where.$index.' IN ('.implode(',', $ids).')'; + return $sql; } - // -------------------------------------------------------------------- /** @@ -584,12 +653,12 @@ class CI_DB_mysqli_driver extends CI_DB { * @access public * @param string the table name * @return string - */ + */ function _truncate($table) { return "TRUNCATE ".$table; } - + // -------------------------------------------------------------------- /** @@ -602,7 +671,7 @@ class CI_DB_mysqli_driver extends CI_DB { * @param array the where clause * @param string the limit clause * @return string - */ + */ function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; @@ -620,7 +689,7 @@ class CI_DB_mysqli_driver extends CI_DB { } $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; - + return "DELETE FROM ".$table.$conditions.$limit; } @@ -638,14 +707,14 @@ class CI_DB_mysqli_driver extends CI_DB { * @return string */ function _limit($sql, $limit, $offset) - { + { $sql .= "LIMIT ".$limit; - + if ($offset > 0) { $sql .= " OFFSET ".$offset; } - + return $sql; } diff --git a/system/database/drivers/mysqli/mysqli_forge.php b/system/database/drivers/mysqli/mysqli_forge.php index 262d491ed..d5097335e 100644..100755 --- a/system/database/drivers/mysqli/mysqli_forge.php +++ b/system/database/drivers/mysqli/mysqli_forge.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -23,7 +23,7 @@ * @link http://codeigniter.com/user_guide/database/ */ class CI_DB_mysqli_forge extends CI_DB_forge { - + /** * Create database * @@ -76,52 +76,52 @@ class CI_DB_mysqli_forge extends CI_DB_forge { else { $attributes = array_change_key_case($attributes, CASE_UPPER); - + $sql .= "\n\t".$this->db->_protect_identifiers($field); if (array_key_exists('NAME', $attributes)) { $sql .= ' '.$this->db->_protect_identifiers($attributes['NAME']).' '; } - + if (array_key_exists('TYPE', $attributes)) { $sql .= ' '.$attributes['TYPE']; } - + if (array_key_exists('CONSTRAINT', $attributes)) { $sql .= '('.$attributes['CONSTRAINT'].')'; } - + if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE) { $sql .= ' UNSIGNED'; } - + if (array_key_exists('DEFAULT', $attributes)) { $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\''; } - + if (array_key_exists('NULL', $attributes)) { $sql .= ($attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL'; } - + if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE) { $sql .= ' AUTO_INCREMENT'; } } - + // don't add a comma on the end of the last field if (++$current_field_count < count($fields)) { $sql .= ','; } } - + return $sql; } @@ -141,12 +141,12 @@ class CI_DB_mysqli_forge extends CI_DB_forge { function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; - + if ($if_not_exists === TRUE) { $sql .= 'IF NOT EXISTS '; } - + $sql .= $this->db->_escape_identifiers($table)." ("; $sql .= $this->_process_fields($fields); @@ -165,14 +165,14 @@ class CI_DB_mysqli_forge extends CI_DB_forge { if (is_array($key)) { $key_name = $this->db->_protect_identifiers(implode('_', $key)); - $key = $this->db->_protect_identifiers($key); + $key = $this->db->_protect_identifiers($key); } else { $key_name = $this->db->_protect_identifiers($key); $key = array($key_name); } - + $sql .= ",\n\tKEY {$key_name} (" . implode(', ', $key) . ")"; } } @@ -226,7 +226,7 @@ class CI_DB_mysqli_forge extends CI_DB_forge { { $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field); } - + return $sql; } diff --git a/system/database/drivers/mysqli/mysqli_result.php b/system/database/drivers/mysqli/mysqli_result.php index 81d22cc9c..c4d8f5d58 100644..100755 --- a/system/database/drivers/mysqli/mysqli_result.php +++ b/system/database/drivers/mysqli/mysqli_result.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -25,7 +25,7 @@ * @link http://codeigniter.com/user_guide/database/ */ class CI_DB_mysqli_result extends CI_DB_result { - + /** * Number of rows in the result set * @@ -36,7 +36,7 @@ class CI_DB_mysqli_result extends CI_DB_result { { return @mysqli_num_rows($this->result_id); } - + // -------------------------------------------------------------------- /** @@ -67,7 +67,7 @@ class CI_DB_mysqli_result extends CI_DB_result { { $field_names[] = $field->name; } - + return $field_names; } @@ -85,17 +85,17 @@ class CI_DB_mysqli_result extends CI_DB_result { { $retval = array(); while ($field = mysqli_fetch_field($this->result_id)) - { - $F = new stdClass(); - $F->name = $field->name; - $F->type = $field->type; + { + $F = new stdClass(); + $F->name = $field->name; + $F->type = $field->type; $F->default = $field->def; $F->max_length = $field->max_length; $F->primary_key = ($field->flags & MYSQLI_PRI_KEY_FLAG) ? 1 : 0; - + $retval[] = $F; } - + return $retval; } @@ -105,7 +105,7 @@ class CI_DB_mysqli_result extends CI_DB_result { * Free the result * * @return null - */ + */ function free_result() { if (is_object($this->result_id)) @@ -146,7 +146,7 @@ class CI_DB_mysqli_result extends CI_DB_result { { return mysqli_fetch_assoc($this->result_id); } - + // -------------------------------------------------------------------- /** @@ -161,7 +161,7 @@ class CI_DB_mysqli_result extends CI_DB_result { { return mysqli_fetch_object($this->result_id); } - + } diff --git a/system/database/drivers/mysqli/mysqli_utility.php b/system/database/drivers/mysqli/mysqli_utility.php index 44fd0f7aa..e17889b8c 100644..100755 --- a/system/database/drivers/mysqli/mysqli_utility.php +++ b/system/database/drivers/mysqli/mysqli_utility.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -23,7 +23,7 @@ * @link http://codeigniter.com/user_guide/database/ */ class CI_DB_mysqli_utility extends CI_DB_utility { - + /** * List databases * @@ -34,7 +34,7 @@ class CI_DB_mysqli_utility extends CI_DB_utility { { return "SHOW DATABASES"; } - + // -------------------------------------------------------------------- /** @@ -81,42 +81,6 @@ class CI_DB_mysqli_utility extends CI_DB_utility { // Currently unsupported return $this->db->display_error('db_unsuported_feature'); } - - - /** - * - * The functions below have been deprecated as of 1.6, and are only here for backwards - * compatibility. They now reside in dbforge(). The use of dbutils for database manipulation - * is STRONGLY discouraged in favour if using dbforge. - * - */ - - /** - * Create database - * - * @access private - * @param string the database name - * @return bool - */ - function _create_database($name) - { - return "CREATE DATABASE ".$name; - } - - // -------------------------------------------------------------------- - - /** - * Drop database - * - * @access private - * @param string the database name - * @return bool - */ - function _drop_database($name) - { - return "DROP DATABASE ".$name; - } - } /* End of file mysqli_utility.php */ diff --git a/system/database/drivers/oci8/index.html b/system/database/drivers/oci8/index.html index c942a79ce..c942a79ce 100644..100755 --- a/system/database/drivers/oci8/index.html +++ b/system/database/drivers/oci8/index.html diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index 758192358..64f53cc3f 100644..100755 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -2,14 +2,14 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * - * @package CodeIgniter - * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. - * @license http://codeigniter.com/user_guide/license.html + * @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 + * @since Version 1.0 * @filesource */ @@ -22,10 +22,10 @@ * creates dynamically based on whether the active record * class is being used or not. * - * @package CodeIgniter + * @package CodeIgniter * @subpackage Drivers * @category Database - * @author ExpressionEngine Dev Team + * @author ExpressionEngine Dev Team * @link http://codeigniter.com/user_guide/database/ */ @@ -44,14 +44,14 @@ class CI_DB_oci8_driver extends CI_DB { var $dbdriver = 'oci8'; - + // The character used for excaping var $_escape_char = '"'; - + // clause and character used for LIKE escape sequences var $_like_escape_str = " escape '%s' "; var $_like_escape_chr = '!'; - + /** * The syntax to count rows is slightly different across different * database engines, so this string appears in each driver and is @@ -141,7 +141,7 @@ class CI_DB_oci8_driver extends CI_DB { } // -------------------------------------------------------------------- - + /** * Version number query string * @@ -248,7 +248,7 @@ class CI_DB_oci8_driver extends CI_DB { } return FALSE; } - + // build the query string $sql = "begin $package.$procedure("; @@ -256,20 +256,20 @@ class CI_DB_oci8_driver extends CI_DB { foreach($params as $param) { $sql .= $param['name'] . ","; - + if (array_key_exists('type', $param) && ($param['type'] == OCI_B_CURSOR)) { $have_cursor = TRUE; } } $sql = trim($sql, ",") . "); end;"; - + $this->stmt_id = FALSE; $this->_set_stmt_id($sql); $this->_bind_params($params); $this->query($sql, FALSE, $have_cursor); } - + // -------------------------------------------------------------------- /** @@ -284,10 +284,10 @@ class CI_DB_oci8_driver extends CI_DB { { return; } - + foreach ($params as $param) { - foreach (array('name', 'value', 'type', 'length') as $val) + foreach (array('name', 'value', 'type', 'length') as $val) { if ( ! isset($param[$val])) { @@ -305,26 +305,26 @@ class CI_DB_oci8_driver extends CI_DB { * Begin Transaction * * @access public - * @return bool - */ + * @return bool + */ function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { return TRUE; } - + // When transactions are nested we only begin/commit/rollback the outermost ones if ($this->_trans_depth > 0) { return TRUE; } - + // Reset the transaction failure flag. // If the $test_mode flag is set to TRUE transactions will be rolled back // even if the queries produce a successful result. $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE; - + $this->_commit = OCI_DEFAULT; return TRUE; } @@ -335,8 +335,8 @@ class CI_DB_oci8_driver extends CI_DB { * Commit Transaction * * @access public - * @return bool - */ + * @return bool + */ function trans_commit() { if ( ! $this->trans_enabled) @@ -361,8 +361,8 @@ class CI_DB_oci8_driver extends CI_DB { * Rollback Transaction * * @access public - * @return bool - */ + * @return bool + */ function trans_rollback() { if ( ! $this->trans_enabled) @@ -396,18 +396,15 @@ class CI_DB_oci8_driver extends CI_DB { if (is_array($str)) { foreach($str as $key => $val) - { + { $str[$key] = $this->escape_str($val, $like); - } - - return $str; - } + } + + return $str; + } - // Access the CI object - $CI =& get_instance(); + $str = remove_invisible_characters($str); - $str = $CI->input->_remove_invisible_characters($str); - // escape LIKE condition wildcards if ($like === TRUE) { @@ -415,7 +412,7 @@ class CI_DB_oci8_driver extends CI_DB { array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr), $str); } - + return $str; } @@ -493,9 +490,9 @@ class CI_DB_oci8_driver extends CI_DB { if ($prefix_limit !== FALSE AND $this->dbprefix != '') { - $sql .= " WHERE TABLE_NAME LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_char); + $sql .= " WHERE TABLE_NAME LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); } - + return $sql; } @@ -558,7 +555,7 @@ class CI_DB_oci8_driver extends CI_DB { $error = ocierror($this->conn_id); return $error['code']; } - + // -------------------------------------------------------------------- /** @@ -581,26 +578,26 @@ class CI_DB_oci8_driver extends CI_DB { { if (strpos($item, '.'.$id) !== FALSE) { - $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item); - + $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item); + // remove duplicates if the user already included the escape return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); - } + } } - + if (strpos($item, '.') !== FALSE) { - $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char; + $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char; } else { $str = $this->_escape_char.$item.$this->_escape_char; } - + // remove duplicates if the user already included the escape return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); } - + // -------------------------------------------------------------------- /** @@ -619,12 +616,12 @@ class CI_DB_oci8_driver extends CI_DB { { $tables = array($tables); } - + return implode(', ', $tables); } // -------------------------------------------------------------------- - + /** * Insert statement * @@ -662,17 +659,17 @@ class CI_DB_oci8_driver extends CI_DB { { $valstr[] = $key." = ".$val; } - + $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; - + $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):''; - + $sql = "UPDATE ".$table." SET ".implode(', ', $valstr); $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : ''; $sql .= $orderby.$limit; - + return $sql; } @@ -688,12 +685,12 @@ class CI_DB_oci8_driver extends CI_DB { * @access public * @param string the table name * @return string - */ + */ function _truncate($table) { return "TRUNCATE TABLE ".$table; } - + // -------------------------------------------------------------------- /** @@ -706,7 +703,7 @@ class CI_DB_oci8_driver extends CI_DB { * @param array the where clause * @param string the limit clause * @return string - */ + */ function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; @@ -724,7 +721,7 @@ class CI_DB_oci8_driver extends CI_DB { } $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; - + return "DELETE FROM ".$table.$conditions.$limit; } @@ -755,7 +752,7 @@ class CI_DB_oci8_driver extends CI_DB { $this->limit_used = TRUE; return $newsql; - } + } // -------------------------------------------------------------------- diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php index d77ed8de6..3cd17585a 100644..100755 --- a/system/database/drivers/oci8/oci8_forge.php +++ b/system/database/drivers/oci8/oci8_forge.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -66,12 +66,12 @@ class CI_DB_oci8_forge extends CI_DB_forge { function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; - + if ($if_not_exists === TRUE) { $sql .= 'IF NOT EXISTS '; } - + $sql .= $this->db->_escape_identifiers($table)." ("; $current_field_count = 0; @@ -87,41 +87,41 @@ class CI_DB_oci8_forge extends CI_DB_forge { else { $attributes = array_change_key_case($attributes, CASE_UPPER); - + $sql .= "\n\t".$this->db->_protect_identifiers($field); - + $sql .= ' '.$attributes['TYPE']; - + if (array_key_exists('CONSTRAINT', $attributes)) { $sql .= '('.$attributes['CONSTRAINT'].')'; } - + if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE) { $sql .= ' UNSIGNED'; } - + if (array_key_exists('DEFAULT', $attributes)) { $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\''; } - + if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE) { $sql .= ' NULL'; } else { - $sql .= ' NOT NULL'; + $sql .= ' NOT NULL'; } - + if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE) { $sql .= ' AUTO_INCREMENT'; } } - + // don't add a comma on the end of the last field if (++$current_field_count < count($fields)) { @@ -141,17 +141,17 @@ class CI_DB_oci8_forge extends CI_DB_forge { { if (is_array($key)) { - $key = $this->db->_protect_identifiers($key); + $key = $this->db->_protect_identifiers($key); } else { $key = array($this->db->_protect_identifiers($key)); } - + $sql .= ",\n\tUNIQUE COLUMNS (" . implode(', ', $key) . ")"; } } - + $sql .= "\n)"; return $sql; @@ -218,9 +218,9 @@ class CI_DB_oci8_forge extends CI_DB_forge { { $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field); } - + return $sql; - + } // -------------------------------------------------------------------- diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php index cab538e21..88531b436 100644..100755 --- a/system/database/drivers/oci8/oci8_result.php +++ b/system/database/drivers/oci8/oci8_result.php @@ -2,14 +2,14 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * - * @package CodeIgniter - * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. - * @license http://codeigniter.com/user_guide/license.html + * @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 + * @since Version 1.0 * @filesource */ @@ -21,7 +21,7 @@ * This class extends the parent result class: CI_DB_result * * @category Database - * @author ExpressionEngine Dev Team + * @author ExpressionEngine Dev Team * @link http://codeigniter.com/user_guide/database/ */ class CI_DB_oci8_result extends CI_DB_result { @@ -35,7 +35,7 @@ class CI_DB_oci8_result extends CI_DB_result { * * Oracle doesn't have a graceful way to retun the number of rows * so we have to use what amounts to a hack. - * + * * * @access public * @return integer @@ -111,7 +111,7 @@ class CI_DB_oci8_result extends CI_DB_result { $fieldCount = $this->num_fields(); for ($c = 1; $c <= $fieldCount; $c++) { - $F = new stdClass(); + $F = new stdClass(); $F->name = ocicolumnname($this->stmt_id, $c); $F->type = ocicolumntype($this->stmt_id, $c); $F->max_length = ocicolumnsize($this->stmt_id, $c); @@ -128,12 +128,12 @@ class CI_DB_oci8_result extends CI_DB_result { * Free the result * * @return null - */ + */ function free_result() { if (is_resource($this->result_id)) { - ocifreestatement($this->result_id); + ocifreestatement($this->result_id); $this->result_id = FALSE; } } @@ -151,8 +151,8 @@ class CI_DB_oci8_result extends CI_DB_result { function _fetch_assoc(&$row) { $id = ($this->curs_id) ? $this->curs_id : $this->stmt_id; - - return ocifetchinto($id, $row, OCI_ASSOC + OCI_RETURN_NULLS); + + return ocifetchinto($id, $row, OCI_ASSOC + OCI_RETURN_NULLS); } // -------------------------------------------------------------------- @@ -166,17 +166,17 @@ class CI_DB_oci8_result extends CI_DB_result { * @return object */ function _fetch_object() - { + { $result = array(); // If PHP 5 is being used we can fetch an result object if (function_exists('oci_fetch_object')) { $id = ($this->curs_id) ? $this->curs_id : $this->stmt_id; - + return @oci_fetch_object($id); } - + // If PHP 4 is being used we have to build our own result foreach ($this->result_array() as $key => $val) { @@ -192,7 +192,7 @@ class CI_DB_oci8_result extends CI_DB_result { { $obj->$key = $val; } - + $result[] = $obj; } diff --git a/system/database/drivers/oci8/oci8_utility.php b/system/database/drivers/oci8/oci8_utility.php index 74670eaab..854b467e1 100644..100755 --- a/system/database/drivers/oci8/oci8_utility.php +++ b/system/database/drivers/oci8/oci8_utility.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -81,41 +81,6 @@ class CI_DB_oci8_utility extends CI_DB_utility { // Currently unsupported return $this->db->display_error('db_unsuported_feature'); } - - /** - * - * The functions below have been deprecated as of 1.6, and are only here for backwards - * compatibility. They now reside in dbforge(). The use of dbutils for database manipulation - * is STRONGLY discouraged in favour if using dbforge. - * - */ - - /** - * Create database - * - * @access public - * @param string the database name - * @return bool - */ - function _create_database($name) - { - return FALSE; - } - - // -------------------------------------------------------------------- - - /** - * Drop database - * - * @access private - * @param string the database name - * @return bool - */ - function _drop_database($name) - { - return FALSE; - } - } /* End of file oci8_utility.php */ diff --git a/system/database/drivers/odbc/index.html b/system/database/drivers/odbc/index.html index c942a79ce..c942a79ce 100644..100755 --- a/system/database/drivers/odbc/index.html +++ b/system/database/drivers/odbc/index.html diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php index 6cb3080d4..c8e03c356 100644..100755 --- a/system/database/drivers/odbc/odbc_driver.php +++ b/system/database/drivers/odbc/odbc_driver.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -31,14 +31,14 @@ class CI_DB_odbc_driver extends CI_DB { var $dbdriver = 'odbc'; - + // the character used to excape - not necessary for ODBC var $_escape_char = ''; - + // clause and character used for LIKE escape sequences var $_like_escape_str = " {escape '%s'} "; var $_like_escape_chr = '!'; - + /** * The syntax to count rows is slightly different across different * database engines, so this string appears in each driver and is @@ -51,7 +51,7 @@ class CI_DB_odbc_driver extends CI_DB { function CI_DB_odbc_driver($params) { parent::CI_DB($params); - + $this->_random_keyword = ' RND('.time().')'; // database specific random keyword } @@ -60,12 +60,12 @@ class CI_DB_odbc_driver extends CI_DB { * * @access private called by the base class * @return resource - */ + */ function db_connect() { return @odbc_connect($this->hostname, $this->username, $this->password); } - + // -------------------------------------------------------------------- /** @@ -73,12 +73,12 @@ class CI_DB_odbc_driver extends CI_DB { * * @access private called by the base class * @return resource - */ + */ function db_pconnect() { return @odbc_pconnect($this->hostname, $this->username, $this->password); } - + // -------------------------------------------------------------------- /** @@ -102,7 +102,7 @@ class CI_DB_odbc_driver extends CI_DB { * * @access private called by the base class * @return resource - */ + */ function db_select() { // Not needed for ODBC @@ -126,7 +126,7 @@ class CI_DB_odbc_driver extends CI_DB { } // -------------------------------------------------------------------- - + /** * Version number query string * @@ -146,13 +146,13 @@ class CI_DB_odbc_driver extends CI_DB { * @access private called by the base class * @param string an SQL query * @return resource - */ + */ function _execute($sql) { $sql = $this->_prep_query($sql); return @odbc_exec($this->conn_id, $sql); } - + // -------------------------------------------------------------------- /** @@ -163,7 +163,7 @@ class CI_DB_odbc_driver extends CI_DB { * @access private called by execute() * @param string an SQL query * @return string - */ + */ function _prep_query($sql) { return $sql; @@ -175,15 +175,15 @@ class CI_DB_odbc_driver extends CI_DB { * Begin Transaction * * @access public - * @return bool - */ + * @return bool + */ function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { return TRUE; } - + // When transactions are nested we only begin/commit/rollback the outermost ones if ($this->_trans_depth > 0) { @@ -204,8 +204,8 @@ class CI_DB_odbc_driver extends CI_DB { * Commit Transaction * * @access public - * @return bool - */ + * @return bool + */ function trans_commit() { if ( ! $this->trans_enabled) @@ -230,8 +230,8 @@ class CI_DB_odbc_driver extends CI_DB { * Rollback Transaction * * @access public - * @return bool - */ + * @return bool + */ function trans_rollback() { if ( ! $this->trans_enabled) @@ -265,19 +265,16 @@ class CI_DB_odbc_driver extends CI_DB { if (is_array($str)) { foreach($str as $key => $val) - { + { $str[$key] = $this->escape_str($val, $like); - } - - return $str; - } - - // Access the CI object - $CI =& get_instance(); - + } + + return $str; + } + // ODBC doesn't require escaping - $str = $CI->input->_remove_invisible_characters($str); - + $str = remove_invisible_characters($str); + // escape LIKE condition wildcards if ($like === TRUE) { @@ -285,10 +282,10 @@ class CI_DB_odbc_driver extends CI_DB { array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr), $str); } - + return $str; } - + // -------------------------------------------------------------------- /** @@ -301,7 +298,7 @@ class CI_DB_odbc_driver extends CI_DB { { return @odbc_num_rows($this->conn_id); } - + // -------------------------------------------------------------------- /** @@ -362,13 +359,13 @@ class CI_DB_odbc_driver extends CI_DB { if ($prefix_limit !== FALSE AND $this->dbprefix != '') { - //$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_char); + //$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); return FALSE; // not currently supported } - + return $sql; } - + // -------------------------------------------------------------------- /** @@ -413,7 +410,7 @@ class CI_DB_odbc_driver extends CI_DB { { return odbc_errormsg($this->conn_id); } - + // -------------------------------------------------------------------- /** @@ -449,26 +446,26 @@ class CI_DB_odbc_driver extends CI_DB { { if (strpos($item, '.'.$id) !== FALSE) { - $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item); - + $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item); + // remove duplicates if the user already included the escape return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); - } + } } - + if (strpos($item, '.') !== FALSE) { - $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char; + $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char; } else { $str = $this->_escape_char.$item.$this->_escape_char; } - + // remove duplicates if the user already included the escape return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); } - + // -------------------------------------------------------------------- /** @@ -487,12 +484,12 @@ class CI_DB_odbc_driver extends CI_DB { { $tables = array($tables); } - + return '('.implode(', ', $tables).')'; } // -------------------------------------------------------------------- - + /** * Insert statement * @@ -505,10 +502,10 @@ class CI_DB_odbc_driver extends CI_DB { * @return string */ function _insert($table, $keys, $values) - { + { return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; } - + // -------------------------------------------------------------------- /** @@ -530,21 +527,21 @@ class CI_DB_odbc_driver extends CI_DB { { $valstr[] = $key." = ".$val; } - + $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; - + $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):''; - + $sql = "UPDATE ".$table." SET ".implode(', ', $valstr); $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : ''; $sql .= $orderby.$limit; - + return $sql; } - + // -------------------------------------------------------------------- /** @@ -557,12 +554,12 @@ class CI_DB_odbc_driver extends CI_DB { * @access public * @param string the table name * @return string - */ + */ function _truncate($table) { return $this->_delete($table); } - + // -------------------------------------------------------------------- /** @@ -575,7 +572,7 @@ class CI_DB_odbc_driver extends CI_DB { * @param array the where clause * @param string the limit clause * @return string - */ + */ function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; @@ -593,7 +590,7 @@ class CI_DB_odbc_driver extends CI_DB { } $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; - + return "DELETE FROM ".$table.$conditions.$limit; } @@ -630,7 +627,7 @@ class CI_DB_odbc_driver extends CI_DB { @odbc_close($conn_id); } - + } diff --git a/system/database/drivers/odbc/odbc_forge.php b/system/database/drivers/odbc/odbc_forge.php index 1ae559b6e..3ec86b4e9 100644..100755 --- a/system/database/drivers/odbc/odbc_forge.php +++ b/system/database/drivers/odbc/odbc_forge.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -54,7 +54,7 @@ class CI_DB_odbc_forge extends CI_DB_forge { function _drop_database($name) { // ODBC has no "drop database" command since it's - // designed to connect to an existing database + // designed to connect to an existing database if ($this->db->db_debug) { return $this->db->display_error('db_unsuported_feature'); @@ -78,12 +78,12 @@ class CI_DB_odbc_forge extends CI_DB_forge { function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; - + if ($if_not_exists === TRUE) { $sql .= 'IF NOT EXISTS '; } - + $sql .= $this->db->_escape_identifiers($table)." ("; $current_field_count = 0; @@ -99,41 +99,41 @@ class CI_DB_odbc_forge extends CI_DB_forge { else { $attributes = array_change_key_case($attributes, CASE_UPPER); - + $sql .= "\n\t".$this->db->_protect_identifiers($field); - + $sql .= ' '.$attributes['TYPE']; - + if (array_key_exists('CONSTRAINT', $attributes)) { $sql .= '('.$attributes['CONSTRAINT'].')'; } - + if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE) { $sql .= ' UNSIGNED'; } - + if (array_key_exists('DEFAULT', $attributes)) { $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\''; } - + if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE) { $sql .= ' NULL'; } else { - $sql .= ' NOT NULL'; + $sql .= ' NOT NULL'; } - + if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE) { $sql .= ' AUTO_INCREMENT'; } } - + // don't add a comma on the end of the last field if (++$current_field_count < count($fields)) { @@ -146,24 +146,24 @@ class CI_DB_odbc_forge extends CI_DB_forge { $primary_keys = $this->db->_protect_identifiers($primary_keys); $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")"; } - + if (is_array($keys) && count($keys) > 0) { foreach ($keys as $key) { if (is_array($key)) { - $key = $this->db->_protect_identifiers($key); + $key = $this->db->_protect_identifiers($key); } else { $key = array($this->db->_protect_identifiers($key)); } - + $sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")"; } } - + $sql .= "\n)"; return $sql; @@ -179,7 +179,7 @@ class CI_DB_odbc_forge extends CI_DB_forge { */ function _drop_table($table) { - // Not a supported ODBC feature + // Not a supported ODBC feature if ($this->db->db_debug) { return $this->db->display_error('db_unsuported_feature'); @@ -235,9 +235,9 @@ class CI_DB_odbc_forge extends CI_DB_forge { { $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field); } - + return $sql; - + } diff --git a/system/database/drivers/odbc/odbc_result.php b/system/database/drivers/odbc/odbc_result.php index 5ae46df62..a81a2b8b7 100644..100755 --- a/system/database/drivers/odbc/odbc_result.php +++ b/system/database/drivers/odbc/odbc_result.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -25,7 +25,7 @@ * @link http://codeigniter.com/user_guide/database/ */ class CI_DB_odbc_result extends CI_DB_result { - + /** * Number of rows in the result set * @@ -36,7 +36,7 @@ class CI_DB_odbc_result extends CI_DB_result { { return @odbc_num_rows($this->result_id); } - + // -------------------------------------------------------------------- /** @@ -65,9 +65,9 @@ class CI_DB_odbc_result extends CI_DB_result { $field_names = array(); for ($i = 0; $i < $this->num_fields(); $i++) { - $field_names[] = odbc_field_name($this->result_id, $i); + $field_names[] = odbc_field_name($this->result_id, $i); } - + return $field_names; } @@ -86,16 +86,16 @@ class CI_DB_odbc_result extends CI_DB_result { $retval = array(); for ($i = 0; $i < $this->num_fields(); $i++) { - $F = new stdClass(); - $F->name = odbc_field_name($this->result_id, $i); - $F->type = odbc_field_type($this->result_id, $i); + $F = new stdClass(); + $F->name = odbc_field_name($this->result_id, $i); + $F->type = odbc_field_type($this->result_id, $i); $F->max_length = odbc_field_len($this->result_id, $i); $F->primary_key = 0; $F->default = ''; $retval[] = $F; } - + return $retval; } @@ -105,7 +105,7 @@ class CI_DB_odbc_result extends CI_DB_result { * Free the result * * @return null - */ + */ function free_result() { if (is_resource($this->result_id)) diff --git a/system/database/drivers/odbc/odbc_utility.php b/system/database/drivers/odbc/odbc_utility.php index 4e6848e82..d335bed99 100644..100755 --- a/system/database/drivers/odbc/odbc_utility.php +++ b/system/database/drivers/odbc/odbc_utility.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -32,7 +32,7 @@ class CI_DB_odbc_utility extends CI_DB_utility { */ function _list_databases() { - // Not sure if ODBC lets you list all databases... + // Not sure if ODBC lets you list all databases... if ($this->db->db_debug) { return $this->db->display_error('db_unsuported_feature'); @@ -53,7 +53,7 @@ class CI_DB_odbc_utility extends CI_DB_utility { */ function _optimize_table($table) { - // Not a supported ODBC feature + // Not a supported ODBC feature if ($this->db->db_debug) { return $this->db->display_error('db_unsuported_feature'); @@ -74,7 +74,7 @@ class CI_DB_odbc_utility extends CI_DB_utility { */ function _repair_table($table) { - // Not a supported ODBC feature + // Not a supported ODBC feature if ($this->db->db_debug) { return $this->db->display_error('db_unsuported_feature'); @@ -96,52 +96,7 @@ class CI_DB_odbc_utility extends CI_DB_utility { // Currently unsupported return $this->db->display_error('db_unsuported_feature'); } - - /** - * - * The functions below have been deprecated as of 1.6, and are only here for backwards - * compatibility. They now reside in dbforge(). The use of dbutils for database manipulation - * is STRONGLY discouraged in favour if using dbforge. - * - */ - /** - * Create database - * - * @access private - * @param string the database name - * @return bool - */ - function _create_database() - { - // ODBC has no "create database" command since it's - // designed to connect to an existing database - if ($this->db->db_debug) - { - return $this->db->display_error('db_unsuported_feature'); - } - return FALSE; - } - - // -------------------------------------------------------------------- - - /** - * Drop database - * - * @access private - * @param string the database name - * @return bool - */ - function _drop_database($name) - { - // ODBC has no "drop database" command since it's - // designed to connect to an existing database - if ($this->db->db_debug) - { - return $this->db->display_error('db_unsuported_feature'); - } - return FALSE; - } } /* End of file odbc_utility.php */ diff --git a/system/database/drivers/postgre/index.html b/system/database/drivers/postgre/index.html index c942a79ce..c942a79ce 100644..100755 --- a/system/database/drivers/postgre/index.html +++ b/system/database/drivers/postgre/index.html diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index bac179d40..0bb7974d8 100644..100755 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -31,7 +31,7 @@ class CI_DB_postgre_driver extends CI_DB { var $dbdriver = 'postgre'; - + var $_escape_char = '"'; // clause and character used for LIKE escape sequences @@ -51,7 +51,7 @@ class CI_DB_postgre_driver extends CI_DB { * * @access private * @return string - */ + */ function _connect_string() { $components = array( @@ -61,7 +61,7 @@ class CI_DB_postgre_driver extends CI_DB { 'username' => 'user', 'password' => 'password' ); - + $connect_string = ""; foreach ($components as $key => $val) { @@ -80,9 +80,9 @@ class CI_DB_postgre_driver extends CI_DB { * * @access private called by the base class * @return resource - */ + */ function db_connect() - { + { return @pg_connect($this->_connect_string()); } @@ -93,12 +93,12 @@ class CI_DB_postgre_driver extends CI_DB { * * @access private called by the base class * @return resource - */ + */ function db_pconnect() { return @pg_pconnect($this->_connect_string()); } - + // -------------------------------------------------------------------- /** @@ -125,7 +125,7 @@ class CI_DB_postgre_driver extends CI_DB { * * @access private called by the base class * @return resource - */ + */ function db_select() { // Not needed for Postgre so we'll return TRUE @@ -149,7 +149,7 @@ class CI_DB_postgre_driver extends CI_DB { } // -------------------------------------------------------------------- - + /** * Version number query string * @@ -169,13 +169,13 @@ class CI_DB_postgre_driver extends CI_DB { * @access private called by the base class * @param string an SQL query * @return resource - */ + */ function _execute($sql) { $sql = $this->_prep_query($sql); return @pg_query($this->conn_id, $sql); } - + // -------------------------------------------------------------------- /** @@ -186,7 +186,7 @@ class CI_DB_postgre_driver extends CI_DB { * @access private called by execute() * @param string an SQL query * @return string - */ + */ function _prep_query($sql) { return $sql; @@ -198,15 +198,15 @@ class CI_DB_postgre_driver extends CI_DB { * Begin Transaction * * @access public - * @return bool - */ + * @return bool + */ function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { return TRUE; } - + // When transactions are nested we only begin/commit/rollback the outermost ones if ($this->_trans_depth > 0) { @@ -227,8 +227,8 @@ class CI_DB_postgre_driver extends CI_DB { * Commit Transaction * * @access public - * @return bool - */ + * @return bool + */ function trans_commit() { if ( ! $this->trans_enabled) @@ -251,8 +251,8 @@ class CI_DB_postgre_driver extends CI_DB { * Rollback Transaction * * @access public - * @return bool - */ + * @return bool + */ function trans_rollback() { if ( ! $this->trans_enabled) @@ -284,15 +284,15 @@ class CI_DB_postgre_driver extends CI_DB { if (is_array($str)) { foreach($str as $key => $val) - { + { $str[$key] = $this->escape_str($val, $like); - } - - return $str; - } + } + + return $str; + } $str = pg_escape_string($str); - + // escape LIKE condition wildcards if ($like === TRUE) { @@ -300,10 +300,10 @@ class CI_DB_postgre_driver extends CI_DB { array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr), $str); } - + return $str; } - + // -------------------------------------------------------------------- /** @@ -316,7 +316,7 @@ class CI_DB_postgre_driver extends CI_DB { { return @pg_affected_rows($this->result_id); } - + // -------------------------------------------------------------------- /** @@ -329,10 +329,10 @@ class CI_DB_postgre_driver extends CI_DB { { $v = $this->_version(); $v = $v['server']; - + $table = func_num_args() > 0 ? func_get_arg(0) : null; $column = func_num_args() > 1 ? func_get_arg(1) : null; - + if ($table == null && $v >= '8.1') { $sql='SELECT LASTVAL() as ins_id'; @@ -400,17 +400,17 @@ class CI_DB_postgre_driver extends CI_DB { * @return string */ function _list_tables($prefix_limit = FALSE) - { - $sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'"; - + { + $sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'"; + if ($prefix_limit !== FALSE AND $this->dbprefix != '') { - $sql .= " AND table_name LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_char); + $sql .= " AND table_name LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); } - + return $sql; } - + // -------------------------------------------------------------------- /** @@ -455,7 +455,7 @@ class CI_DB_postgre_driver extends CI_DB { { return pg_last_error($this->conn_id); } - + // -------------------------------------------------------------------- /** @@ -491,26 +491,26 @@ class CI_DB_postgre_driver extends CI_DB { { if (strpos($item, '.'.$id) !== FALSE) { - $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item); - + $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item); + // remove duplicates if the user already included the escape return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); - } + } } - + if (strpos($item, '.') !== FALSE) { - $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char; + $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char; } else { $str = $this->_escape_char.$item.$this->_escape_char; } - + // remove duplicates if the user already included the escape return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); } - + // -------------------------------------------------------------------- /** @@ -529,12 +529,12 @@ class CI_DB_postgre_driver extends CI_DB { { $tables = array($tables); } - + return implode(', ', $tables); } // -------------------------------------------------------------------- - + /** * Insert statement * @@ -547,10 +547,10 @@ class CI_DB_postgre_driver extends CI_DB { * @return string */ function _insert($table, $keys, $values) - { + { return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; } - + // -------------------------------------------------------------------- /** @@ -572,17 +572,17 @@ class CI_DB_postgre_driver extends CI_DB { { $valstr[] = $key." = ".$val; } - + $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; - + $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):''; - + $sql = "UPDATE ".$table." SET ".implode(', ', $valstr); $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : ''; $sql .= $orderby.$limit; - + return $sql; } @@ -598,12 +598,12 @@ class CI_DB_postgre_driver extends CI_DB { * @access public * @param string the table name * @return string - */ + */ function _truncate($table) { return "TRUNCATE ".$table; } - + // -------------------------------------------------------------------- /** @@ -616,7 +616,7 @@ class CI_DB_postgre_driver extends CI_DB { * @param array the where clause * @param string the limit clause * @return string - */ + */ function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; @@ -634,7 +634,7 @@ class CI_DB_postgre_driver extends CI_DB { } $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; - + return "DELETE FROM ".$table.$conditions.$limit; } @@ -651,14 +651,14 @@ class CI_DB_postgre_driver extends CI_DB { * @return string */ function _limit($sql, $limit, $offset) - { + { $sql .= "LIMIT ".$limit; - + if ($offset > 0) { $sql .= " OFFSET ".$offset; } - + return $sql; } diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php index c98ef425d..91a1c6861 100644..100755 --- a/system/database/drivers/postgre/postgre_forge.php +++ b/system/database/drivers/postgre/postgre_forge.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -66,12 +66,15 @@ class CI_DB_postgre_forge extends CI_DB_forge { function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; - + if ($if_not_exists === TRUE) { - $sql .= 'IF NOT EXISTS '; + if ($this->db->table_exists($table)) + { + return "SELECT * FROM $table"; // Needs to return innocous but valid SQL statement + } } - + $sql .= $this->db->_escape_identifiers($table)." ("; $current_field_count = 0; @@ -87,41 +90,81 @@ class CI_DB_postgre_forge extends CI_DB_forge { else { $attributes = array_change_key_case($attributes, CASE_UPPER); - + $sql .= "\n\t".$this->db->_protect_identifiers($field); - - $sql .= ' '.$attributes['TYPE']; - - if (array_key_exists('CONSTRAINT', $attributes)) + + $is_unsigned = (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE); + + // Convert datatypes to be PostgreSQL-compatible + switch (strtoupper($attributes['TYPE'])) { - $sql .= '('.$attributes['CONSTRAINT'].')'; + case 'TINYINT': + $attributes['TYPE'] = 'SMALLINT'; + break; + case 'SMALLINT': + $attributes['TYPE'] = ($is_unsigned) ? 'INTEGER' : 'SMALLINT'; + break; + case 'MEDIUMINT': + $attributes['TYPE'] = 'INTEGER'; + break; + case 'INT': + $attributes['TYPE'] = ($is_unsigned) ? 'BIGINT' : 'INTEGER'; + break; + case 'BIGINT': + $attributes['TYPE'] = ($is_unsigned) ? 'NUMERIC' : 'BIGINT'; + break; + case 'DOUBLE': + $attributes['TYPE'] = 'DOUBLE PRECISION'; + break; + case 'DATETIME': + $attributes['TYPE'] = 'TIMESTAMP'; + break; + case 'LONGTEXT': + $attributes['TYPE'] = 'TEXT'; + break; + case 'BLOB': + $attributes['TYPE'] = 'BYTEA'; + break; + } + + // If this is an auto-incrementing primary key, use the serial data type instead + if (in_array($field, $primary_keys) && array_key_exists('AUTO_INCREMENT', $attributes) + && $attributes['AUTO_INCREMENT'] === TRUE) + { + $sql .= ' SERIAL'; } - - if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE) + else { - $sql .= ' UNSIGNED'; + $sql .= ' '.$attributes['TYPE']; } - + + // Modified to prevent constraints with integer data types + if (array_key_exists('CONSTRAINT', $attributes) && strpos($attributes['TYPE'], 'INT') === false) + { + $sql .= '('.$attributes['CONSTRAINT'].')'; + } + if (array_key_exists('DEFAULT', $attributes)) { $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\''; } - + if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE) { $sql .= ' NULL'; } else { - $sql .= ' NOT NULL'; + $sql .= ' NOT NULL'; } - - if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE) + + // Added new attribute to create unqite fields. Also works with MySQL + if (array_key_exists('UNIQUE', $attributes) && $attributes['UNIQUE'] === TRUE) { - $sql .= ' AUTO_INCREMENT'; + $sql .= ' UNIQUE'; } } - + // don't add a comma on the end of the last field if (++$current_field_count < count($fields)) { @@ -131,29 +174,37 @@ class CI_DB_postgre_forge extends CI_DB_forge { if (count($primary_keys) > 0) { - $primary_keys = $this->db->_protect_identifiers($primary_keys); + // Something seems to break when passing an array to _protect_identifiers() + foreach ($primary_keys as $index => $key) + { + $primary_keys[$index] = $this->db->_protect_identifiers($key); + } + $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")"; } - + + $sql .= "\n);"; + if (is_array($keys) && count($keys) > 0) { foreach ($keys as $key) { if (is_array($key)) { - $key = $this->db->_protect_identifiers($key); + $key = $this->db->_protect_identifiers($key); } else { $key = array($this->db->_protect_identifiers($key)); } - - $sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")"; + + foreach ($key as $field) + { + $sql .= "CREATE INDEX " . $table . "_" . str_replace(array('"', "'"), '', $field) . "_index ON $table ($field); "; + } } } - $sql .= "\n);"; - return $sql; } @@ -162,12 +213,12 @@ class CI_DB_postgre_forge extends CI_DB_forge { /** * Drop Table * - * @access private - * @return bool + * @access private + * @return bool */ function _drop_table($table) { - return "DROP TABLE ".$this->db->_escape_identifiers($table)." CASCADE"; + return "DROP TABLE IF EXISTS ".$this->db->_escape_identifiers($table)." CASCADE"; } // -------------------------------------------------------------------- @@ -218,9 +269,9 @@ class CI_DB_postgre_forge extends CI_DB_forge { { $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field); } - + return $sql; - + } // -------------------------------------------------------------------- diff --git a/system/database/drivers/postgre/postgre_result.php b/system/database/drivers/postgre/postgre_result.php index 545f413e8..e9a1d1607 100644..100755 --- a/system/database/drivers/postgre/postgre_result.php +++ b/system/database/drivers/postgre/postgre_result.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -36,7 +36,7 @@ class CI_DB_postgre_result extends CI_DB_result { { return @pg_num_rows($this->result_id); } - + // -------------------------------------------------------------------- /** @@ -67,7 +67,7 @@ class CI_DB_postgre_result extends CI_DB_result { { $field_names[] = pg_field_name($this->result_id, $i); } - + return $field_names; } @@ -86,16 +86,16 @@ class CI_DB_postgre_result extends CI_DB_result { $retval = array(); for ($i = 0; $i < $this->num_fields(); $i++) { - $F = new stdClass(); - $F->name = pg_field_name($this->result_id, $i); - $F->type = pg_field_type($this->result_id, $i); + $F = new stdClass(); + $F->name = pg_field_name($this->result_id, $i); + $F->type = pg_field_type($this->result_id, $i); $F->max_length = pg_field_size($this->result_id, $i); $F->primary_key = 0; $F->default = ''; $retval[] = $F; } - + return $retval; } @@ -105,7 +105,7 @@ class CI_DB_postgre_result extends CI_DB_result { * Free the result * * @return null - */ + */ function free_result() { if (is_resource($this->result_id)) @@ -146,7 +146,7 @@ class CI_DB_postgre_result extends CI_DB_result { { return pg_fetch_assoc($this->result_id); } - + // -------------------------------------------------------------------- /** @@ -161,7 +161,7 @@ class CI_DB_postgre_result extends CI_DB_result { { return pg_fetch_object($this->result_id); } - + } diff --git a/system/database/drivers/postgre/postgre_utility.php b/system/database/drivers/postgre/postgre_utility.php index dda22ddb0..741c52ea8 100644..100755 --- a/system/database/drivers/postgre/postgre_utility.php +++ b/system/database/drivers/postgre/postgre_utility.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -81,42 +81,6 @@ class CI_DB_postgre_utility extends CI_DB_utility { // Currently unsupported return $this->db->display_error('db_unsuported_feature'); } - - /** - * - * The functions below have been deprecated as of 1.6, and are only here for backwards - * compatibility. They now reside in dbforge(). The use of dbutils for database manipulation - * is STRONGLY discouraged in favour if using dbforge. - * - */ - - /** - * Create database - * - * @access private - * @param string the database name - * @return bool - */ - function _create_database($name) - { - return "CREATE DATABASE ".$name; - } - - // -------------------------------------------------------------------- - - /** - * Drop database - * - * @access private - * @param string the database name - * @return bool - */ - function _drop_database($name) - { - return "DROP DATABASE ".$name; - } - - } diff --git a/system/database/drivers/sqlite/index.html b/system/database/drivers/sqlite/index.html index c942a79ce..c942a79ce 100644..100755 --- a/system/database/drivers/sqlite/index.html +++ b/system/database/drivers/sqlite/index.html diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php index 05e38848a..5bfc1f558 100644..100755 --- a/system/database/drivers/sqlite/sqlite_driver.php +++ b/system/database/drivers/sqlite/sqlite_driver.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -33,14 +33,14 @@ class CI_DB_sqlite_driver extends CI_DB { var $dbdriver = 'sqlite'; - + // The character used to escape with - not needed for SQLite var $_escape_char = ''; // clause and character used for LIKE escape sequences - var $_like_escape_str = " ESCAPE '%s' "; + var $_like_escape_str = " ESCAPE '%s' "; var $_like_escape_chr = '!'; - + /** * The syntax to count rows is slightly different across different * database engines, so this string appears in each driver and is @@ -54,24 +54,24 @@ class CI_DB_sqlite_driver extends CI_DB { * * @access private called by the base class * @return resource - */ + */ function db_connect() { if ( ! $conn_id = @sqlite_open($this->database, FILE_WRITE_MODE, $error)) { log_message('error', $error); - + if ($this->db_debug) { $this->display_error($error, '', TRUE); } - + return FALSE; } - + return $conn_id; } - + // -------------------------------------------------------------------- /** @@ -79,24 +79,24 @@ class CI_DB_sqlite_driver extends CI_DB { * * @access private called by the base class * @return resource - */ + */ function db_pconnect() { if ( ! $conn_id = @sqlite_popen($this->database, FILE_WRITE_MODE, $error)) { log_message('error', $error); - + if ($this->db_debug) { $this->display_error($error, '', TRUE); } - + return FALSE; } - + return $conn_id; } - + // -------------------------------------------------------------------- /** @@ -120,7 +120,7 @@ class CI_DB_sqlite_driver extends CI_DB { * * @access private called by the base class * @return resource - */ + */ function db_select() { return TRUE; @@ -143,7 +143,7 @@ class CI_DB_sqlite_driver extends CI_DB { } // -------------------------------------------------------------------- - + /** * Version number query string * @@ -154,7 +154,7 @@ class CI_DB_sqlite_driver extends CI_DB { { return sqlite_libversion(); } - + // -------------------------------------------------------------------- /** @@ -163,13 +163,13 @@ class CI_DB_sqlite_driver extends CI_DB { * @access private called by the base class * @param string an SQL query * @return resource - */ + */ function _execute($sql) { $sql = $this->_prep_query($sql); return @sqlite_query($this->conn_id, $sql); } - + // -------------------------------------------------------------------- /** @@ -180,7 +180,7 @@ class CI_DB_sqlite_driver extends CI_DB { * @access private called by execute() * @param string an SQL query * @return string - */ + */ function _prep_query($sql) { return $sql; @@ -192,15 +192,15 @@ class CI_DB_sqlite_driver extends CI_DB { * Begin Transaction * * @access public - * @return bool - */ + * @return bool + */ function trans_begin($test_mode = FALSE) { if ( ! $this->trans_enabled) { return TRUE; } - + // When transactions are nested we only begin/commit/rollback the outermost ones if ($this->_trans_depth > 0) { @@ -222,8 +222,8 @@ class CI_DB_sqlite_driver extends CI_DB { * Commit Transaction * * @access public - * @return bool - */ + * @return bool + */ function trans_commit() { if ( ! $this->trans_enabled) @@ -247,8 +247,8 @@ class CI_DB_sqlite_driver extends CI_DB { * Rollback Transaction * * @access public - * @return bool - */ + * @return bool + */ function trans_rollback() { if ( ! $this->trans_enabled) @@ -265,7 +265,7 @@ class CI_DB_sqlite_driver extends CI_DB { $this->simple_query('ROLLBACK'); return TRUE; } - + // -------------------------------------------------------------------- /** @@ -281,15 +281,15 @@ class CI_DB_sqlite_driver extends CI_DB { if (is_array($str)) { foreach($str as $key => $val) - { + { $str[$key] = $this->escape_str($val, $like); - } - - return $str; - } - + } + + return $str; + } + $str = sqlite_escape_string($str); - + // escape LIKE condition wildcards if ($like === TRUE) { @@ -297,10 +297,10 @@ class CI_DB_sqlite_driver extends CI_DB { array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr), $str); } - + return $str; } - + // -------------------------------------------------------------------- /** @@ -313,7 +313,7 @@ class CI_DB_sqlite_driver extends CI_DB { { return sqlite_changes($this->conn_id); } - + // -------------------------------------------------------------------- /** @@ -347,7 +347,7 @@ class CI_DB_sqlite_driver extends CI_DB { } $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE)); - + if ($query->num_rows() == 0) { return 0; @@ -374,7 +374,7 @@ class CI_DB_sqlite_driver extends CI_DB { if ($prefix_limit !== FALSE AND $this->dbprefix != '') { - $sql .= " AND 'name' LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_char); + $sql .= " AND 'name' LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); } return $sql; } @@ -424,7 +424,7 @@ class CI_DB_sqlite_driver extends CI_DB { { return sqlite_error_string(sqlite_last_error($this->conn_id)); } - + // -------------------------------------------------------------------- /** @@ -460,26 +460,26 @@ class CI_DB_sqlite_driver extends CI_DB { { if (strpos($item, '.'.$id) !== FALSE) { - $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item); - + $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item); + // remove duplicates if the user already included the escape return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); - } + } } - + if (strpos($item, '.') !== FALSE) { - $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char; + $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char; } else { $str = $this->_escape_char.$item.$this->_escape_char; } - + // remove duplicates if the user already included the escape return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); } - + // -------------------------------------------------------------------- /** @@ -498,12 +498,12 @@ class CI_DB_sqlite_driver extends CI_DB { { $tables = array($tables); } - + return '('.implode(', ', $tables).')'; } // -------------------------------------------------------------------- - + /** * Insert statement * @@ -516,10 +516,10 @@ class CI_DB_sqlite_driver extends CI_DB { * @return string */ function _insert($table, $keys, $values) - { + { return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; } - + // -------------------------------------------------------------------- /** @@ -541,21 +541,21 @@ class CI_DB_sqlite_driver extends CI_DB { { $valstr[] = $key." = ".$val; } - + $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; - + $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):''; - + $sql = "UPDATE ".$table." SET ".implode(', ', $valstr); $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : ''; $sql .= $orderby.$limit; - + return $sql; } - + // -------------------------------------------------------------------- /** @@ -568,12 +568,12 @@ class CI_DB_sqlite_driver extends CI_DB { * @access public * @param string the table name * @return string - */ + */ function _truncate($table) { return $this->_delete($table); } - + // -------------------------------------------------------------------- /** @@ -586,7 +586,7 @@ class CI_DB_sqlite_driver extends CI_DB { * @param array the where clause * @param string the limit clause * @return string - */ + */ function _delete($table, $where = array(), $like = array(), $limit = FALSE) { $conditions = ''; @@ -604,10 +604,10 @@ class CI_DB_sqlite_driver extends CI_DB { } $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; - + return "DELETE FROM ".$table.$conditions.$limit; } - + // -------------------------------------------------------------------- /** @@ -622,7 +622,7 @@ class CI_DB_sqlite_driver extends CI_DB { * @return string */ function _limit($sql, $limit, $offset) - { + { if ($offset == 0) { $offset = ''; @@ -631,7 +631,7 @@ class CI_DB_sqlite_driver extends CI_DB { { $offset .= ", "; } - + return $sql."LIMIT ".$offset.$limit; } diff --git a/system/database/drivers/sqlite/sqlite_forge.php b/system/database/drivers/sqlite/sqlite_forge.php index b7d25e755..56904082e 100644..100755 --- a/system/database/drivers/sqlite/sqlite_forge.php +++ b/system/database/drivers/sqlite/sqlite_forge.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -75,13 +75,13 @@ class CI_DB_sqlite_forge extends CI_DB_forge { function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; - + // IF NOT EXISTS added to SQLite in 3.3.0 - if ($if_not_exists === TRUE && version_compare($this->_version(), '3.3.0', '>=') === TRUE) + if ($if_not_exists === TRUE && version_compare($this->db->_version(), '3.3.0', '>=') === TRUE) { $sql .= 'IF NOT EXISTS '; } - + $sql .= $this->db->_escape_identifiers($table)."("; $current_field_count = 0; @@ -97,41 +97,41 @@ class CI_DB_sqlite_forge extends CI_DB_forge { else { $attributes = array_change_key_case($attributes, CASE_UPPER); - + $sql .= "\n\t".$this->db->_protect_identifiers($field); - + $sql .= ' '.$attributes['TYPE']; - + if (array_key_exists('CONSTRAINT', $attributes)) { $sql .= '('.$attributes['CONSTRAINT'].')'; } - + if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE) { $sql .= ' UNSIGNED'; } - + if (array_key_exists('DEFAULT', $attributes)) { $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\''; } - + if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE) { $sql .= ' NULL'; } else { - $sql .= ' NOT NULL'; + $sql .= ' NOT NULL'; } - + if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE) { $sql .= ' AUTO_INCREMENT'; } } - + // don't add a comma on the end of the last field if (++$current_field_count < count($fields)) { @@ -151,13 +151,13 @@ class CI_DB_sqlite_forge extends CI_DB_forge { { if (is_array($key)) { - $key = $this->db->_protect_identifiers($key); + $key = $this->db->_protect_identifiers($key); } else { $key = array($this->db->_protect_identifiers($key)); } - + $sql .= ",\n\tUNIQUE (" . implode(', ', $key) . ")"; } } @@ -237,9 +237,9 @@ class CI_DB_sqlite_forge extends CI_DB_forge { { $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field); } - + return $sql; - + } // -------------------------------------------------------------------- diff --git a/system/database/drivers/sqlite/sqlite_result.php b/system/database/drivers/sqlite/sqlite_result.php index 7b0631221..7bd30db7c 100644..100755 --- a/system/database/drivers/sqlite/sqlite_result.php +++ b/system/database/drivers/sqlite/sqlite_result.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -25,7 +25,7 @@ * @link http://codeigniter.com/user_guide/database/ */ class CI_DB_sqlite_result extends CI_DB_result { - + /** * Number of rows in the result set * @@ -36,7 +36,7 @@ class CI_DB_sqlite_result extends CI_DB_result { { return @sqlite_num_rows($this->result_id); } - + // -------------------------------------------------------------------- /** @@ -67,7 +67,7 @@ class CI_DB_sqlite_result extends CI_DB_result { { $field_names[] = sqlite_field_name($this->result_id, $i); } - + return $field_names; } @@ -86,16 +86,16 @@ class CI_DB_sqlite_result extends CI_DB_result { $retval = array(); for ($i = 0; $i < $this->num_fields(); $i++) { - $F = new stdClass(); - $F->name = sqlite_field_name($this->result_id, $i); - $F->type = 'varchar'; + $F = new stdClass(); + $F->name = sqlite_field_name($this->result_id, $i); + $F->type = 'varchar'; $F->max_length = 0; $F->primary_key = 0; $F->default = ''; $retval[] = $F; } - + return $retval; } @@ -105,7 +105,7 @@ class CI_DB_sqlite_result extends CI_DB_result { * Free the result * * @return null - */ + */ function free_result() { // Not implemented in SQLite @@ -142,7 +142,7 @@ class CI_DB_sqlite_result extends CI_DB_result { { return sqlite_fetch_array($this->result_id); } - + // -------------------------------------------------------------------- /** @@ -168,7 +168,7 @@ class CI_DB_sqlite_result extends CI_DB_result { return $obj; } else { return NULL; - } + } } } diff --git a/system/database/drivers/sqlite/sqlite_utility.php b/system/database/drivers/sqlite/sqlite_utility.php index 5629dac99..508023e2f 100644..100755 --- a/system/database/drivers/sqlite/sqlite_utility.php +++ b/system/database/drivers/sqlite/sqlite_utility.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -39,7 +39,7 @@ class CI_DB_sqlite_utility extends CI_DB_utility { { if ($this->db_debug) { - return $this->display_error('db_unsuported_feature'); + return $this->db->display_error('db_unsuported_feature'); } return array(); } @@ -90,51 +90,6 @@ class CI_DB_sqlite_utility extends CI_DB_utility { // Currently unsupported return $this->db->display_error('db_unsuported_feature'); } - - /** - * - * The functions below have been deprecated as of 1.6, and are only here for backwards - * compatibility. They now reside in dbforge(). The use of dbutils for database manipulation - * is STRONGLY discouraged in favour if using dbforge. - * - */ - - /** - * Create database - * - * @access public - * @param string the database name - * @return bool - */ - function _create_database() - { - // In SQLite, a database is created when you connect to the database. - // We'll return TRUE so that an error isn't generated - return TRUE; - } - - // -------------------------------------------------------------------- - - /** - * Drop database - * - * @access private - * @param string the database name - * @return bool - */ - function _drop_database($name) - { - if ( ! @file_exists($this->db->database) OR ! @unlink($this->db->database)) - { - if ($this->db->db_debug) - { - return $this->db->display_error('db_unable_to_drop'); - } - return FALSE; - } - return TRUE; - } - } /* End of file sqlite_utility.php */ diff --git a/system/database/index.html b/system/database/index.html index c942a79ce..c942a79ce 100644..100755 --- a/system/database/index.html +++ b/system/database/index.html diff --git a/system/fonts/index.html b/system/fonts/index.html index c942a79ce..c942a79ce 100644..100755 --- a/system/fonts/index.html +++ b/system/fonts/index.html diff --git a/system/fonts/texb.ttf b/system/fonts/texb.ttf Binary files differindex a7aa6469a..6792342a3 100644..100755 --- a/system/fonts/texb.ttf +++ b/system/fonts/texb.ttf diff --git a/system/helpers/array_helper.php b/system/helpers/array_helper.php index b7289900f..6b2415df2 100644..100755 --- a/system/helpers/array_helper.php +++ b/system/helpers/array_helper.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -38,7 +38,7 @@ * @param array * @param mixed * @return mixed depends on what the array contains - */ + */ if ( ! function_exists('element')) { function element($item, $array, $default = FALSE) @@ -49,7 +49,7 @@ if ( ! function_exists('element')) } return $array[$item]; - } + } } // ------------------------------------------------------------------------ @@ -60,7 +60,7 @@ if ( ! function_exists('element')) * @access public * @param array * @return mixed depends on what the array contains - */ + */ if ( ! function_exists('random_element')) { function random_element($array) @@ -70,9 +70,49 @@ if ( ! function_exists('random_element')) return $array; } return $array[array_rand($array)]; - } + } } +// -------------------------------------------------------------------- + +/** + * Elements + * + * Returns only the array items specified. Will return a default value if + * it is not set. + * + * @access public + * @param array + * @param array + * @param mixed + * @return mixed depends on what the array contains + */ +if ( ! function_exists('elements')) +{ + function elements($items, $array, $default = FALSE) + { + $return = array(); + + if ( ! is_array($items)) + { + $items = array($items); + } + + foreach ($items as $item) + { + if (isset($array[$item])) + { + $return[$item] = $array[$item]; + } + else + { + $return[$item] = $default; + } + } + + return $return; + } +} /* End of file array_helper.php */ /* Location: ./system/helpers/array_helper.php */
\ No newline at end of file diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php new file mode 100755 index 000000000..c0e3798f4 --- /dev/null +++ b/system/helpers/captcha_helper.php @@ -0,0 +1,246 @@ +<?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 CAPTCHA Helper + * + * @package CodeIgniter + * @subpackage Helpers + * @category Helpers + * @author ExpressionEngine Dev Team + * @link http://codeigniter.com/user_guide/helpers/xml_helper.html + */ + +// ------------------------------------------------------------------------ + +/** + * Create CAPTCHA + * + * @access public + * @param array array of data for the CAPTCHA + * @param string path to create the image in + * @param string URL to the CAPTCHA image folder + * @param string server path to font + * @return string + */ +if ( ! function_exists('create_captcha')) +{ + function create_captcha($data = '', $img_path = '', $img_url = '', $font_path = '') + { + $defaults = array('word' => '', 'img_path' => '', 'img_url' => '', 'img_width' => '150', 'img_height' => '30', 'font_path' => '', 'expiration' => 7200); + + foreach ($defaults as $key => $val) + { + if ( ! is_array($data)) + { + if ( ! isset($$key) OR $$key == '') + { + $$key = $val; + } + } + else + { + $$key = ( ! isset($data[$key])) ? $val : $data[$key]; + } + } + + if ($img_path == '' OR $img_url == '') + { + return FALSE; + } + + if ( ! @is_dir($img_path)) + { + return FALSE; + } + + if ( ! is_writable($img_path)) + { + return FALSE; + } + + if ( ! extension_loaded('gd')) + { + return FALSE; + } + + // ----------------------------------- + // Remove old images + // ----------------------------------- + + list($usec, $sec) = explode(" ", microtime()); + $now = ((float)$usec + (float)$sec); + + $current_dir = @opendir($img_path); + + while($filename = @readdir($current_dir)) + { + if ($filename != "." and $filename != ".." and $filename != "index.html") + { + $name = str_replace(".jpg", "", $filename); + + if (($name + $expiration) < $now) + { + @unlink($img_path.$filename); + } + } + } + + @closedir($current_dir); + + // ----------------------------------- + // Do we have a "word" yet? + // ----------------------------------- + + if ($word == '') + { + $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + + $str = ''; + for ($i = 0; $i < 8; $i++) + { + $str .= substr($pool, mt_rand(0, strlen($pool) -1), 1); + } + + $word = $str; + } + + // ----------------------------------- + // Determine angle and position + // ----------------------------------- + + $length = strlen($word); + $angle = ($length >= 6) ? rand(-($length-6), ($length-6)) : 0; + $x_axis = rand(6, (360/$length)-16); + $y_axis = ($angle >= 0 ) ? rand($img_height, $img_width) : rand(6, $img_height); + + // ----------------------------------- + // Create image + // ----------------------------------- + + // PHP.net recommends imagecreatetruecolor(), but it isn't always available + if (function_exists('imagecreatetruecolor')) + { + $im = imagecreatetruecolor($img_width, $img_height); + } + else + { + $im = imagecreate($img_width, $img_height); + } + + // ----------------------------------- + // Assign colors + // ----------------------------------- + + $bg_color = imagecolorallocate ($im, 255, 255, 255); + $border_color = imagecolorallocate ($im, 153, 102, 102); + $text_color = imagecolorallocate ($im, 204, 153, 153); + $grid_color = imagecolorallocate($im, 255, 182, 182); + $shadow_color = imagecolorallocate($im, 255, 240, 240); + + // ----------------------------------- + // Create the rectangle + // ----------------------------------- + + ImageFilledRectangle($im, 0, 0, $img_width, $img_height, $bg_color); + + // ----------------------------------- + // Create the spiral pattern + // ----------------------------------- + + $theta = 1; + $thetac = 7; + $radius = 16; + $circles = 20; + $points = 32; + + for ($i = 0; $i < ($circles * $points) - 1; $i++) + { + $theta = $theta + $thetac; + $rad = $radius * ($i / $points ); + $x = ($rad * cos($theta)) + $x_axis; + $y = ($rad * sin($theta)) + $y_axis; + $theta = $theta + $thetac; + $rad1 = $radius * (($i + 1) / $points); + $x1 = ($rad1 * cos($theta)) + $x_axis; + $y1 = ($rad1 * sin($theta )) + $y_axis; + imageline($im, $x, $y, $x1, $y1, $grid_color); + $theta = $theta - $thetac; + } + + // ----------------------------------- + // Write the text + // ----------------------------------- + + $use_font = ($font_path != '' AND file_exists($font_path) AND function_exists('imagettftext')) ? TRUE : FALSE; + + if ($use_font == FALSE) + { + $font_size = 5; + $x = rand(0, $img_width/($length/3)); + $y = 0; + } + else + { + $font_size = 16; + $x = rand(0, $img_width/($length/1.5)); + $y = $font_size+2; + } + + for ($i = 0; $i < strlen($word); $i++) + { + if ($use_font == FALSE) + { + $y = rand(0 , $img_height/2); + imagestring($im, $font_size, $x, $y, substr($word, $i, 1), $text_color); + $x += ($font_size*2); + } + else + { + $y = rand($img_height/2, $img_height-3); + imagettftext($im, $font_size, $angle, $x, $y, $text_color, $font_path, substr($word, $i, 1)); + $x += $font_size; + } + } + + + // ----------------------------------- + // Create the border + // ----------------------------------- + + imagerectangle($im, 0, 0, $img_width-1, $img_height-1, $border_color); + + // ----------------------------------- + // Generate the image + // ----------------------------------- + + $img_name = $now.'.jpg'; + + ImageJPEG($im, $img_path.$img_name); + + $img = "<img src=\"$img_url$img_name\" width=\"$img_width\" height=\"$img_height\" style=\"border:0;\" alt=\" \" />"; + + ImageDestroy($im); + + return array('word' => $word, 'time' => $now, 'image' => $img); + } +} + +// ------------------------------------------------------------------------ + +/* End of file captcha_helper.php */ +/* Location: ./system/heleprs/captcha_helper.php */
\ No newline at end of file diff --git a/system/helpers/compatibility_helper.php b/system/helpers/compatibility_helper.php deleted file mode 100644 index e7b21c660..000000000 --- a/system/helpers/compatibility_helper.php +++ /dev/null @@ -1,498 +0,0 @@ -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); -/** - * CodeIgniter - * - * An open source application development framework for PHP 4.3.2 or newer - * - * @package CodeIgniter - * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. - * @license http://codeigniter.com/user_guide/license.html - * @link http://codeigniter.com - * @since Version 1.0 - * @filesource - */ - -// ------------------------------------------------------------------------ - -/** - * CodeIgniter Compatibility Helpers - * - * This helper contains some functions based on the PEAR PHP_Compat library - * http://pear.php.net/package/PHP_Compat - * - * The PEAR compat library is a little bloated and the code doesn't harmonize - * well with CodeIgniter, so those functions have been refactored. - * We cheat a little and use CI's _exception_handler() to output our own PHP errors - * so that the behavior fully mimicks the PHP 5 counterparts. -- Derek Jones - * - * @package CodeIgniter - * @subpackage Helpers - * @category Helpers - * @author ExpressionEngine Dev Team - * @link http://codeigniter.com/user_guide/helpers/compatibility_helper.html - */ - -// ------------------------------------------------------------------------ - -if ( ! defined('PHP_EOL')) -{ - define('PHP_EOL', (DIRECTORY_SEPARATOR == '/') ? "\n" : "\r\n"); -} - -// ------------------------------------------------------------------------ - -/** - * file_put_contents() - * - * Writes a string to a file - * http://us.php.net/manual/en/function.file_put_contents.php - * argument 4, $context, not supported - * - * @access public - * @param string file name - * @param mixed data to be written - * @param int flags - * @return int length of written string - */ -if ( ! function_exists('file_put_contents')) -{ - function file_put_contents($filename, $data, $flags = NULL) - { - if (is_scalar($data)) - { - settype($data, 'STRING'); - } - - if ( ! is_string($data) && ! is_array($data) && ! is_resource($data)) - { - $backtrace = debug_backtrace(); - _exception_handler(E_USER_WARNING, 'file_put_contents(): the 2nd parameter should be either a string or an array', $backtrace[0]['file'], $backtrace[0]['line']); - return FALSE; - } - - // read stream if given a stream resource - if (is_resource($data)) - { - if (get_resource_type($data) !== 'stream') - { - $backtrace = debug_backtrace(); - _exception_handler(E_USER_WARNING, 'file_put_contents(): supplied resource is not a valid stream resource', $backtrace[0]['file'], $backtrace[0]['line']); - return FALSE; - } - - $text = ''; - - while ( ! feof($data)) - { - $text .= fread($data, 4096); - } - - $data = $text; - unset($text); - } - - // strings only please! - if (is_array($data)) - { - $data = implode('', $data); - } - - // Set the appropriate mode - if (($flags & 8) > 0) // 8 = FILE_APPEND flag - { - $mode = FOPEN_WRITE_CREATE; - } - else - { - $mode = FOPEN_WRITE_CREATE_DESTRUCTIVE; - } - - // Check if we're using the include path - if (($flags & 1) > 0) // 1 = FILE_USE_INCLUDE_PATH flag - { - $use_include_path = TRUE; - } - else - { - $use_include_path = FALSE; - } - - $fp = @fopen($filename, $mode, $use_include_path); - - if ($fp === FALSE) - { - $backtrace = debug_backtrace(); - _exception_handler(E_USER_WARNING, 'file_put_contents('.htmlentities($filename).') failed to open stream', $backtrace[0]['file'], $backtrace[0]['line']); - return FALSE; - } - - if (($flags & LOCK_EX) > 0) - { - if ( ! flock($fp, LOCK_EX)) - { - $backtrace = debug_backtrace(); - _exception_handler(E_USER_WARNING, 'file_put_contents('.htmlentities($filename).') unable to acquire an exclusive lock on file', $backtrace[0]['file'], $backtrace[0]['line']); - return FALSE; - } - } - - // write it - if (($written = @fwrite($fp, $data)) === FALSE) - { - $backtrace = debug_backtrace(); - _exception_handler(E_USER_WARNING, 'file_put_contents('.htmlentities($filename).') failed to write to '.htmlentities($filename), $backtrace[0]['file'], $backtrace[0]['line']); - } - - // Close the handle - @fclose($fp); - - // Return length - return $written; - } -} - -// ------------------------------------------------------------------------ - -/** - * fputcsv() - * - * Format line as CSV and write to file pointer - * http://us.php.net/manual/en/function.fputcsv.php - * - * @access public - * @param resource file pointer - * @param array data to be written - * @param string delimiter - * @param string enclosure - * @return int length of written string - */ -if ( ! function_exists('fputcsv')) -{ - function fputcsv($handle, $fields, $delimiter = ',', $enclosure = '"') - { - // Checking for a handle resource - if ( ! is_resource($handle)) - { - $backtrace = debug_backtrace(); - _exception_handler(E_USER_WARNING, 'fputcsv() expects parameter 1 to be stream resource, '.gettype($handle).' given', $backtrace[0]['file'], $backtrace[0]['line']); - return FALSE; - } - - // OK, it is a resource, but is it a stream? - if (get_resource_type($handle) !== 'stream') - { - $backtrace = debug_backtrace(); - _exception_handler(E_USER_WARNING, 'fputcsv() expects parameter 1 to be stream resource, '.get_resource_type($handle).' given', $backtrace[0]['file'], $backtrace[0]['line']); - return FALSE; - } - - // Checking for an array of fields - if ( ! is_array($fields)) - { - $backtrace = debug_backtrace(); - _exception_handler(E_USER_WARNING, 'fputcsv() expects parameter 2 to be array, '.gettype($fields).' given', $backtrace[0]['file'], $backtrace[0]['line']); - return FALSE; - } - - // validate delimiter - if (strlen($delimiter) > 1) - { - $delimiter = substr($delimiter, 0, 1); - $backtrace = debug_backtrace(); - _exception_handler(E_NOTICE, 'fputcsv() delimiter must be one character long, "'.htmlentities($delimiter).'" used', $backtrace[0]['file'], $backtrace[0]['line']); - } - - // validate enclosure - if (strlen($enclosure) > 1) - { - $enclosure = substr($enclosure, 0, 1); - $backtrace = debug_backtrace(); - _exception_handler(E_NOTICE, 'fputcsv() enclosure must be one character long, "'.htmlentities($enclosure).'" used', $backtrace[0]['file'], $backtrace[0]['line']); - - } - - $out = ''; - - foreach ($fields as $cell) - { - $cell = str_replace($enclosure, $enclosure.$enclosure, $cell); - - if (strpos($cell, $delimiter) !== FALSE OR strpos($cell, $enclosure) !== FALSE OR strpos($cell, "\n") !== FALSE) - { - $out .= $enclosure.$cell.$enclosure.$delimiter; - } - else - { - $out .= $cell.$delimiter; - } - } - - $length = @fwrite($handle, substr($out, 0, -1)."\n"); - - return $length; - } -} - -// ------------------------------------------------------------------------ - -/** - * stripos() - * - * Find position of first occurrence of a case-insensitive string - * http://us.php.net/manual/en/function.stripos.php - * - * @access public - * @param string haystack - * @param string needle - * @param int offset - * @return int numeric position of the first occurrence of needle in the haystack - */ -if ( ! function_exists('stripos')) -{ - function stripos($haystack, $needle, $offset = NULL) - { - // Cast non string scalar values - if (is_scalar($haystack)) - { - settype($haystack, 'STRING'); - } - - if ( ! is_string($haystack)) - { - $backtrace = debug_backtrace(); - _exception_handler(E_USER_WARNING, 'stripos() expects parameter 1 to be string, '.gettype($haystack).' given', $backtrace[0]['file'], $backtrace[0]['line']); - return FALSE; - } - - if ( ! is_scalar($needle)) - { - $backtrace = debug_backtrace(); - _exception_handler(E_USER_WARNING, 'stripos() needle is not a string or an integer in '.$backtrace[0]['file'], $backtrace[0]['line']); - return FALSE; - } - - if (is_float($offset)) - { - $offset = (int)$offset; - } - - if ( ! is_int($offset) && ! is_bool($offset) && ! is_null($offset)) - { - $backtrace = debug_backtrace(); - _exception_handler(E_USER_WARNING, 'stripos() expects parameter 3 to be long, '.gettype($offset).' given', $backtrace[0]['file'], $backtrace[0]['line']); - return NULL; - } - - return strpos(strtolower($haystack), strtolower($needle), $offset); - } -} - -// ------------------------------------------------------------------------ - -/** - * str_ireplace() - * - * Find position of first occurrence of a case-insensitive string - * http://us.php.net/manual/en/function.str-ireplace.php - * (parameter 4, $count, is not supported as to do so in PHP 4 would make - * it a required parameter) - * - * @access public - * @param mixed search - * @param mixed replace - * @param mixed subject - * @return int numeric position of the first occurrence of needle in the haystack - */ -if ( ! function_exists('str_ireplace')) -{ - function str_ireplace($search, $replace, $subject) - { - // Nothing to do here - if ($search === NULL OR $subject === NULL) - { - return $subject; - } - - // Crazy arguments - if (is_scalar($search) && is_array($replace)) - { - $backtrace = debug_backtrace(); - - if (is_object($replace)) - { - show_error('Object of class '.get_class($replace).' could not be converted to string in '.$backtrace[0]['file'].' on line '.$backtrace[0]['line']); - } - else - { - _exception_handler(E_USER_NOTICE, 'Array to string conversion in '.$backtrace[0]['file'], $backtrace[0]['line']); - } - } - - // Searching for an array - if (is_array($search)) - { - // Replacing with an array - if (is_array($replace)) - { - $search = array_values($search); - $replace = array_values($replace); - - if (count($search) >= count($replace)) - { - $replace = array_pad($replace, count($search), ''); - } - else - { - $replace = array_slice($replace, 0, count($search)); - } - } - else - { - // Replacing with a string all positions - $replace = array_fill(0, count($search), $replace); - } - } - else - { - //Searching for a string and replacing with a string. - $search = array((string)$search); - $replace = array((string)$replace); - } - - // Prepare the search array - foreach ($search as $search_key => $search_value) - { - $search[$search_key] = '/'.preg_quote($search_value, '/').'/i'; - } - - // Prepare the replace array (escape backreferences) - foreach ($replace as $k => $v) - { - $replace[$k] = str_replace(array(chr(92), '$'), array(chr(92).chr(92), '\$'), $v); - } - - // do the replacement - $result = preg_replace($search, $replace, (array)$subject); - - // Check if subject was initially a string and return it as a string - if ( ! is_array($subject)) - { - return current($result); - } - - // Otherwise, just return the array - return $result; - } -} - -// ------------------------------------------------------------------------ - -/** - * http_build_query() - * - * Generate URL-encoded query string - * http://us.php.net/manual/en/function.http-build-query.php - * - * @access public - * @param array form data - * @param string numeric prefix - * @param string argument separator - * @return string URL-encoded string - */ -if ( ! function_exists('http_build_query')) -{ - function http_build_query($formdata, $numeric_prefix = NULL, $separator = NULL) - { - // Check the data - if ( ! is_array($formdata) && ! is_object($formdata)) - { - $backtrace = debug_backtrace(); - _exception_handler(E_USER_WARNING, 'http_build_query() Parameter 1 expected to be Array or Object. Incorrect value given', $backtrace[0]['file'], $backtrace[0]['line']); - return FALSE; - } - - // Cast it as array - if (is_object($formdata)) - { - $formdata = get_object_vars($formdata); - } - - // If the array is empty, return NULL - if (empty($formdata)) - { - return NULL; - } - - // Argument separator - if ($separator === NULL) - { - $separator = ini_get('arg_separator.output'); - - if (strlen($separator) == 0) - { - $separator = '&'; - } - } - - // Start building the query - $tmp = array(); - - foreach ($formdata as $key => $val) - { - if ($val === NULL) - { - continue; - } - - if (is_integer($key) && $numeric_prefix != NULL) - { - $key = $numeric_prefix.$key; - } - - if (is_resource($val)) - { - return NULL; - } - - // hand it off to a recursive parser - $tmp[] = _http_build_query_helper($key, $val, $separator); - } - - return implode($separator, $tmp); - } - - - // Helper helper. Remind anyone of college? - // Required to handle recursion in nested arrays. - // - // You could shave fractions of fractions of a second by moving where - // the urlencoding takes place, but it's much less intuitive, and if - // your application has 10,000 form fields, well, you have other problems ;) - function _http_build_query_helper($key, $val, $separator = '&') - { - if (is_scalar($val)) - { - return urlencode($key).'='.urlencode($val); - } - else - { - // arrays please - if (is_object($val)) - { - $val = get_object_vars($val); - } - - foreach ($val as $k => $v) - { - $tmp[] = _http_build_query_helper($key.'['.$k.']', $v, $separator); - } - } - - return implode($separator, $tmp); - } -} - - -/* End of file compatibility_helper.php */ -/* Location: ./system/helpers/compatibility_helper.php */
\ No newline at end of file diff --git a/system/helpers/cookie_helper.php b/system/helpers/cookie_helper.php index 40afadb57..7701d503f 100644..100755 --- a/system/helpers/cookie_helper.php +++ b/system/helpers/cookie_helper.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -46,53 +46,12 @@ if ( ! function_exists('set_cookie')) { function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '') { - if (is_array($name)) - { - foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'name') as $item) - { - if (isset($name[$item])) - { - $$item = $name[$item]; - } - } - } - // Set the config file options $CI =& get_instance(); - - if ($prefix == '' AND $CI->config->item('cookie_prefix') != '') - { - $prefix = $CI->config->item('cookie_prefix'); - } - if ($domain == '' AND $CI->config->item('cookie_domain') != '') - { - $domain = $CI->config->item('cookie_domain'); - } - if ($path == '/' AND $CI->config->item('cookie_path') != '/') - { - $path = $CI->config->item('cookie_path'); - } - - if ( ! is_numeric($expire)) - { - $expire = time() - 86500; - } - else - { - if ($expire > 0) - { - $expire = time() + $expire; - } - else - { - $expire = 0; - } - } - - setcookie($prefix.$name, $value, $expire, $path, $domain, 0); + $CI->input->set_cookie($name, $value, $expire, $domain, $path, $prefix); } } - + // -------------------------------------------------------------------- /** @@ -108,14 +67,14 @@ if ( ! function_exists('get_cookie')) function get_cookie($index = '', $xss_clean = FALSE) { $CI =& get_instance(); - + $prefix = ''; - + if ( ! isset($_COOKIE[$index]) && config_item('cookie_prefix') != '') { $prefix = config_item('cookie_prefix'); } - + return $CI->input->cookie($prefix.$index, $xss_clean); } } diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 0e9781666..553e8d7ee 100644..100755 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -34,24 +34,24 @@ * * @access public * @return integer - */ + */ if ( ! function_exists('now')) { function now() { $CI =& get_instance(); - + if (strtolower($CI->config->item('time_reference')) == 'gmt') { $now = time(); $system_time = mktime(gmdate("H", $now), gmdate("i", $now), gmdate("s", $now), gmdate("m", $now), gmdate("d", $now), gmdate("Y", $now)); - + if (strlen($system_time) < 10) { $system_time = time(); log_message('error', 'The Date class could not set a proper GMT timestamp so the local time() value was used.'); } - + return $system_time; } else @@ -60,7 +60,7 @@ if ( ! function_exists('now')) } } } - + // ------------------------------------------------------------------------ /** @@ -79,22 +79,22 @@ if ( ! function_exists('now')) * @param string * @param integer * @return integer - */ + */ if ( ! function_exists('mdate')) { function mdate($datestr = '', $time = '') { if ($datestr == '') return ''; - + if ($time == '') $time = now(); - + $datestr = str_replace('%\\', '', preg_replace("/([a-z]+?){1}/i", "\\\\\\1", $datestr)); return date($datestr, $time); } } - + // ------------------------------------------------------------------------ /** @@ -106,7 +106,7 @@ if ( ! function_exists('mdate')) * @param string the chosen format * @param integer Unix timestamp * @return string - */ + */ if ( ! function_exists('standard_date')) { function standard_date($fmt = 'DATE_RFC822', $time = '') @@ -114,7 +114,7 @@ if ( ! function_exists('standard_date')) $formats = array( 'DATE_ATOM' => '%Y-%m-%dT%H:%i:%s%Q', 'DATE_COOKIE' => '%l, %d-%M-%y %H:%i:%s UTC', - 'DATE_ISO8601' => '%Y-%m-%dT%H:%i:%s%O', + 'DATE_ISO8601' => '%Y-%m-%dT%H:%i:%s%Q', 'DATE_RFC822' => '%D, %d %M %y %H:%i:%s %O', 'DATE_RFC850' => '%l, %d-%M-%y %H:%m:%i UTC', 'DATE_RFC1036' => '%D, %d %M %y %H:%i:%s %O', @@ -127,11 +127,11 @@ if ( ! function_exists('standard_date')) { return FALSE; } - + return mdate($formats[$fmt], $time); } } - + // ------------------------------------------------------------------------ /** @@ -144,7 +144,7 @@ if ( ! function_exists('standard_date')) * @param integer a number of seconds * @param integer Unix timestamp * @return integer - */ + */ if ( ! function_exists('timespan')) { function timespan($seconds = 1, $time = '') @@ -156,12 +156,12 @@ if ( ! function_exists('timespan')) { $seconds = 1; } - + if ( ! is_numeric($time)) { $time = time(); } - + if ($time <= $seconds) { $seconds = 1; @@ -170,85 +170,85 @@ if ( ! function_exists('timespan')) { $seconds = $time - $seconds; } - + $str = ''; $years = floor($seconds / 31536000); - + if ($years > 0) - { + { $str .= $years.' '.$CI->lang->line((($years > 1) ? 'date_years' : 'date_year')).', '; - } - + } + $seconds -= $years * 31536000; $months = floor($seconds / 2628000); - + if ($years > 0 OR $months > 0) { if ($months > 0) - { + { $str .= $months.' '.$CI->lang->line((($months > 1) ? 'date_months' : 'date_month')).', '; - } - + } + $seconds -= $months * 2628000; } $weeks = floor($seconds / 604800); - + if ($years > 0 OR $months > 0 OR $weeks > 0) { if ($weeks > 0) - { + { $str .= $weeks.' '.$CI->lang->line((($weeks > 1) ? 'date_weeks' : 'date_week')).', '; } - + $seconds -= $weeks * 604800; - } + } $days = floor($seconds / 86400); - + if ($months > 0 OR $weeks > 0 OR $days > 0) { if ($days > 0) - { + { $str .= $days.' '.$CI->lang->line((($days > 1) ? 'date_days' : 'date_day')).', '; } - + $seconds -= $days * 86400; } - + $hours = floor($seconds / 3600); - + if ($days > 0 OR $hours > 0) { if ($hours > 0) { $str .= $hours.' '.$CI->lang->line((($hours > 1) ? 'date_hours' : 'date_hour')).', '; } - + $seconds -= $hours * 3600; } - + $minutes = floor($seconds / 60); - + if ($days > 0 OR $hours > 0 OR $minutes > 0) { if ($minutes > 0) - { + { $str .= $minutes.' '.$CI->lang->line((($minutes > 1) ? 'date_minutes' : 'date_minute')).', '; } - + $seconds -= $minutes * 60; } - + if ($str == '') { $str .= $seconds.' '.$CI->lang->line((($seconds > 1) ? 'date_seconds' : 'date_second')).', '; } - + return substr(trim($str), 0, -1); } } - + // ------------------------------------------------------------------------ /** @@ -261,7 +261,7 @@ if ( ! function_exists('timespan')) * @param integer a numeric month * @param integer a numeric year * @return integer - */ + */ if ( ! function_exists('days_in_month')) { function days_in_month($month = 0, $year = '') @@ -270,12 +270,12 @@ if ( ! function_exists('days_in_month')) { return 0; } - + if ( ! is_numeric($year) OR strlen($year) != 4) { $year = date('Y'); } - + if ($month == 2) { if ($year % 400 == 0 OR ($year % 4 == 0 AND $year % 100 != 0)) @@ -288,7 +288,7 @@ if ( ! function_exists('days_in_month')) return $days_in_month[$month - 1]; } } - + // ------------------------------------------------------------------------ /** @@ -297,18 +297,18 @@ if ( ! function_exists('days_in_month')) * @access public * @param integer Unix timestamp * @return integer - */ + */ if ( ! function_exists('local_to_gmt')) { function local_to_gmt($time = '') { if ($time == '') $time = time(); - + return mktime( gmdate("H", $time), gmdate("i", $time), gmdate("s", $time), gmdate("m", $time), gmdate("d", $time), gmdate("Y", $time)); } } - + // ------------------------------------------------------------------------ /** @@ -323,27 +323,27 @@ if ( ! function_exists('local_to_gmt')) * @param string timezone * @param bool whether DST is active * @return integer - */ + */ if ( ! function_exists('gmt_to_local')) { function gmt_to_local($time = '', $timezone = 'UTC', $dst = FALSE) - { + { if ($time == '') { return now(); } - + $time += timezones($timezone) * 3600; if ($dst == TRUE) { $time += 3600; } - + return $time; } } - + // ------------------------------------------------------------------------ /** @@ -352,7 +352,7 @@ if ( ! function_exists('gmt_to_local')) * @access public * @param integer Unix timestamp * @return integer - */ + */ if ( ! function_exists('mysql_to_unix')) { function mysql_to_unix($time = '') @@ -360,11 +360,11 @@ if ( ! function_exists('mysql_to_unix')) // We'll remove certain characters for backward compatibility // since the formatting changed with MySQL 4.1 // YYYY-MM-DD HH:MM:SS - + $time = str_replace('-', '', $time); $time = str_replace(':', '', $time); $time = str_replace(' ', '', $time); - + // YYYYMMDDHHMMSS return mktime( substr($time, 8, 2), @@ -376,7 +376,7 @@ if ( ! function_exists('mysql_to_unix')) ); } } - + // ------------------------------------------------------------------------ /** @@ -389,13 +389,13 @@ if ( ! function_exists('mysql_to_unix')) * @param bool whether to show seconds * @param string format: us or euro * @return string - */ + */ if ( ! function_exists('unix_to_human')) { function unix_to_human($time = '', $seconds = FALSE, $fmt = 'us') { $r = date('Y', $time).'-'.date('m', $time).'-'.date('d', $time).' '; - + if ($fmt == 'us') { $r .= date('h', $time).':'.date('i', $time); @@ -404,21 +404,21 @@ if ( ! function_exists('unix_to_human')) { $r .= date('H', $time).':'.date('i', $time); } - + if ($seconds) { $r .= ':'.date('s', $time); } - + if ($fmt == 'us') { $r .= ' '.date('A', $time); } - + return $r; } } - + // ------------------------------------------------------------------------ /** @@ -429,7 +429,7 @@ if ( ! function_exists('unix_to_human')) * @access public * @param string format: us or euro * @return integer - */ + */ if ( ! function_exists('human_to_unix')) { function human_to_unix($datestr = '') @@ -438,25 +438,25 @@ if ( ! function_exists('human_to_unix')) { return FALSE; } - + $datestr = trim($datestr); - $datestr = preg_replace("/\040+/", "\040", $datestr); + $datestr = preg_replace("/\040+/", ' ', $datestr); if ( ! preg_match('/^[0-9]{2,4}\-[0-9]{1,2}\-[0-9]{1,2}\s[0-9]{1,2}:[0-9]{1,2}(?::[0-9]{1,2})?(?:\s[AP]M)?$/i', $datestr)) { return FALSE; } - $split = preg_split("/\040/", $datestr); + $split = explode(' ', $datestr); $ex = explode("-", $split['0']); - + $year = (strlen($ex['0']) == 2) ? '20'.$ex['0'] : $ex['0']; $month = (strlen($ex['1']) == 1) ? '0'.$ex['1'] : $ex['1']; $day = (strlen($ex['2']) == 1) ? '0'.$ex['2'] : $ex['2']; $ex = explode(":", $split['1']); - + $hour = (strlen($ex['0']) == 1) ? '0'.$ex['0'] : $ex['0']; $min = (strlen($ex['1']) == 1) ? '0'.$ex['1'] : $ex['1']; @@ -469,25 +469,25 @@ if ( ! function_exists('human_to_unix')) // Unless specified, seconds get set to zero. $sec = '00'; } - + if (isset($split['2'])) { $ampm = strtolower($split['2']); - + if (substr($ampm, 0, 1) == 'p' AND $hour < 12) $hour = $hour + 12; - + if (substr($ampm, 0, 1) == 'a' AND $hour == 12) $hour = '00'; - + if (strlen($hour) == 1) $hour = '0'.$hour; } - + return mktime($hour, $min, $sec, $month, $day, $year); } } - + // ------------------------------------------------------------------------ /** @@ -500,26 +500,26 @@ if ( ! function_exists('human_to_unix')) * @param string classname * @param string menu name * @return string - */ + */ if ( ! function_exists('timezone_menu')) { function timezone_menu($default = 'UTC', $class = "", $name = 'timezones') { $CI =& get_instance(); $CI->lang->load('date'); - + if ($default == 'GMT') $default = 'UTC'; $menu = '<select name="'.$name.'"'; - + if ($class != '') { $menu .= ' class="'.$class.'"'; } - + $menu .= ">\n"; - + foreach (timezones() as $key => $val) { $selected = ($default == $key) ? " selected='selected'" : ''; @@ -531,7 +531,7 @@ if ( ! function_exists('timezone_menu')) return $menu; } } - + // ------------------------------------------------------------------------ /** @@ -543,15 +543,15 @@ if ( ! function_exists('timezone_menu')) * @access public * @param string timezone * @return string - */ + */ if ( ! function_exists('timezones')) { function timezones($tz = '') { // Note: Don't change the order of these even though // some items appear to be in the wrong order - - $zones = array( + + $zones = array( 'UM12' => -12, 'UM11' => -11, 'UM10' => -10, @@ -593,15 +593,15 @@ if ( ! function_exists('timezones')) 'UP13' => +13, 'UP14' => +14 ); - + if ($tz == '') { return $zones; } - + if ($tz == 'GMT') $tz = 'UTC'; - + return ( ! isset($zones[$tz])) ? 0 : $zones[$tz]; } } diff --git a/system/helpers/directory_helper.php b/system/helpers/directory_helper.php index 791cf0d10..38347fa62 100644..100755 --- a/system/helpers/directory_helper.php +++ b/system/helpers/directory_helper.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -36,46 +36,42 @@ * * @access public * @param string path to source - * @param bool whether to limit the result to the top level only + * @param int depth of directories to traverse (0 = fully recursive, 1 = current dir, etc) * @return array - */ + */ if ( ! function_exists('directory_map')) { - function directory_map($source_dir, $top_level_only = FALSE, $hidden = FALSE) - { + function directory_map($source_dir, $directory_depth = 0, $hidden = FALSE) + { if ($fp = @opendir($source_dir)) { - $source_dir = rtrim($source_dir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; - $filedata = array(); - + $filedata = array(); + $new_depth = $directory_depth - 1; + $source_dir = rtrim($source_dir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; + while (FALSE !== ($file = readdir($fp))) { - if (($hidden == FALSE && strncmp($file, '.', 1) == 0) OR ($file == '.' OR $file == '..')) + // Remove '.', '..', and hidden files [optional] + if ( ! trim($file, '.') OR ($hidden == FALSE && $file[0] == '.')) { continue; } - - if ($top_level_only == FALSE && @is_dir($source_dir.$file)) + + if (($directory_depth < 1 OR $new_depth > 0) && @is_dir($source_dir.$file)) { - $temp_array = array(); - - $temp_array = directory_map($source_dir.$file.DIRECTORY_SEPARATOR, $top_level_only, $hidden); - - $filedata[$file] = $temp_array; + $filedata[$file] = directory_map($source_dir.$file.DIRECTORY_SEPARATOR, $new_depth, $hidden); } else { $filedata[] = $file; } } - + closedir($fp); return $filedata; } - else - { - return FALSE; - } + + return FALSE; } } diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index 638ebaa88..6cecd0d11 100644..100755 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -36,7 +36,7 @@ * @param string filename * @param mixed the data to be downloaded * @return void - */ + */ if ( ! function_exists('force_download')) { function force_download($filename = '', $data = '') @@ -52,14 +52,14 @@ if ( ! function_exists('force_download')) { return FALSE; } - + // Grab the file extension $x = explode('.', $filename); $extension = end($x); // Load the mime types @include(APPPATH.'config/mimes'.EXT); - + // Set a default mime if we can't find it if ( ! isset($mimes[$extension])) { @@ -69,9 +69,9 @@ if ( ! function_exists('force_download')) { $mime = (is_array($mimes[$extension])) ? $mimes[$extension][0] : $mimes[$extension]; } - + // Generate the server headers - if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")) + if (strpos($_SERVER['HTTP_USER_AGENT'], "MSIE") !== FALSE) { header('Content-Type: "'.$mime.'"'); header('Content-Disposition: attachment; filename="'.$filename.'"'); @@ -90,7 +90,7 @@ if ( ! function_exists('force_download')) header('Pragma: no-cache'); header("Content-Length: ".strlen($data)); } - + exit($data); } } diff --git a/system/helpers/email_helper.php b/system/helpers/email_helper.php index 046562a91..651aef439 100644..100755 --- a/system/helpers/email_helper.php +++ b/system/helpers/email_helper.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -32,7 +32,7 @@ * * @access public * @return bool - */ + */ if ( ! function_exists('valid_email')) { function valid_email($address) @@ -48,7 +48,7 @@ if ( ! function_exists('valid_email')) * * @access public * @return bool - */ + */ if ( ! function_exists('send_email')) { function send_email($recipient, $subject = 'Test email', $message = 'Hello World') diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php index fea54a1f6..334eef87c 100644..100755 --- a/system/helpers/file_helper.php +++ b/system/helpers/file_helper.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -35,7 +35,7 @@ * @access public * @param string path to file * @return string - */ + */ if ( ! function_exists('read_file')) { function read_file($file) @@ -44,19 +44,19 @@ if ( ! function_exists('read_file')) { return FALSE; } - + if (function_exists('file_get_contents')) { - return file_get_contents($file); + return file_get_contents($file); } if ( ! $fp = @fopen($file, FOPEN_READ)) { return FALSE; } - + flock($fp, LOCK_SH); - + $data = ''; if (filesize($file) > 0) { @@ -69,7 +69,7 @@ if ( ! function_exists('read_file')) return $data; } } - + // ------------------------------------------------------------------------ /** @@ -82,7 +82,7 @@ if ( ! function_exists('read_file')) * @param string path to file * @param string file data * @return bool - */ + */ if ( ! function_exists('write_file')) { function write_file($path, $data, $mode = FOPEN_WRITE_CREATE_DESTRUCTIVE) @@ -91,16 +91,16 @@ if ( ! function_exists('write_file')) { return FALSE; } - + flock($fp, LOCK_EX); fwrite($fp, $data); flock($fp, LOCK_UN); - fclose($fp); + fclose($fp); return TRUE; } } - + // ------------------------------------------------------------------------ /** @@ -115,17 +115,19 @@ if ( ! function_exists('write_file')) * @param string path to file * @param bool whether to delete any directories found in the path * @return bool - */ + */ if ( ! function_exists('delete_files')) { function delete_files($path, $del_dir = FALSE, $level = 0) - { + { // Trim the trailing slash $path = rtrim($path, DIRECTORY_SEPARATOR); - + if ( ! $current_dir = @opendir($path)) - return; - + { + return FALSE; + } + while(FALSE !== ($filename = @readdir($current_dir))) { if ($filename != "." and $filename != "..") @@ -136,7 +138,7 @@ if ( ! function_exists('delete_files')) if (substr($filename, 0, 1) != '.') { delete_files($path.DIRECTORY_SEPARATOR.$filename, $del_dir, $level + 1); - } + } } else { @@ -145,11 +147,13 @@ if ( ! function_exists('delete_files')) } } @closedir($current_dir); - + if ($del_dir == TRUE AND $level > 0) { - @rmdir($path); + return @rmdir($path); } + + return TRUE; } } @@ -158,7 +162,7 @@ if ( ! function_exists('delete_files')) /** * Get Filenames * - * Reads the specified directory and builds an array containing the filenames. + * Reads the specified directory and builds an array containing the filenames. * Any sub-folders contained within the specified path are read as well. * * @access public @@ -166,13 +170,13 @@ if ( ! function_exists('delete_files')) * @param bool whether to include the path as part of the filename * @param bool internal variable to determine recursion status - do not use in calls * @return array - */ + */ if ( ! function_exists('get_filenames')) { function get_filenames($source_dir, $include_path = FALSE, $_recursion = FALSE) { static $_filedata = array(); - + if ($fp = @opendir($source_dir)) { // reset the array and make sure $source_dir has a trailing slash on the initial call @@ -181,12 +185,12 @@ if ( ! function_exists('get_filenames')) $_filedata = array(); $source_dir = rtrim(realpath($source_dir), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; } - + while (FALSE !== ($file = readdir($fp))) { if (@is_dir($source_dir.$file) && strncmp($file, '.', 1) !== 0) { - get_filenames($source_dir.$file.DIRECTORY_SEPARATOR, $include_path, TRUE); + get_filenames($source_dir.$file.DIRECTORY_SEPARATOR, $include_path, TRUE); } elseif (strncmp($file, '.', 1) !== 0) { @@ -207,20 +211,20 @@ if ( ! function_exists('get_filenames')) /** * Get Directory File Information * - * Reads the specified directory and builds an array containing the filenames, + * Reads the specified directory and builds an array containing the filenames, * filesize, dates, and permissions * * Any sub-folders contained within the specified path are read as well. * * @access public * @param string path to source - * @param bool whether to include the path as part of the filename + * @param bool Look only at the top level directory specified? * @param bool internal variable to determine recursion status - do not use in calls * @return array - */ + */ if ( ! function_exists('get_dir_file_info')) { - function get_dir_file_info($source_dir, $include_path = FALSE, $_recursion = FALSE) + function get_dir_file_info($source_dir, $top_level_only = TRUE, $_recursion = FALSE) { static $_filedata = array(); $relative_path = $source_dir; @@ -234,11 +238,12 @@ if ( ! function_exists('get_dir_file_info')) $source_dir = rtrim(realpath($source_dir), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; } + // foreach (scandir($source_dir, 1) as $file) // In addition to being PHP5+, scandir() is simply not as fast while (FALSE !== ($file = readdir($fp))) { - if (@is_dir($source_dir.$file) && strncmp($file, '.', 1) !== 0) + if (@is_dir($source_dir.$file) AND strncmp($file, '.', 1) !== 0 AND $top_level_only === FALSE) { - get_dir_file_info($source_dir.$file.DIRECTORY_SEPARATOR, $include_path, TRUE); + get_dir_file_info($source_dir.$file.DIRECTORY_SEPARATOR, $top_level_only, TRUE); } elseif (strncmp($file, '.', 1) !== 0) { @@ -246,6 +251,7 @@ if ( ! function_exists('get_dir_file_info')) $_filedata[$file]['relative_path'] = $relative_path; } } + return $_filedata; } else @@ -299,7 +305,7 @@ if ( ! function_exists('get_file_info')) $fileinfo['size'] = filesize($file); break; case 'date': - $fileinfo['date'] = filectime($file); + $fileinfo['date'] = filemtime($file); break; case 'readable': $fileinfo['readable'] = is_readable($file); @@ -326,7 +332,7 @@ if ( ! function_exists('get_file_info')) /** * Get Mime by Extension * - * Translates a file extension into a mime type based on config/mimes.php. + * Translates a file extension into a mime type based on config/mimes.php. * Returns FALSE if it can't determine the type, or open the mime config file * * Note: this is NOT an accurate way of determining file mime types, and is here strictly as a convenience @@ -335,12 +341,12 @@ if ( ! function_exists('get_file_info')) * @access public * @param string path to file * @return mixed - */ + */ if ( ! function_exists('get_mime_by_extension')) { function get_mime_by_extension($file) { - $extension = substr(strrchr($file, '.'), 1); + $extension = strtolower(substr(strrchr($file, '.'), 1)); global $mimes; @@ -382,11 +388,11 @@ if ( ! function_exists('get_mime_by_extension')) * @access public * @param int * @return string - */ + */ if ( ! function_exists('symbolic_permissions')) { function symbolic_permissions($perms) - { + { if (($perms & 0xC000) == 0xC000) { $symbolic = 's'; // Socket @@ -435,7 +441,7 @@ if ( ! function_exists('symbolic_permissions')) $symbolic .= (($perms & 0x0002) ? 'w' : '-'); $symbolic .= (($perms & 0x0001) ? (($perms & 0x0200) ? 't' : 'x' ) : (($perms & 0x0200) ? 'T' : '-')); - return $symbolic; + return $symbolic; } } @@ -450,7 +456,7 @@ if ( ! function_exists('symbolic_permissions')) * @access public * @param int * @return string - */ + */ if ( ! function_exists('octal_permissions')) { function octal_permissions($perms) diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 31b36efd0..758056b50 100644..100755 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -37,7 +37,7 @@ * @param array a key/value pair of attributes * @param array a key/value pair hidden data * @return string - */ + */ if ( ! function_exists('form_open')) { function form_open($action = '', $attributes = '', $hidden = array()) @@ -52,14 +52,20 @@ if ( ! function_exists('form_open')) $action = ( strpos($action, '://') === FALSE) ? $CI->config->site_url($action) : $action; $form = '<form action="'.$action.'"'; - + $form .= _attributes_to_string($attributes, TRUE); - + $form .= '>'; + // CSRF + if ($CI->config->item('csrf_protection') === TRUE) + { + $hidden[$CI->security->csrf_token_name] = $CI->security->csrf_hash; + } + if (is_array($hidden) AND count($hidden) > 0) { - $form .= form_hidden($hidden); + $form .= sprintf("\n<div class=\"hidden\">%s</div>", form_hidden($hidden)); } return $form; @@ -83,7 +89,15 @@ if ( ! function_exists('form_open_multipart')) { function form_open_multipart($action, $attributes = array(), $hidden = array()) { - $attributes['enctype'] = 'multipart/form-data'; + if (is_string($attributes)) + { + $attributes .= ' enctype="multipart/form-data"'; + } + else + { + $attributes['enctype'] = 'multipart/form-data'; + } + return form_open($action, $attributes, $hidden); } } @@ -129,7 +143,7 @@ if ( ! function_exists('form_hidden')) { foreach ($value as $k => $v) { - $k = (is_int($k)) ? '' : $k; + $k = (is_int($k)) ? '' : $k; form_hidden($name.'['.$k.']', $v, TRUE); } } @@ -236,10 +250,10 @@ if ( ! function_exists('form_textarea')) } else { - $val = $data['value']; + $val = $data['value']; unset($data['value']); // textareas don't use the value attribute } - + $name = (is_array($data)) ? $data['name'] : $data; return "<textarea "._parse_form_attributes($data, $defaults).$extra.">".form_prep($val, $name)."</textarea>"; } @@ -257,7 +271,7 @@ if ( ! function_exists('form_textarea')) * @param string * @return type */ -if (! function_exists('form_multiselect')) +if ( ! function_exists('form_multiselect')) { function form_multiselect($name = '', $options = array(), $selected = array(), $extra = '') { @@ -265,7 +279,7 @@ if (! function_exists('form_multiselect')) { $extra .= ' multiple="multiple"'; } - + return form_dropdown($name, $options, $selected, $extra); } } @@ -311,7 +325,7 @@ if ( ! function_exists('form_dropdown')) { $key = (string) $key; - if (is_array($val)) + if (is_array($val) && ! empty($val)) { $form .= '<optgroup label="'.$key.'">'."\n"; @@ -400,7 +414,7 @@ if ( ! function_exists('form_radio')) function form_radio($data = '', $value = '', $checked = FALSE, $extra = '') { if ( ! is_array($data)) - { + { $data = array('name' => $data); } @@ -421,7 +435,7 @@ if ( ! function_exists('form_radio')) * @return string */ if ( ! function_exists('form_submit')) -{ +{ function form_submit($data = '', $value = '', $extra = '') { $defaults = array('type' => 'submit', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value); @@ -498,7 +512,7 @@ if ( ! function_exists('form_label')) if ($id != '') { - $label .= " for=\"$id\""; + $label .= " for=\"$id\""; } if (is_array($attributes) AND count($attributes) > 0) @@ -596,7 +610,7 @@ if ( ! function_exists('form_prep')) function form_prep($str = '', $field_name = '') { static $prepped_fields = array(); - + // if the field name is an array we do this recursively if (is_array($str)) { @@ -621,7 +635,7 @@ if ( ! function_exists('form_prep')) { return $str; } - + $str = htmlspecialchars($str); // In case htmlspecialchars misses these. @@ -629,9 +643,9 @@ if ( ! function_exists('form_prep')) if ($field_name != '') { - $prepped_fields[$field_name] = $str; + $prepped_fields[$field_name] = $field_name; } - + return $str; } } @@ -743,7 +757,7 @@ if ( ! function_exists('set_checkbox')) $OBJ =& _get_validation_object(); if ($OBJ === FALSE) - { + { if ( ! isset($_POST[$field])) { if (count($_POST) === 0 AND $default == TRUE) @@ -754,7 +768,7 @@ if ( ! function_exists('set_checkbox')) } $field = $_POST[$field]; - + if (is_array($field)) { if ( ! in_array($value, $field)) @@ -809,7 +823,7 @@ if ( ! function_exists('set_radio')) } $field = $_POST[$field]; - + if (is_array($field)) { if ( ! in_array($value, $field)) @@ -919,7 +933,7 @@ if ( ! function_exists('_parse_form_attributes')) } $att = ''; - + foreach ($default as $key => $val) { if ($key == 'value') @@ -957,9 +971,14 @@ if ( ! function_exists('_attributes_to_string')) $attributes .= ' method="post"'; } + if ($formtag == TRUE AND strpos($attributes, 'accept-charset=') === FALSE) + { + $attributes .= ' accept-charset="'.strtolower(config_item('charset')).'"'; + } + return ' '.$attributes; } - + if (is_object($attributes) AND count($attributes) > 0) { $attributes = (array)$attributes; @@ -967,19 +986,24 @@ if ( ! function_exists('_attributes_to_string')) if (is_array($attributes) AND count($attributes) > 0) { - $atts = ''; + $atts = ''; - if ( ! isset($attributes['method']) AND $formtag === TRUE) - { - $atts .= ' method="post"'; - } + if ( ! isset($attributes['method']) AND $formtag === TRUE) + { + $atts .= ' method="post"'; + } - foreach ($attributes as $key => $val) - { - $atts .= ' '.$key.'="'.$val.'"'; - } + if ( ! isset($attributes['accept-charset']) AND $formtag === TRUE) + { + $atts .= ' accept-charset="'.strtolower(config_item('charset')).'"'; + } + + foreach ($attributes as $key => $val) + { + $atts .= ' '.$key.'="'.$val.'"'; + } - return $atts; + return $atts; } } } diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php index c18a68778..68c6f5908 100644..100755 --- a/system/helpers/html_helper.php +++ b/system/helpers/html_helper.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -97,7 +97,7 @@ if ( ! function_exists('ol')) * @param string * @param mixed * @param mixed - * @param intiger + * @param integer * @return string */ if ( ! function_exists('_list')) @@ -199,6 +199,12 @@ if ( ! function_exists('img')) $src = array('src' => $src); } + // If there is no alt attribute defined, set it to an empty string + if ( ! isset($src['alt'])) + { + $src['alt'] = ''; + } + $img = '<img'; foreach ($src as $k=>$v) @@ -210,16 +216,16 @@ if ( ! function_exists('img')) if ($index_page === TRUE) { - $img .= ' src="'.$CI->config->site_url($v).'" '; + $img .= ' src="'.$CI->config->site_url($v).'"'; } else { - $img .= ' src="'.$CI->config->slash_item('base_url').$v.'" '; + $img .= ' src="'.$CI->config->slash_item('base_url').$v.'"'; } } else { - $img .= " $k=\"$v\" "; + $img .= " $k=\"$v\""; } } @@ -301,11 +307,11 @@ if ( ! function_exists('link_tag')) { if ($index_page === TRUE) { - $link .= ' href="'.$CI->config->site_url($v).'" '; + $link .= 'href="'.$CI->config->site_url($v).'" '; } else { - $link .= ' href="'.$CI->config->slash_item('base_url').$v.'" '; + $link .= 'href="'.$CI->config->slash_item('base_url').$v.'" '; } } else @@ -320,15 +326,15 @@ if ( ! function_exists('link_tag')) { if ( strpos($href, '://') !== FALSE) { - $link .= ' href="'.$href.'" '; + $link .= 'href="'.$href.'" '; } elseif ($index_page === TRUE) { - $link .= ' href="'.$CI->config->site_url($href).'" '; + $link .= 'href="'.$CI->config->site_url($href).'" '; } else { - $link .= ' href="'.$CI->config->slash_item('base_url').$href.'" '; + $link .= 'href="'.$CI->config->slash_item('base_url').$href.'" '; } $link .= 'rel="'.$rel.'" type="'.$type.'" '; @@ -382,9 +388,9 @@ if ( ! function_exists('meta')) $str = ''; foreach ($name as $meta) { - $type = ( ! isset($meta['type']) OR $meta['type'] == 'name') ? 'name' : 'http-equiv'; - $name = ( ! isset($meta['name'])) ? '' : $meta['name']; - $content = ( ! isset($meta['content'])) ? '' : $meta['content']; + $type = ( ! isset($meta['type']) OR $meta['type'] == 'name') ? 'name' : 'http-equiv'; + $name = ( ! isset($meta['name'])) ? '' : $meta['name']; + $content = ( ! isset($meta['content'])) ? '' : $meta['content']; $newline = ( ! isset($meta['newline'])) ? "\n" : $meta['newline']; $str .= '<meta '.$type.'="'.$name.'" content="'.$content.'" />'.$newline; diff --git a/system/helpers/index.html b/system/helpers/index.html index c942a79ce..c942a79ce 100644..100755 --- a/system/helpers/index.html +++ b/system/helpers/index.html diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php index ffa99cc26..4cd7486b4 100644..100755 --- a/system/helpers/inflector_helper.php +++ b/system/helpers/inflector_helper.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -36,14 +36,14 @@ * @access public * @param string * @return str - */ + */ if ( ! function_exists('singular')) -{ +{ function singular($str) { $str = strtolower(trim($str)); $end = substr($str, -3); - + if ($end == 'ies') { $str = substr($str, 0, strlen($str)-3).'y'; @@ -55,13 +55,13 @@ if ( ! function_exists('singular')) else { $end = substr($str, -1); - + if ($end == 's') { $str = substr($str, 0, strlen($str)-1); } } - + return $str; } } @@ -77,9 +77,9 @@ if ( ! function_exists('singular')) * @param string * @param bool * @return str - */ + */ if ( ! function_exists('plural')) -{ +{ function plural($str, $force = FALSE) { $str = strtolower(trim($str)); @@ -91,6 +91,17 @@ if ( ! function_exists('plural')) $vowels = array('a', 'e', 'i', 'o', 'u'); $str = in_array(substr($str, -2, 1), $vowels) ? $str.'s' : substr($str, 0, -1).'ies'; } + elseif ($end == 'h') + { + if (substr($str, -2) == 'ch' OR substr($str, -2) == 'sh') + { + $str .= 'es'; + } + else + { + $str .= 's'; + } + } elseif ($end == 's') { if ($force == TRUE) @@ -117,11 +128,11 @@ if ( ! function_exists('plural')) * @access public * @param string * @return str - */ + */ if ( ! function_exists('camelize')) -{ +{ function camelize($str) - { + { $str = 'x'.strtolower(trim($str)); $str = ucwords(preg_replace('/[\s_]+/', ' ', $str)); return substr(str_replace(' ', '', $str), 1); @@ -138,7 +149,7 @@ if ( ! function_exists('camelize')) * @access public * @param string * @return str - */ + */ if ( ! function_exists('underscore')) { function underscore($str) @@ -157,15 +168,15 @@ if ( ! function_exists('underscore')) * @access public * @param string * @return str - */ + */ if ( ! function_exists('humanize')) -{ +{ function humanize($str) { return ucwords(preg_replace('/[_]+/', ' ', strtolower(trim($str)))); } } - + /* End of file inflector_helper.php */ /* Location: ./system/helpers/inflector_helper.php */
\ No newline at end of file diff --git a/system/helpers/language_helper.php b/system/helpers/language_helper.php index 442619c93..68c1a1fc6 100644..100755 --- a/system/helpers/language_helper.php +++ b/system/helpers/language_helper.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -36,7 +36,7 @@ * @param string the language line * @param string the id of the form element * @return string - */ + */ if ( ! function_exists('lang')) { function lang($line, $id = '') diff --git a/system/helpers/number_helper.php b/system/helpers/number_helper.php index cf683f2a1..a2caea5e3 100644..100755 --- a/system/helpers/number_helper.php +++ b/system/helpers/number_helper.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -36,29 +36,29 @@ */ if ( ! function_exists('byte_format')) { - function byte_format($num) + function byte_format($num, $precision = 1) { $CI =& get_instance(); $CI->lang->load('number'); - - if ($num >= 1000000000000) + + if ($num >= 1000000000000) { - $num = round($num / 1099511627776, 1); + $num = round($num / 1099511627776, $precision); $unit = $CI->lang->line('terabyte_abbr'); } - elseif ($num >= 1000000000) + elseif ($num >= 1000000000) { - $num = round($num / 1073741824, 1); + $num = round($num / 1073741824, $precision); $unit = $CI->lang->line('gigabyte_abbr'); } - elseif ($num >= 1000000) + elseif ($num >= 1000000) { - $num = round($num / 1048576, 1); + $num = round($num / 1048576, $precision); $unit = $CI->lang->line('megabyte_abbr'); } - elseif ($num >= 1000) + elseif ($num >= 1000) { - $num = round($num / 1024, 1); + $num = round($num / 1024, $precision); $unit = $CI->lang->line('kilobyte_abbr'); } else @@ -67,9 +67,10 @@ if ( ! function_exists('byte_format')) return number_format($num).' '.$unit; } - return number_format($num, 1).' '.$unit; - } + return number_format($num, $precision).' '.$unit; + } } + /* End of file number_helper.php */ /* Location: ./system/helpers/number_helper.php */
\ No newline at end of file diff --git a/system/helpers/path_helper.php b/system/helpers/path_helper.php index 030b6bff1..ffcf46842 100644..100755 --- a/system/helpers/path_helper.php +++ b/system/helpers/path_helper.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -34,7 +34,7 @@ * @param string * @param bool checks to see if the path exists * @return string - */ + */ if ( ! function_exists('set_realpath')) { function set_realpath($path, $check_existance = FALSE) @@ -44,16 +44,16 @@ if ( ! function_exists('set_realpath')) { show_error('The path you submitted must be a local server path, not a URL'); } - + // Resolve the path if (function_exists('realpath') AND @realpath($path) !== FALSE) { $path = realpath($path).'/'; } - + // Add a trailing slash $path = preg_replace("#([^/])/*$#", "\\1/", $path); - + // Make sure the path exists if ($check_existance == TRUE) { @@ -62,7 +62,7 @@ if ( ! function_exists('set_realpath')) show_error('Not a valid path: '.$path); } } - + return $path; } } diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php index 1fc47b34b..61ebf46f9 100644..100755 --- a/system/helpers/security_helper.php +++ b/system/helpers/security_helper.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -34,35 +34,69 @@ * @param string * @param bool whether or not the content is an image file * @return string - */ + */ if ( ! function_exists('xss_clean')) { function xss_clean($str, $is_image = FALSE) { $CI =& get_instance(); - return $CI->input->xss_clean($str, $is_image); + return $CI->security->xss_clean($str, $is_image); } } -// -------------------------------------------------------------------- +// ------------------------------------------------------------------------ /** - * Hash encode a string + * Sanitize Filename * * @access public * @param string * @return string - */ + */ +if ( ! function_exists('sanitize_filename')) +{ + function sanitize_filename($filename) + { + $CI =& get_instance(); + return $CI->security->sanitize_filename($filename); + } +} + +// -------------------------------------------------------------------- + +/** + * Hash encode a string + * + * This is simply an alias for do_hash() + * dohash() is now deprecated + */ if ( ! function_exists('dohash')) -{ +{ function dohash($str, $type = 'sha1') { + return do_hash($str, $type); + } +} + +// -------------------------------------------------------------------- + +/** + * Hash encode a string + * + * @access public + * @param string + * @return string + */ +if ( ! function_exists('do_hash')) +{ + function do_hash($str, $type = 'sha1') + { if ($type == 'sha1') { if ( ! function_exists('sha1')) { if ( ! function_exists('mhash')) - { + { require_once(BASEPATH.'libraries/Sha1'.EXT); $SH = new CI_SHA; return $SH->generate($str); @@ -75,7 +109,7 @@ if ( ! function_exists('dohash')) else { return sha1($str); - } + } } else { @@ -83,7 +117,7 @@ if ( ! function_exists('dohash')) } } } - + // ------------------------------------------------------------------------ /** @@ -92,18 +126,18 @@ if ( ! function_exists('dohash')) * @access public * @param string * @return string - */ + */ if ( ! function_exists('strip_image_tags')) { function strip_image_tags($str) { $str = preg_replace("#<img\s+.*?src\s*=\s*[\"'](.+?)[\"'].*?\>#", "\\1", $str); $str = preg_replace("#<img\s+.*?src\s*=\s*(.+?).*?\>#", "\\1", $str); - + return $str; } } - + // ------------------------------------------------------------------------ /** @@ -112,7 +146,7 @@ if ( ! function_exists('strip_image_tags')) * @access public * @param string * @return string - */ + */ if ( ! function_exists('encode_php_tags')) { function encode_php_tags($str) diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php index 3a31be36e..80a8d79ad 100644..100755 --- a/system/helpers/smiley_helper.php +++ b/system/helpers/smiley_helper.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -40,12 +40,12 @@ */ if ( ! function_exists('smiley_js')) { - function smiley_js($alias = '', $field_id = '') + function smiley_js($alias = '', $field_id = '', $inline = TRUE) { static $do_setup = TRUE; $r = ''; - + if ($alias != '' && ! is_array($alias)) { $alias = array($alias => $field_id); @@ -54,9 +54,9 @@ if ( ! function_exists('smiley_js')) if ($do_setup === TRUE) { $do_setup = FALSE; - + $m = array(); - + if (is_array($alias)) { foreach($alias as $name => $id) @@ -64,23 +64,22 @@ if ( ! function_exists('smiley_js')) $m[] = '"'.$name.'" : "'.$id.'"'; } } - + $m = '{'.implode(',', $m).'}'; - + $r .= <<<EOF - var smiley_map = {$m}; function insert_smiley(smiley, field_id) { var el = document.getElementById(field_id), newStart; - + if ( ! el && smiley_map[field_id]) { el = document.getElementById(smiley_map[field_id]); - + if ( ! el) return false; } - + el.focus(); smiley = " " + smiley; @@ -93,7 +92,7 @@ if ( ! function_exists('smiley_js')) el.setSelectionRange(newStart, newStart); } else if (document.selection) { - document.selection.createRange().text = text; + document.selection.createRange().text = smiley; } } EOF; @@ -109,7 +108,14 @@ EOF; } } - return '<script type="text/javascript" charset="utf-8">'.$r.'</script>'; + if ($inline) + { + return '<script type="text/javascript" charset="utf-8">/*<![CDATA[ */'.$r.'// ]]></script>'; + } + else + { + return $r; + } } } @@ -118,8 +124,8 @@ EOF; /** * Get Clickable Smileys * - * Returns an array of image tag links that can be clicked to be inserted - * into a form field. + * Returns an array of image tag links that can be clicked to be inserted + * into a form field. * * @access public * @param string the URL to the folder containing the smiley images @@ -130,12 +136,12 @@ if ( ! function_exists('get_clickable_smileys')) function get_clickable_smileys($image_url, $alias = '', $smileys = NULL) { // For backward compatibility with js_insert_smiley - + if (is_array($alias)) { $smileys = $alias; } - + if ( ! is_array($smileys)) { if (FALSE === ($smileys = _get_smiley_array())) @@ -146,7 +152,7 @@ if ( ! function_exists('get_clickable_smileys')) // Add a trailing slash to the file path if needed $image_url = rtrim($image_url, '/').'/'; - + $used = array(); foreach ($smileys as $key => $val) { @@ -158,12 +164,12 @@ if ( ! function_exists('get_clickable_smileys')) { continue; } - - $link[] = "<a href=\"javascript:void(0);\" onClick=\"insert_smiley('".$key."', '".$alias."')\"><img src=\"".$image_url.$smileys[$key][0]."\" width=\"".$smileys[$key][1]."\" height=\"".$smileys[$key][2]."\" alt=\"".$smileys[$key][3]."\" style=\"border:0;\" /></a>"; - + + $link[] = "<a href=\"javascript:void(0);\" onclick=\"insert_smiley('".$key."', '".$alias."')\"><img src=\"".$image_url.$smileys[$key][0]."\" width=\"".$smileys[$key][1]."\" height=\"".$smileys[$key][2]."\" alt=\"".$smileys[$key][3]."\" style=\"border:0;\" /></a>"; + $used[$smileys[$key][0]] = TRUE; } - + return $link; } } diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php index c0409dc5a..7765bba31 100644..100755 --- a/system/helpers/string_helper.php +++ b/system/helpers/string_helper.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -30,7 +30,7 @@ /** * Trim Slashes * - * Removes any leading/traling slashes from a string: + * Removes any leading/trailing slashes from a string: * * /this/that/theother/ * @@ -41,15 +41,15 @@ * @access public * @param string * @return string - */ + */ if ( ! function_exists('trim_slashes')) { function trim_slashes($str) { return trim($str, '/'); - } + } } - + // ------------------------------------------------------------------------ /** @@ -60,13 +60,13 @@ if ( ! function_exists('trim_slashes')) * @access public * @param mixed string or array * @return mixed string or array - */ + */ if ( ! function_exists('strip_slashes')) { function strip_slashes($str) { if (is_array($str)) - { + { foreach ($str as $key => $val) { $str[$key] = strip_slashes($val); @@ -76,7 +76,7 @@ if ( ! function_exists('strip_slashes')) { $str = stripslashes($str); } - + return $str; } } @@ -91,7 +91,7 @@ if ( ! function_exists('strip_slashes')) * @access public * @param string * @return string - */ + */ if ( ! function_exists('strip_quotes')) { function strip_quotes($str) @@ -110,16 +110,17 @@ if ( ! function_exists('strip_quotes')) * @access public * @param string * @return string - */ + */ if ( ! function_exists('quotes_to_entities')) { function quotes_to_entities($str) - { + { return str_replace(array("\'","\"","'",'"'), array("'",""","'","""), $str); } } // ------------------------------------------------------------------------ + /** * Reduce Double Slashes * @@ -135,15 +136,15 @@ if ( ! function_exists('quotes_to_entities')) * @access public * @param string * @return string - */ + */ if ( ! function_exists('reduce_double_slashes')) { function reduce_double_slashes($str) { - return preg_replace("#([^:])//+#", "\\1/", $str); + return preg_replace("#(^|[^:])//+#", "\\1/", $str); } } - + // ------------------------------------------------------------------------ /** @@ -162,7 +163,7 @@ if ( ! function_exists('reduce_double_slashes')) * @param string the character you wish to reduce * @param bool TRUE/FALSE - whether to trim the character from the beginning/end * @return string - */ + */ if ( ! function_exists('reduce_multiples')) { function reduce_multiples($str, $character = ',', $trim = FALSE) @@ -177,7 +178,7 @@ if ( ! function_exists('reduce_multiples')) return $str; } } - + // ------------------------------------------------------------------------ /** @@ -186,22 +187,27 @@ if ( ! function_exists('reduce_multiples')) * Useful for generating passwords or hashes. * * @access public - * @param string type of random string. Options: alunum, numeric, nozero, unique + * @param string type of random string. basic, alpha, alunum, numeric, nozero, unique, md5, encrypt and sha1 * @param integer number of characters * @return string */ if ( ! function_exists('random_string')) -{ +{ function random_string($type = 'alnum', $len = 8) - { + { switch($type) { + case 'basic' : return mt_rand(); + break; case 'alnum' : case 'numeric' : case 'nozero' : - + case 'alpha' : + switch ($type) { + case 'alpha' : $pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + break; case 'alnum' : $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; break; case 'numeric' : $pool = '0123456789'; @@ -216,9 +222,20 @@ if ( ! function_exists('random_string')) $str .= substr($pool, mt_rand(0, strlen($pool) -1), 1); } return $str; - break; - case 'unique' : return md5(uniqid(mt_rand())); - break; + break; + case 'unique' : + case 'md5' : + + return md5(uniqid(mt_rand())); + break; + case 'encrypt' : + case 'sha1' : + + $CI =& get_instance(); + $CI->load->helper('security'); + + return do_hash(uniqid(mt_rand(), TRUE), 'sha1'); + break; } } } @@ -233,12 +250,12 @@ if ( ! function_exists('random_string')) * @access public * @param string (as many parameters as needed) * @return string - */ + */ if ( ! function_exists('alternator')) { function alternator() { - static $i; + static $i; if (func_num_args() == 0) { @@ -259,13 +276,13 @@ if ( ! function_exists('alternator')) * @param string * @param integer number of repeats * @return string - */ + */ if ( ! function_exists('repeater')) { function repeater($data, $num = 1) { return (($num > 0) ? str_repeat($data, $num) : ''); - } + } } diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index 1e672937b..47e6ccc93 100644..100755 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -37,7 +37,7 @@ * @param integer * @param string the end character. Usually an ellipsis * @return string - */ + */ if ( ! function_exists('word_limiter')) { function word_limiter($str, $limit = 100, $end_char = '…') @@ -46,18 +46,18 @@ if ( ! function_exists('word_limiter')) { return $str; } - + preg_match('/^\s*+(?:\S++\s*+){1,'.(int) $limit.'}/', $str, $matches); - + if (strlen($str) == strlen($matches[0])) { $end_char = ''; } - + return rtrim($matches[0]).$end_char; } } - + // ------------------------------------------------------------------------ /** @@ -71,7 +71,7 @@ if ( ! function_exists('word_limiter')) * @param integer * @param string the end character. Usually an ellipsis * @return string - */ + */ if ( ! function_exists('character_limiter')) { function character_limiter($str, $n = 500, $end_char = '…') @@ -80,7 +80,7 @@ if ( ! function_exists('character_limiter')) { return $str; } - + $str = preg_replace("/\s+/", ' ', str_replace(array("\r\n", "\r", "\n"), ' ', $str)); if (strlen($str) <= $n) @@ -92,16 +92,16 @@ if ( ! function_exists('character_limiter')) foreach (explode(' ', trim($str)) as $val) { $out .= $val.' '; - + if (strlen($out) >= $n) { $out = trim($out); return (strlen($out) == strlen($str)) ? $out : $out.$end_char; - } + } } } } - + // ------------------------------------------------------------------------ /** @@ -112,21 +112,21 @@ if ( ! function_exists('character_limiter')) * @access public * @param string * @return string - */ + */ if ( ! function_exists('ascii_to_entities')) { function ascii_to_entities($str) { - $count = 1; - $out = ''; - $temp = array(); - - for ($i = 0, $s = strlen($str); $i < $s; $i++) - { - $ordinal = ord($str[$i]); - - if ($ordinal < 128) - { + $count = 1; + $out = ''; + $temp = array(); + + for ($i = 0, $s = strlen($str); $i < $s; $i++) + { + $ordinal = ord($str[$i]); + + if ($ordinal < 128) + { /* If the $temp array has a value but we have moved on, then it seems only fair that we output that entity and restart $temp before continuing. -Paul @@ -138,31 +138,31 @@ if ( ! function_exists('ascii_to_entities')) } $out .= $str[$i]; - } - else - { - if (count($temp) == 0) - { - $count = ($ordinal < 224) ? 2 : 3; - } - - $temp[] = $ordinal; - - if (count($temp) == $count) - { - $number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64); - - $out .= '&#'.$number.';'; - $count = 1; - $temp = array(); - } - } - } - - return $out; + } + else + { + if (count($temp) == 0) + { + $count = ($ordinal < 224) ? 2 : 3; + } + + $temp[] = $ordinal; + + if (count($temp) == $count) + { + $number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64); + + $out .= '&#'.$number.';'; + $count = 1; + $temp = array(); + } + } + } + + return $out; } } - + // ------------------------------------------------------------------------ /** @@ -174,51 +174,51 @@ if ( ! function_exists('ascii_to_entities')) * @param string * @param bool * @return string - */ + */ if ( ! function_exists('entities_to_ascii')) { function entities_to_ascii($str, $all = TRUE) { - if (preg_match_all('/\&#(\d+)\;/', $str, $matches)) - { - for ($i = 0, $s = count($matches['0']); $i < $s; $i++) - { - $digits = $matches['1'][$i]; - - $out = ''; - - if ($digits < 128) - { - $out .= chr($digits); - - } - elseif ($digits < 2048) - { - $out .= chr(192 + (($digits - ($digits % 64)) / 64)); - $out .= chr(128 + ($digits % 64)); - } - else - { - $out .= chr(224 + (($digits - ($digits % 4096)) / 4096)); - $out .= chr(128 + ((($digits % 4096) - ($digits % 64)) / 64)); - $out .= chr(128 + ($digits % 64)); - } - - $str = str_replace($matches['0'][$i], $out, $str); - } - } - - if ($all) - { - $str = str_replace(array("&", "<", ">", """, "'", "-"), - array("&","<",">","\"", "'", "-"), - $str); - } - - return $str; + if (preg_match_all('/\&#(\d+)\;/', $str, $matches)) + { + for ($i = 0, $s = count($matches['0']); $i < $s; $i++) + { + $digits = $matches['1'][$i]; + + $out = ''; + + if ($digits < 128) + { + $out .= chr($digits); + + } + elseif ($digits < 2048) + { + $out .= chr(192 + (($digits - ($digits % 64)) / 64)); + $out .= chr(128 + ($digits % 64)); + } + else + { + $out .= chr(224 + (($digits - ($digits % 4096)) / 4096)); + $out .= chr(128 + ((($digits % 4096) - ($digits % 64)) / 64)); + $out .= chr(128 + ($digits % 64)); + } + + $str = str_replace($matches['0'][$i], $out, $str); + } + } + + if ($all) + { + $str = str_replace(array("&", "<", ">", """, "'", "-"), + array("&","<",">","\"", "'", "-"), + $str); + } + + return $str; } } - + // ------------------------------------------------------------------------ /** @@ -233,7 +233,7 @@ if ( ! function_exists('entities_to_ascii')) * @param string the array of censoered words * @param string the optional replacement value * @return string - */ + */ if ( ! function_exists('word_censor')) { function word_censor($str, $censored, $replacement = '') @@ -242,13 +242,13 @@ if ( ! function_exists('word_censor')) { return $str; } - - $str = ' '.$str.' '; + + $str = ' '.$str.' '; // \w, \b and a few others do not match on a unicode character // set for performance reasons. As a result words like über // will not match on a word boundary. Instead, we'll assume that - // a bad word will be bookended by any of these characters. + // a bad word will be bookeneded by any of these characters. $delim = '[-_\'\"`(){}<>\[\]|!?@#%&,.:;^~*+=\/ 0-9\n\r\t]'; foreach ($censored as $badword) @@ -263,10 +263,10 @@ if ( ! function_exists('word_censor')) } } - return trim($str); + return trim($str); } } - + // ------------------------------------------------------------------------ /** @@ -277,26 +277,26 @@ if ( ! function_exists('word_censor')) * @access public * @param string the text string * @return string - */ + */ if ( ! function_exists('highlight_code')) { function highlight_code($str) - { + { // The highlight string function encodes and highlights // brackets so we need them to start raw $str = str_replace(array('<', '>'), array('<', '>'), $str); - + // Replace any existing PHP tags to temporary markers so they don't accidentally // break the string out of PHP, and thus, thwart the highlighting. - - $str = str_replace(array('<?', '?>', '<%', '%>', '\\', '</script>'), + + $str = str_replace(array('<?', '?>', '<%', '%>', '\\', '</script>'), array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'), $str); // The highlight_string function requires that the text be surrounded // by PHP tags, which we will remove later $str = '<?php '.$str.' ?>'; // <? - // All the magic happens here, baby! + // All the magic happens here, baby! $str = highlight_string($str, TRUE); // Prior to PHP 5, the highligh function used icky <font> tags @@ -307,20 +307,20 @@ if ( ! function_exists('highlight_code')) $str = str_replace(array('<font ', '</font>'), array('<span ', '</span>'), $str); $str = preg_replace('#color="(.*?)"#', 'style="color: \\1"', $str); } - + // Remove our artificially added PHP, and the syntax highlighting that came with it $str = preg_replace('/<span style="color: #([A-Z0-9]+)"><\?php( | )/i', '<span style="color: #$1">', $str); $str = preg_replace('/(<span style="color: #[A-Z0-9]+">.*?)\?><\/span>\n<\/span>\n<\/code>/is', "$1</span>\n</span>\n</code>", $str); $str = preg_replace('/<span style="color: #[A-Z0-9]+"\><\/span>/i', '', $str); - + // Replace our markers back to PHP tags. $str = str_replace(array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'), array('<?', '?>', '<%', '%>', '\\', '</script>'), $str); - + return $str; } } - + // ------------------------------------------------------------------------ /** @@ -334,7 +334,7 @@ if ( ! function_exists('highlight_code')) * @param string the openging tag to precede the phrase with * @param string the closing tag to end the phrase with * @return string - */ + */ if ( ! function_exists('highlight_phrase')) { function highlight_phrase($str, $phrase, $tag_open = '<strong>', $tag_close = '</strong>') @@ -343,7 +343,7 @@ if ( ! function_exists('highlight_phrase')) { return ''; } - + if ($phrase != '') { return preg_replace('/('.preg_quote($phrase, '/').')/i', $tag_open."\\1".$tag_close, $str); @@ -352,7 +352,36 @@ if ( ! function_exists('highlight_phrase')) return $str; } } - + +// ------------------------------------------------------------------------ + +/** + * Convert Accented Foreign Characters to ASCII + * + * @access public + * @param string the text string + * @return string + */ +if ( ! function_exists('convert_accented_characters')) +{ + function convert_accented_characters($str) + { + if ( ! file_exists(APPPATH.'config/foreign_chars'.EXT)) + { + return $str; + } + + include APPPATH.'config/foreign_chars'.EXT; + + if ( ! isset($foreign_characters)) + { + return $str; + } + + return preg_replace(array_keys($foreign_characters), array_values($foreign_characters), $str); + } +} + // ------------------------------------------------------------------------ /** @@ -366,7 +395,7 @@ if ( ! function_exists('highlight_phrase')) * @param string the text string * @param integer the number of characters to wrap at * @return string - */ + */ if ( ! function_exists('word_wrap')) { function word_wrap($str, $charlim = '76') @@ -374,47 +403,47 @@ if ( ! function_exists('word_wrap')) // Se the character limit if ( ! is_numeric($charlim)) $charlim = 76; - + // Reduce multiple spaces $str = preg_replace("| +|", " ", $str); - + // Standardize newlines if (strpos($str, "\r") !== FALSE) { - $str = str_replace(array("\r\n", "\r"), "\n", $str); + $str = str_replace(array("\r\n", "\r"), "\n", $str); } - - // If the current word is surrounded by {unwrap} tags we'll + + // If the current word is surrounded by {unwrap} tags we'll // strip the entire chunk and replace it with a marker. $unwrap = array(); if (preg_match_all("|(\{unwrap\}.+?\{/unwrap\})|s", $str, $matches)) { for ($i = 0; $i < count($matches['0']); $i++) { - $unwrap[] = $matches['1'][$i]; + $unwrap[] = $matches['1'][$i]; $str = str_replace($matches['1'][$i], "{{unwrapped".$i."}}", $str); } } - - // Use PHP's native function to do the initial wordwrap. - // We set the cut flag to FALSE so that any individual words that are + + // Use PHP's native function to do the initial wordwrap. + // We set the cut flag to FALSE so that any individual words that are // too long get left alone. In the next step we'll deal with them. $str = wordwrap($str, $charlim, "\n", FALSE); - + // Split the string into individual lines of text and cycle through them $output = ""; - foreach (explode("\n", $str) as $line) + foreach (explode("\n", $str) as $line) { // Is the line within the allowed character count? // If so we'll join it to the output and continue if (strlen($line) <= $charlim) { - $output .= $line."\n"; + $output .= $line."\n"; continue; } - + $temp = ''; - while((strlen($line)) > $charlim) + while((strlen($line)) > $charlim) { // If the over-length word is a URL we won't wrap it if (preg_match("!\[url.+\]|://|wwww.!", $line)) @@ -426,12 +455,12 @@ if ( ! function_exists('word_wrap')) $temp .= substr($line, 0, $charlim-1); $line = substr($line, $charlim-1); } - - // If $temp contains data it means we had to split up an over-length + + // If $temp contains data it means we had to split up an over-length // word into smaller chunks so we'll add it back to our current line if ($temp != '') { - $output .= $temp . "\n" . $line; + $output .= $temp."\n".$line; } else { @@ -443,7 +472,7 @@ if ( ! function_exists('word_wrap')) // Put our markers back if (count($unwrap) > 0) - { + { foreach ($unwrap as $key => $val) { $output = str_replace("{{unwrapped".$key."}}", $val, $output); @@ -453,10 +482,52 @@ if ( ! function_exists('word_wrap')) // Remove the unwrap tags $output = str_replace(array('{unwrap}', '{/unwrap}'), '', $output); - return $output; + return $output; } } +// ------------------------------------------------------------------------ + +/** + * Ellipsize String + * + * This function will strip tags from a string, split it at its max_length and ellipsize + * + * @param string string to ellipsize + * @param integer max length of string + * @param mixed int (1|0) or float, .5, .2, etc for position to split + * @param string ellipsis ; Default '...' + * @return string ellipsized string + */ +if ( ! function_exists('ellipsize')) +{ + function ellipsize($str, $max_length, $position = 1, $ellipsis = '…') + { + // Strip tags + $str = trim(strip_tags($str)); + + // Is the string long enough to ellipsize? + if (strlen($str) <= $max_length) + { + return $str; + } + + $beg = substr($str, 0, floor($max_length * $position)); + + $position = ($position > 1) ? 1 : $position; + + if ($position === 1) + { + $end = substr($str, 0, -($max_length - strlen($beg))); + } + else + { + $end = substr($str, -($max_length - strlen($beg))); + } + + return $beg.$ellipsis.$end; + } +} /* End of file text_helper.php */ /* Location: ./system/helpers/text_helper.php */
\ No newline at end of file diff --git a/system/helpers/typography_helper.php b/system/helpers/typography_helper.php index 5621e6dd0..302bf45c5 100644..100755 --- a/system/helpers/typography_helper.php +++ b/system/helpers/typography_helper.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -33,19 +33,19 @@ * @access public * @param string * @return string - */ + */ if ( ! function_exists('nl2br_except_pre')) { function nl2br_except_pre($str) { $CI =& get_instance(); - + $CI->load->library('typography'); - + return $CI->typography->nl2br_except_pre($str); } } - + // ------------------------------------------------------------------------ /** @@ -54,16 +54,39 @@ if ( ! function_exists('nl2br_except_pre')) * * @access public * @param string + * @param bool whether to allow javascript event handlers * @param bool whether to reduce multiple instances of double newlines to two * @return string */ if ( ! function_exists('auto_typography')) { - function auto_typography($str, $reduce_linebreaks = FALSE) + function auto_typography($str, $strip_js_event_handlers = TRUE, $reduce_linebreaks = FALSE) { - $CI =& get_instance(); + $CI =& get_instance(); $CI->load->library('typography'); - return $CI->typography->auto_typography($str, $reduce_linebreaks); + return $CI->typography->auto_typography($str, $strip_js_event_handlers, $reduce_linebreaks); + } +} + + +// -------------------------------------------------------------------- + +/** + * HTML Entities Decode + * + * This function is a replacement for html_entity_decode() + * + * @access public + * @param string + * @return string + */ +if ( ! function_exists('entity_decode')) +{ + function entity_decode($str, $charset='UTF-8') + { + $CI =& get_instance(); + $CI->load->library('security'); + return $CI->security->entity_decode($str, $charset); } } diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index 90ea9207e..d0516cee6 100644..100755 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -70,7 +70,7 @@ if ( ! function_exists('base_url')) /** * Current URL * - * Returns the full URL (including segments) of the page where this + * Returns the full URL (including segments) of the page where this * function is placed * * @access public @@ -224,7 +224,7 @@ if ( ! function_exists('anchor_popup')) * @access public * @param string the email address * @param string the link title - * @param mixed any attributes + * @param mixed any attributes * @return string */ if ( ! function_exists('mailto')) @@ -254,7 +254,7 @@ if ( ! function_exists('mailto')) * @access public * @param string the email address * @param string the link title - * @param mixed any attributes + * @param mixed any attributes * @return string */ if ( ! function_exists('safe_mailto')) @@ -320,7 +320,7 @@ if ( ! function_exists('safe_mailto')) { $count = ($ordinal < 224) ? 2 : 3; } - + $temp[] = $ordinal; if (count($temp) == $count) { @@ -369,7 +369,7 @@ if ( ! function_exists('safe_mailto')) * @access public * @param string the string * @param string the type: email, url, or both - * @param bool whether to create pop-up links + * @param bool whether to create pop-up links * @return string */ if ( ! function_exists('auto_link')) @@ -381,7 +381,7 @@ if ( ! function_exists('auto_link')) if (preg_match_all("#(^|\s|\()((http(s?)://)|(www\.))(\w+[^\s\)\<]+)#i", $str, $matches)) { $pop = ($popup == TRUE) ? " target=\"_blank\" " : ""; - + for ($i = 0; $i < count($matches['0']); $i++) { $period = ''; @@ -390,7 +390,7 @@ if ( ! function_exists('auto_link')) $period = '.'; $matches['6'][$i] = substr($matches['6'][$i], 0, -1); } - + $str = str_replace($matches['0'][$i], $matches['1'][$i].'<a href="http'. $matches['4'][$i].'://'. @@ -416,7 +416,7 @@ if ( ! function_exists('auto_link')) $period = '.'; $matches['3'][$i] = substr($matches['3'][$i], 0, -1); } - + $str = str_replace($matches['0'][$i], safe_mailto($matches['1'][$i].'@'.$matches['2'][$i].'.'.$matches['3'][$i]).$period, $str); } } @@ -431,7 +431,7 @@ if ( ! function_exists('auto_link')) /** * Prep URL * - * Simply adds the http:// part if missing + * Simply adds the http:// part if no scheme is included * * @access public * @param string the URL @@ -446,7 +446,9 @@ if ( ! function_exists('prep_url')) return ''; } - if (substr($str, 0, 7) != 'http://' && substr($str, 0, 8) != 'https://') + $url = parse_url($str); + + if ( ! $url OR ! isset($url['scheme'])) { $str = 'http://'.$str; } @@ -493,7 +495,7 @@ if ( ! function_exists('url_title')) $replace.'$' => $replace, '^'.$replace => $replace, '\.+$' => '' - ); + ); $str = strip_tags($str); @@ -506,7 +508,7 @@ if ( ! function_exists('url_title')) { $str = strtolower($str); } - + return trim(stripslashes($str)); } } @@ -533,7 +535,7 @@ if ( ! function_exists('redirect')) { $uri = site_url($uri); } - + switch($method) { case 'refresh' : header("Refresh:0;url=".$uri); diff --git a/system/helpers/xml_helper.php b/system/helpers/xml_helper.php index 712f6777e..cdd81ad70 100644..100755 --- a/system/helpers/xml_helper.php +++ b/system/helpers/xml_helper.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -33,30 +33,39 @@ * @access public * @param string * @return string - */ + */ if ( ! function_exists('xml_convert')) { - function xml_convert($str) + function xml_convert($str, $protect_all = FALSE) { $temp = '__TEMP_AMPERSANDS__'; - // Replace entities to temporary markers so that + // Replace entities to temporary markers so that // ampersands won't get messed up $str = preg_replace("/&#(\d+);/", "$temp\\1;", $str); - $str = preg_replace("/&(\w+);/", "$temp\\1;", $str); - + + if ($protect_all === TRUE) + { + $str = preg_replace("/&(\w+);/", "$temp\\1;", $str); + } + $str = str_replace(array("&","<",">","\"", "'", "-"), - array("&", "<", ">", """, "'", "-"), - $str); + array("&", "<", ">", """, "'", "-"), + $str); - // Decode the temp markers back to entities + // Decode the temp markers back to entities $str = preg_replace("/$temp(\d+);/","&#\\1;",$str); - $str = preg_replace("/$temp(\w+);/","&\\1;", $str); - + + if ($protect_all === TRUE) + { + $str = preg_replace("/$temp(\w+);/","&\\1;", $str); + } + return $str; } } +// ------------------------------------------------------------------------ /* End of file xml_helper.php */ /* Location: ./system/helpers/xml_helper.php */
\ No newline at end of file diff --git a/system/index.html b/system/index.html index c942a79ce..c942a79ce 100644..100755 --- a/system/index.html +++ b/system/index.html diff --git a/system/language/english/calendar_lang.php b/system/language/english/calendar_lang.php index e26f84930..3e6312361 100644..100755 --- a/system/language/english/calendar_lang.php +++ b/system/language/english/calendar_lang.php @@ -1,19 +1,19 @@ <?php $lang['cal_su'] = "Su"; -$lang['cal_mo'] = "Mo"; -$lang['cal_tu'] = "Tu"; -$lang['cal_we'] = "We"; -$lang['cal_th'] = "Th"; -$lang['cal_fr'] = "Fr"; -$lang['cal_sa'] = "Sa"; -$lang['cal_sun'] = "Sun"; -$lang['cal_mon'] = "Mon"; -$lang['cal_tue'] = "Tue"; -$lang['cal_wed'] = "Wed"; -$lang['cal_thu'] = "Thu"; -$lang['cal_fri'] = "Fri"; -$lang['cal_sat'] = "Sat"; +$lang['cal_mo'] = "Mo"; +$lang['cal_tu'] = "Tu"; +$lang['cal_we'] = "We"; +$lang['cal_th'] = "Th"; +$lang['cal_fr'] = "Fr"; +$lang['cal_sa'] = "Sa"; +$lang['cal_sun'] = "Sun"; +$lang['cal_mon'] = "Mon"; +$lang['cal_tue'] = "Tue"; +$lang['cal_wed'] = "Wed"; +$lang['cal_thu'] = "Thu"; +$lang['cal_fri'] = "Fri"; +$lang['cal_sat'] = "Sat"; $lang['cal_sunday'] = "Sunday"; $lang['cal_monday'] = "Monday"; $lang['cal_tuesday'] = "Tuesday"; @@ -21,30 +21,30 @@ $lang['cal_wednesday'] = "Wednesday"; $lang['cal_thursday'] = "Thursday"; $lang['cal_friday'] = "Friday"; $lang['cal_saturday'] = "Saturday"; -$lang['cal_jan'] = "Jan"; -$lang['cal_feb'] = "Feb"; -$lang['cal_mar'] = "Mar"; -$lang['cal_apr'] = "Apr"; -$lang['cal_may'] = "May"; -$lang['cal_jun'] = "Jun"; -$lang['cal_jul'] = "Jul"; -$lang['cal_aug'] = "Aug"; -$lang['cal_sep'] = "Sep"; -$lang['cal_oct'] = "Oct"; -$lang['cal_nov'] = "Nov"; -$lang['cal_dec'] = "Dec"; -$lang['cal_january'] = "January"; -$lang['cal_february'] = "February"; -$lang['cal_march'] = "March"; +$lang['cal_jan'] = "Jan"; +$lang['cal_feb'] = "Feb"; +$lang['cal_mar'] = "Mar"; +$lang['cal_apr'] = "Apr"; +$lang['cal_may'] = "May"; +$lang['cal_jun'] = "Jun"; +$lang['cal_jul'] = "Jul"; +$lang['cal_aug'] = "Aug"; +$lang['cal_sep'] = "Sep"; +$lang['cal_oct'] = "Oct"; +$lang['cal_nov'] = "Nov"; +$lang['cal_dec'] = "Dec"; +$lang['cal_january'] = "January"; +$lang['cal_february'] = "February"; +$lang['cal_march'] = "March"; $lang['cal_april'] = "April"; -$lang['cal_mayl'] = "May"; -$lang['cal_june'] = "June"; -$lang['cal_july'] = "July"; +$lang['cal_mayl'] = "May"; +$lang['cal_june'] = "June"; +$lang['cal_july'] = "July"; $lang['cal_august'] = "August"; $lang['cal_september'] = "September"; -$lang['cal_october'] = "October"; +$lang['cal_october'] = "October"; $lang['cal_november'] = "November"; -$lang['cal_december'] = "December"; +$lang['cal_december'] = "December"; /* End of file calendar_lang.php */ diff --git a/system/language/english/date_lang.php b/system/language/english/date_lang.php index 628e55b1a..c0ace16ef 100644..100755 --- a/system/language/english/date_lang.php +++ b/system/language/english/date_lang.php @@ -56,5 +56,6 @@ $lang['UP1275'] = '(UTC +12:45) Chatham Islands Standard Time'; $lang['UP13'] = '(UTC +13:00) Phoenix Islands Time, Tonga'; $lang['UP14'] = '(UTC +14:00) Line Islands'; + /* End of file date_lang.php */ /* Location: ./system/language/english/date_lang.php */
\ No newline at end of file diff --git a/system/language/english/db_lang.php b/system/language/english/db_lang.php index dc98afcad..79b82c73a 100644..100755 --- a/system/language/english/db_lang.php +++ b/system/language/english/db_lang.php @@ -6,8 +6,9 @@ $lang['db_unable_to_select'] = 'Unable to select the specified database: %s'; $lang['db_unable_to_create'] = 'Unable to create the specified database: %s'; $lang['db_invalid_query'] = 'The query you submitted is not valid.'; $lang['db_must_set_table'] = 'You must set the database table to be used with your query.'; -$lang['db_must_set_database'] = 'You must set the database name in your database config file.'; $lang['db_must_use_set'] = 'You must use the "set" method to update an entry.'; +$lang['db_must_use_index'] = 'You must specify an index to match on for batch updates.'; +$lang['db_batch_missing_index'] = 'One or more rows submitted for batch updating is missing the specified index.'; $lang['db_must_use_where'] = 'Updates are not allowed unless they contain a "where" clause.'; $lang['db_del_must_use_where'] = 'Deletes are not allowed unless they contain a "where" or "like" clause.'; $lang['db_field_param_missing'] = 'To fetch fields requires the name of the table as a parameter.'; diff --git a/system/language/english/email_lang.php b/system/language/english/email_lang.php index e3bd113cb..e3bd113cb 100644..100755 --- a/system/language/english/email_lang.php +++ b/system/language/english/email_lang.php diff --git a/system/language/english/form_validation_lang.php b/system/language/english/form_validation_lang.php index 8a123f4bd..b01885091 100644..100755 --- a/system/language/english/form_validation_lang.php +++ b/system/language/english/form_validation_lang.php @@ -1,11 +1,11 @@ <?php -$lang['required'] = "The %s field is required."; +$lang['required'] = "The %s field is required."; $lang['isset'] = "The %s field must have a value."; $lang['valid_email'] = "The %s field must contain a valid email address."; -$lang['valid_emails'] = "The %s field must contain all valid email addresses."; -$lang['valid_url'] = "The %s field must contain a valid URL."; -$lang['valid_ip'] = "The %s field must contain a valid IP."; +$lang['valid_emails'] = "The %s field must contain all valid email addresses."; +$lang['valid_url'] = "The %s field must contain a valid URL."; +$lang['valid_ip'] = "The %s field must contain a valid IP."; $lang['min_length'] = "The %s field must be at least %s characters in length."; $lang['max_length'] = "The %s field can not exceed %s characters in length."; $lang['exact_length'] = "The %s field must be exactly %s characters in length."; @@ -15,6 +15,7 @@ $lang['alpha_dash'] = "The %s field may only contain alpha-numeric characters, $lang['numeric'] = "The %s field must contain only numbers."; $lang['is_numeric'] = "The %s field must contain only numeric characters."; $lang['integer'] = "The %s field must contain an integer."; +$lang['regex_match'] = "The %s field is not in the correct format."; $lang['matches'] = "The %s field does not match the %s field."; $lang['is_natural'] = "The %s field must contain only positive numbers."; $lang['is_natural_no_zero'] = "The %s field must contain a number greater than zero."; diff --git a/system/language/english/ftp_lang.php b/system/language/english/ftp_lang.php index 42403b971..392b2b272 100644..100755 --- a/system/language/english/ftp_lang.php +++ b/system/language/english/ftp_lang.php @@ -7,6 +7,7 @@ $lang['ftp_unable_to_makdir'] = "Unable to create the directory you have specif $lang['ftp_unable_to_changedir'] = "Unable to change directories."; $lang['ftp_unable_to_chmod'] = "Unable to set file permissions. Please check your path. Note: This feature is only available in PHP 5 or higher."; $lang['ftp_unable_to_upload'] = "Unable to upload the specified file. Please check your path."; +$lang['ftp_unable_to_download'] = "Unable to download the specified file. Please check your path."; $lang['ftp_no_source_file'] = "Unable to locate the source file. Please check your path."; $lang['ftp_unable_to_rename'] = "Unable to rename the file."; $lang['ftp_unable_to_delete'] = "Unable to delete the file."; diff --git a/system/language/english/imglib_lang.php b/system/language/english/imglib_lang.php index 66505da07..66505da07 100644..100755 --- a/system/language/english/imglib_lang.php +++ b/system/language/english/imglib_lang.php diff --git a/system/language/english/index.html b/system/language/english/index.html index c942a79ce..c942a79ce 100644..100755 --- a/system/language/english/index.html +++ b/system/language/english/index.html diff --git a/system/language/english/number_lang.php b/system/language/english/number_lang.php index 908580914..908580914 100644..100755 --- a/system/language/english/number_lang.php +++ b/system/language/english/number_lang.php diff --git a/system/language/english/profiler_lang.php b/system/language/english/profiler_lang.php index 7c40e3f3e..b6460fb83 100644..100755 --- a/system/language/english/profiler_lang.php +++ b/system/language/english/profiler_lang.php @@ -1,6 +1,6 @@ <?php -$lang['profiler_database'] = 'DATABASE'; +$lang['profiler_database'] = 'DATABASE'; $lang['profiler_controller_info'] = 'CLASS/METHOD'; $lang['profiler_benchmarks'] = 'BENCHMARKS'; $lang['profiler_queries'] = 'QUERIES'; @@ -8,12 +8,15 @@ $lang['profiler_get_data'] = 'GET DATA'; $lang['profiler_post_data'] = 'POST DATA'; $lang['profiler_uri_string'] = 'URI STRING'; $lang['profiler_memory_usage'] = 'MEMORY USAGE'; +$lang['profiler_config'] = 'CONFIG VARIABLES'; +$lang['profiler_headers'] = 'HTTP HEADERS'; $lang['profiler_no_db'] = 'Database driver is not currently loaded'; $lang['profiler_no_queries'] = 'No queries were run'; $lang['profiler_no_post'] = 'No POST data exists'; $lang['profiler_no_get'] = 'No GET data exists'; $lang['profiler_no_uri'] = 'No URI data exists'; $lang['profiler_no_memory'] = 'Memory Usage Unavailable'; +$lang['profiler_no_profiles'] = 'No Profile data - all Profiler sections have been disabled.'; /* End of file profiler_lang.php */ /* Location: ./system/language/english/profiler_lang.php */
\ No newline at end of file diff --git a/system/language/english/scaffolding_lang.php b/system/language/english/scaffolding_lang.php deleted file mode 100644 index c4d54d5c6..000000000 --- a/system/language/english/scaffolding_lang.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -$lang['scaff_view_records'] = 'View Records'; -$lang['scaff_create_record'] = 'Create New Record'; -$lang['scaff_add'] = 'Add Data'; -$lang['scaff_view'] = 'View Data'; -$lang['scaff_edit'] = 'Edit'; -$lang['scaff_delete'] = 'Delete'; -$lang['scaff_view_all'] = 'View All'; -$lang['scaff_yes'] = 'Yes'; -$lang['scaff_no'] = 'No'; -$lang['scaff_no_data'] = 'No data exists for this table yet.'; -$lang['scaff_del_confirm'] = 'Are you sure you want to delete the following row:'; - - -/* End of file scaffolding_lang.php */ -/* Location: ./system/language/english/scaffolding_lang.php */
\ No newline at end of file diff --git a/system/language/english/unit_test_lang.php b/system/language/english/unit_test_lang.php index 45b5acf55..070bcd1f2 100644..100755 --- a/system/language/english/unit_test_lang.php +++ b/system/language/english/unit_test_lang.php @@ -18,6 +18,7 @@ $lang['ut_array'] = 'Array'; $lang['ut_object'] = 'Object'; $lang['ut_resource'] = 'Resource'; $lang['ut_null'] = 'Null'; +$lang['ut_notes'] = 'Notes'; /* End of file unit_test_lang.php */ diff --git a/system/language/english/upload_lang.php b/system/language/english/upload_lang.php index 4de9e9e74..4de9e9e74 100644..100755 --- a/system/language/english/upload_lang.php +++ b/system/language/english/upload_lang.php diff --git a/system/language/english/validation_lang.php b/system/language/english/validation_lang.php deleted file mode 100644 index a287892fe..000000000 --- a/system/language/english/validation_lang.php +++ /dev/null @@ -1,24 +0,0 @@ -<?php - -$lang['required'] = "The %s field is required."; -$lang['isset'] = "The %s field must have a value."; -$lang['valid_email'] = "The %s field must contain a valid email address."; -$lang['valid_emails'] = "The %s field must contain all valid email addresses."; -$lang['valid_url'] = "The %s field must contain a valid URL."; -$lang['valid_ip'] = "The %s field must contain a valid IP."; -$lang['min_length'] = "The %s field must be at least %s characters in length."; -$lang['max_length'] = "The %s field can not exceed %s characters in length."; -$lang['exact_length'] = "The %s field must be exactly %s characters in length."; -$lang['alpha'] = "The %s field may only contain alphabetical characters."; -$lang['alpha_numeric'] = "The %s field may only contain alpha-numeric characters."; -$lang['alpha_dash'] = "The %s field may only contain alpha-numeric characters, underscores, and dashes."; -$lang['numeric'] = "The %s field must contain a number."; -$lang['is_numeric'] = "The %s field must contain a number."; -$lang['integer'] = "The %s field must contain an integer."; -$lang['matches'] = "The %s field does not match the %s field."; -$lang['is_natural'] = "The %s field must contain a number."; -$lang['is_natural_no_zero'] = "The %s field must contain a number greater than zero."; - - -/* End of file validation_lang.php */ -/* Location: ./system/language/english/validation_lang.php */
\ No newline at end of file diff --git a/system/language/index.html b/system/language/index.html index c942a79ce..c942a79ce 100644..100755 --- a/system/language/index.html +++ b/system/language/index.html diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php new file mode 100755 index 000000000..d3f6105ea --- /dev/null +++ b/system/libraries/Cache/Cache.php @@ -0,0 +1,216 @@ +<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); +/** + * CodeIgniter + * + * An open source application development framework for PHP 4.3.2 or newer + * + * @package CodeIgniter + * @author ExpressionEngine Dev Team + * @copyright Copyright (c) 2006 - 2011 EllisLab, Inc. + * @license http://codeigniter.com/user_guide/license.html + * @link http://codeigniter.com + * @since Version 2.0 + * @filesource + */ + +// ------------------------------------------------------------------------ + +/** + * CodeIgniter Caching Class + * + * @package CodeIgniter + * @subpackage Libraries + * @category Core + * @author ExpressionEngine Dev Team + * @link + */ +class Cache extends CI_Driver_Library { + + protected $valid_drivers = array( + 'cache_apc', 'cache_file', 'cache_memcached', 'cache_dummy' + ); + + protected $_cache_path = NULL; // Path of cache files (if file-based cache) + protected $_adapter = 'dummy'; + protected $_backup_driver; + + // ------------------------------------------------------------------------ + + /** + * Constructor + * + * @param array + */ + public function __construct($config = array()) + { + if ( ! empty($config)) + { + $this->_initialize($config); + } + } + + // ------------------------------------------------------------------------ + + /** + * Get + * + * Look for a value in the cache. If it exists, return the data + * if not, return FALSE + * + * @param string + * @return mixed value that is stored/FALSE on failure + */ + public function get($id) + { + return $this->{$this->_adapter}->get($id); + } + + // ------------------------------------------------------------------------ + + /** + * Cache Save + * + * @param string Unique Key + * @param mixed Data to store + * @param int Length of time (in seconds) to cache the data + * + * @return boolean true on success/false on failure + */ + public function save($id, $data, $ttl = 60) + { + return $this->{$this->_adapter}->save($id, $data, $ttl); + } + + // ------------------------------------------------------------------------ + + /** + * Delete from Cache + * + * @param mixed unique identifier of the item in the cache + * @return boolean true on success/false on failure + */ + public function delete($id) + { + return $this->{$this->_adapter}->delete($id); + } + + // ------------------------------------------------------------------------ + + /** + * Clean the cache + * + * @return boolean false on failure/true on success + */ + public function clean() + { + return $this->{$this->_adapter}->clean(); + } + + // ------------------------------------------------------------------------ + + /** + * Cache Info + * + * @param string user/filehits + * @return mixed array on success, false on failure + */ + public function cache_info($type = 'user') + { + return $this->{$this->_adapter}->cache_info($type); + } + + // ------------------------------------------------------------------------ + + /** + * Get Cache Metadata + * + * @param mixed key to get cache metadata on + * @return mixed return value from child method + */ + public function get_metadata($id) + { + return $this->{$this->_adapter}->get_metadata($id); + } + + // ------------------------------------------------------------------------ + + /** + * Initialize + * + * Initialize class properties based on the configuration array. + * + * @param array + * @return void + */ + private function _initialize($config) + { + $default_config = array( + 'adapter', + 'memcached' + ); + + foreach ($default_config as $key) + { + if (isset($config[$key])) + { + $param = '_'.$key; + + $this->{$param} = $config[$key]; + } + } + + if (isset($config['backup'])) + { + if (in_array('cache_'.$config['backup'], $this->valid_drivers)) + { + $this->_backup_driver = $config['backup']; + } + } + } + + // ------------------------------------------------------------------------ + + /** + * Is the requested driver supported in this environment? + * + * @param string The driver to test. + * @return array + */ + public function is_supported($driver) + { + static $support = array(); + + if ( ! isset($support[$driver])) + { + $support[$driver] = $this->{$driver}->is_supported(); + } + + return $support[$driver]; + } + + // ------------------------------------------------------------------------ + + /** + * __get() + * + * @param child + * @return object + */ + public function __get($child) + { + $obj = parent::__get($child); + + if ( ! $this->is_supported($child)) + { + $this->_adapter = $this->_backup_driver; + } + + return $obj; + } + + // ------------------------------------------------------------------------ +} +// End Class + +/* End of file Cache.php */ +/* Location: ./system/libraries/Cache/Cache.php */
\ No newline at end of file diff --git a/system/libraries/Cache/drivers/Cache_apc.php b/system/libraries/Cache/drivers/Cache_apc.php new file mode 100755 index 000000000..e82e8e1f5 --- /dev/null +++ b/system/libraries/Cache/drivers/Cache_apc.php @@ -0,0 +1,151 @@ +<?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) 2006 - 2011 EllisLab, Inc. + * @license http://codeigniter.com/user_guide/license.html + * @link http://codeigniter.com + * @since Version 2.0 + * @filesource + */ + +// ------------------------------------------------------------------------ + +/** + * CodeIgniter APC Caching Class + * + * @package CodeIgniter + * @subpackage Libraries + * @category Core + * @author ExpressionEngine Dev Team + * @link + */ + +class Cache_apc extends CI_Driver { + + /** + * Get + * + * Look for a value in the cache. If it exists, return the data + * if not, return FALSE + * + * @param string + * @return mixed value that is stored/FALSE on failure + */ + public function get($id) + { + $data = apc_fetch($id); + + return (is_array($data)) ? $data[0] : FALSE; + } + + // ------------------------------------------------------------------------ + + /** + * Cache Save + * + * @param string Unique Key + * @param mixed Data to store + * @param int Length of time (in seconds) to cache the data + * + * @return boolean true on success/false on failure + */ + public function save($id, $data, $ttl = 60) + { + return apc_store($id, array($data, time(), $ttl), $ttl); + } + + // ------------------------------------------------------------------------ + + /** + * Delete from Cache + * + * @param mixed unique identifier of the item in the cache + * @param boolean true on success/false on failure + */ + public function delete($id) + { + return apc_delete($id); + } + + // ------------------------------------------------------------------------ + + /** + * Clean the cache + * + * @return boolean false on failure/true on success + */ + public function clean() + { + return apc_clear_cache('user'); + } + + // ------------------------------------------------------------------------ + + /** + * Cache Info + * + * @param string user/filehits + * @return mixed array on success, false on failure + */ + public function cache_info($type = NULL) + { + return apc_cache_info($type); + } + + // ------------------------------------------------------------------------ + + /** + * Get Cache Metadata + * + * @param mixed key to get cache metadata on + * @return mixed array on success/false on failure + */ + public function get_metadata($id) + { + $stored = apc_fetch($id); + + if (count($stored) !== 3) + { + return FALSE; + } + + list($value, $time, $ttl) = $stored; + + return array( + 'expire' => $time + $ttl, + 'mtime' => $time, + 'data' => $data + ); + } + + // ------------------------------------------------------------------------ + + /** + * is_supported() + * + * Check to see if APC is available on this system, bail if it isn't. + */ + public function is_supported() + { + if ( ! extension_loaded('apc') OR ! function_exists('apc_store')) + { + log_message('error', 'The APC PHP extension must be loaded to use APC Cache.'); + return FALSE; + } + + return TRUE; + } + + // ------------------------------------------------------------------------ + + +} +// End Class + +/* End of file Cache_apc.php */ +/* Location: ./system/libraries/Cache/drivers/Cache_apc.php */
\ No newline at end of file diff --git a/system/libraries/Cache/drivers/Cache_dummy.php b/system/libraries/Cache/drivers/Cache_dummy.php new file mode 100755 index 000000000..74f689241 --- /dev/null +++ b/system/libraries/Cache/drivers/Cache_dummy.php @@ -0,0 +1,129 @@ +<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); +/** + * CodeIgniter + * + * An open source application development framework for PHP 4.3.2 or newer + * + * @package CodeIgniter + * @author ExpressionEngine Dev Team + * @copyright Copyright (c) 2006 - 2011 EllisLab, Inc. + * @license http://codeigniter.com/user_guide/license.html + * @link http://codeigniter.com + * @since Version 2.0 + * @filesource + */ + +// ------------------------------------------------------------------------ + +/** + * CodeIgniter Dummy Caching Class + * + * @package CodeIgniter + * @subpackage Libraries + * @category Core + * @author ExpressionEngine Dev Team + * @link + */ + +class Cache_dummy extends CI_Driver { + + /** + * Get + * + * Since this is the dummy class, it's always going to return FALSE. + * + * @param string + * @return Boolean FALSE + */ + public function get($id) + { + return FALSE; + } + + // ------------------------------------------------------------------------ + + /** + * Cache Save + * + * @param string Unique Key + * @param mixed Data to store + * @param int Length of time (in seconds) to cache the data + * + * @return boolean TRUE, Simulating success + */ + public function save($id, $data, $ttl = 60) + { + return TRUE; + } + + // ------------------------------------------------------------------------ + + /** + * Delete from Cache + * + * @param mixed unique identifier of the item in the cache + * @param boolean TRUE, simulating success + */ + public function delete($id) + { + return TRUE; + } + + // ------------------------------------------------------------------------ + + /** + * Clean the cache + * + * @return boolean TRUE, simulating success + */ + public function clean() + { + return TRUE; + } + + // ------------------------------------------------------------------------ + + /** + * Cache Info + * + * @param string user/filehits + * @return boolean FALSE + */ + public function cache_info($type = NULL) + { + return FALSE; + } + + // ------------------------------------------------------------------------ + + /** + * Get Cache Metadata + * + * @param mixed key to get cache metadata on + * @return boolean FALSE + */ + public function get_metadata($id) + { + return FALSE; + } + + // ------------------------------------------------------------------------ + + /** + * Is this caching driver supported on the system? + * Of course this one is. + * + * @return TRUE; + */ + public function is_supported() + { + return TRUE; + } + + // ------------------------------------------------------------------------ + +} +// End Class + +/* End of file Cache_apc.php */ +/* Location: ./system/libraries/Cache/drivers/Cache_apc.php */
\ No newline at end of file diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php new file mode 100755 index 000000000..3ed357f2f --- /dev/null +++ b/system/libraries/Cache/drivers/Cache_file.php @@ -0,0 +1,196 @@ +<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); +/** + * CodeIgniter + * + * An open source application development framework for PHP 4.3.2 or newer + * + * @package CodeIgniter + * @author ExpressionEngine Dev Team + * @copyright Copyright (c) 2006 - 2011 EllisLab, Inc. + * @license http://codeigniter.com/user_guide/license.html + * @link http://codeigniter.com + * @since Version 2.0 + * @filesource + */ + +// ------------------------------------------------------------------------ + +/** + * CodeIgniter Memcached Caching Class + * + * @package CodeIgniter + * @subpackage Libraries + * @category Core + * @author ExpressionEngine Dev Team + * @link + */ + +class Cache_file extends CI_Driver { + + protected $_cache_path; + + /** + * Constructor + */ + public function __construct() + { + $CI =& get_instance(); + $CI->load->helper('file'); + + $path = $CI->config->item('cache_path'); + + $this->_cache_path = ($path == '') ? BASEPATH.'cache/' : $path; + } + + // ------------------------------------------------------------------------ + + /** + * Fetch from cache + * + * @param mixed unique key id + * @return mixed data on success/false on failure + */ + public function get($id) + { + if ( ! file_exists($this->_cache_path.$id)) + { + return FALSE; + } + + $data = read_file($this->_cache_path.$id); + $data = unserialize($data); + + if (time() > $data['time'] + $data['ttl']) + { + unlink($this->_cache_path.$id); + return FALSE; + } + + return $data['data']; + } + + // ------------------------------------------------------------------------ + + /** + * Save into cache + * + * @param string unique key + * @param mixed data to store + * @param int length of time (in seconds) the cache is valid + * - Default is 60 seconds + * @return boolean true on success/false on failure + */ + public function save($id, $data, $ttl = 60) + { + $contents = array( + 'time' => time(), + 'ttl' => $ttl, + 'data' => $data + ); + + if (write_file($this->_cache_path.$id, serialize($contents))) + { + @chmod($this->_cache_path.$id, 0777); + return TRUE; + } + + return FALSE; + } + + // ------------------------------------------------------------------------ + + /** + * Delete from Cache + * + * @param mixed unique identifier of item in cache + * @return boolean true on success/false on failure + */ + public function delete($id) + { + return unlink($this->_cache_path.$id); + } + + // ------------------------------------------------------------------------ + + /** + * Clean the Cache + * + * @return boolean false on failure/true on success + */ + public function clean() + { + return delete_files($this->_cache_path); + } + + // ------------------------------------------------------------------------ + + /** + * Cache Info + * + * Not supported by file-based caching + * + * @param string user/filehits + * @return mixed FALSE + */ + public function cache_info($type = NULL) + { + return get_dir_file_info($this->_cache_path); + } + + // ------------------------------------------------------------------------ + + /** + * Get Cache Metadata + * + * @param mixed key to get cache metadata on + * @return mixed FALSE on failure, array on success. + */ + public function get_metadata($id) + { + if ( ! file_exists($this->_cache_path.$id)) + { + return FALSE; + } + + $data = read_file($this->_cache_path.$id); + $data = unserialize($data); + + if (is_array($data)) + { + $data = $data['data']; + $mtime = filemtime($this->_cache_path.$id); + + if ( ! isset($data['ttl'])) + { + return FALSE; + } + + return array( + 'expire' => $mtime + $data['ttl'], + 'mtime' => $mtime + ); + } + + return FALSE; + } + + // ------------------------------------------------------------------------ + + /** + * Is supported + * + * In the file driver, check to see that the cache directory is indeed writable + * + * @return boolean + */ + public function is_supported() + { + return is_really_writable($this->_cache_path); + } + + // ------------------------------------------------------------------------ +} +// End Class + +/* End of file Cache_file.php */ +/* Location: ./system/libraries/Cache/drivers/Cache_file.php */
\ No newline at end of file diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php new file mode 100755 index 000000000..a7efdc5de --- /dev/null +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -0,0 +1,209 @@ +<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); +/** + * CodeIgniter + * + * An open source application development framework for PHP 4.3.2 or newer + * + * @package CodeIgniter + * @author ExpressionEngine Dev Team + * @copyright Copyright (c) 2006 - 2011 EllisLab, Inc. + * @license http://codeigniter.com/user_guide/license.html + * @link http://codeigniter.com + * @since Version 2.0 + * @filesource + */ + +// ------------------------------------------------------------------------ + +/** + * CodeIgniter Memcached Caching Class + * + * @package CodeIgniter + * @subpackage Libraries + * @category Core + * @author ExpressionEngine Dev Team + * @link + */ + +class Cache_memcached extends CI_Driver { + + private $_memcached; // Holds the memcached object + + protected $_memcache_conf = array( + 'default' => array( + 'default_host' => '127.0.0.1', + 'default_port' => 11211, + 'default_weight' => 1 + ) + ); + + // ------------------------------------------------------------------------ + + /** + * Fetch from cache + * + * @param mixed unique key id + * @return mixed data on success/false on failure + */ + public function get($id) + { + $data = $this->_memcached->get($id); + + return (is_array($data)) ? $data[0] : FALSE; + } + + // ------------------------------------------------------------------------ + + /** + * Save + * + * @param string unique identifier + * @param mixed data being cached + * @param int time to live + * @return boolean true on success, false on failure + */ + public function save($id, $data, $ttl = 60) + { + return $this->_memcached->add($id, array($data, time(), $ttl), $ttl); + } + + // ------------------------------------------------------------------------ + + /** + * Delete from Cache + * + * @param mixed key to be deleted. + * @return boolean true on success, false on failure + */ + public function delete($id) + { + return $this->_memcached->delete($id); + } + + // ------------------------------------------------------------------------ + + /** + * Clean the Cache + * + * @return boolean false on failure/true on success + */ + public function clean() + { + return $this->_memcached->flush(); + } + + // ------------------------------------------------------------------------ + + /** + * Cache Info + * + * @param null type not supported in memcached + * @return mixed array on success, false on failure + */ + public function cache_info($type = NULL) + { + return $this->_memcached->getStats(); + } + + // ------------------------------------------------------------------------ + + /** + * Get Cache Metadata + * + * @param mixed key to get cache metadata on + * @return mixed FALSE on failure, array on success. + */ + public function get_metadata($id) + { + $stored = $this->_memcached->get($id); + + if (count($stored) !== 3) + { + return FALSE; + } + + list($value, $time, $ttl) = $stored; + + return array( + 'expire' => $time + $ttl, + 'mtime' => $time, + 'data' => $data + ); + } + + // ------------------------------------------------------------------------ + + /** + * Setup memcached. + */ + private function _setup_memcached() + { + // Try to load memcached server info from the config file. + $CI =& get_instance(); + if ($CI->config->load('memcached', TRUE, TRUE)) + { + if (is_array($CI->config->config['memcached'])) + { + $this->_memcache_conf = NULL; + + foreach ($CI->config->config['memcached'] as $name => $conf) + { + $this->_memcache_conf[$name] = $conf; + } + } + } + + $this->_memcached = new Memcached(); + + foreach ($this->_memcache_conf as $name => $cache_server) + { + if ( ! array_key_exists('hostname', $cache_server)) + { + $cache_server['hostname'] = $this->_default_options['default_host']; + } + + if ( ! array_key_exists('port', $cache_server)) + { + $cache_server['port'] = $this->_default_options['default_port']; + } + + if ( ! array_key_exists('weight', $cache_server)) + { + $cache_server['weight'] = $this->_default_options['default_weight']; + } + + $this->_memcached->addServer( + $cache_server['hostname'], $cache_server['port'], $cache_server['weight'] + ); + } + } + + // ------------------------------------------------------------------------ + + + /** + * Is supported + * + * Returns FALSE if memcached is not supported on the system. + * If it is, we setup the memcached object & return TRUE + */ + public function is_supported() + { + if ( ! extension_loaded('memcached')) + { + log_message('error', 'The Memcached Extension must be loaded to use Memcached Cache.'); + + return FALSE; + } + + $this->_setup_memcached(); + return TRUE; + } + + // ------------------------------------------------------------------------ + +} +// End Class + +/* End of file Cache_memcached.php */ +/* Location: ./system/libraries/Cache/drivers/Cache_memcached.php */
\ No newline at end of file diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 275bf2451..72d228e73 100644..100755 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -33,7 +33,7 @@ class CI_Calendar { var $local_time; var $template = ''; var $start_day = 'sunday'; - var $month_type = 'long'; + var $month_type = 'long'; var $day_type = 'abr'; var $show_next_prev = FALSE; var $next_prev_url = ''; @@ -42,30 +42,28 @@ class CI_Calendar { * Constructor * * Loads the calendar language file and sets the default time reference - * - * @access public */ - function CI_Calendar($config = array()) - { + public function __construct($config = array()) + { $this->CI =& get_instance(); - + if ( ! in_array('calendar_lang'.EXT, $this->CI->lang->is_loaded, TRUE)) { $this->CI->lang->load('calendar'); } $this->local_time = time(); - + if (count($config) > 0) { $this->initialize($config); } - + log_message('debug', "Calendar Class Initialized"); } - + // -------------------------------------------------------------------- - + /** * Initialize the user preferences * @@ -74,7 +72,7 @@ class CI_Calendar { * @access public * @param array config preferences * @return void - */ + */ function initialize($config = array()) { foreach ($config as $key => $val) @@ -85,7 +83,7 @@ class CI_Calendar { } } } - + // -------------------------------------------------------------------- /** @@ -102,66 +100,66 @@ class CI_Calendar { // Set and validate the supplied month/year if ($year == '') $year = date("Y", $this->local_time); - + if ($month == '') $month = date("m", $this->local_time); - - if (strlen($year) == 1) + + if (strlen($year) == 1) $year = '200'.$year; - - if (strlen($year) == 2) + + if (strlen($year) == 2) $year = '20'.$year; - if (strlen($month) == 1) + if (strlen($month) == 1) $month = '0'.$month; - + $adjusted_date = $this->adjust_date($month, $year); - + $month = $adjusted_date['month']; $year = $adjusted_date['year']; - + // Determine the total days in the month $total_days = $this->get_total_days($month, $year); - + // Set the starting day of the week $start_days = array('sunday' => 0, 'monday' => 1, 'tuesday' => 2, 'wednesday' => 3, 'thursday' => 4, 'friday' => 5, 'saturday' => 6); $start_day = ( ! isset($start_days[$this->start_day])) ? 0 : $start_days[$this->start_day]; - + // Set the starting day number $local_date = mktime(12, 0, 0, $month, 1, $year); $date = getdate($local_date); $day = $start_day + 1 - $date["wday"]; - + while ($day > 1) { $day -= 7; } - + // Set the current month/year/day // We use this to determine the "today" date $cur_year = date("Y", $this->local_time); $cur_month = date("m", $this->local_time); $cur_day = date("j", $this->local_time); - + $is_current_month = ($cur_year == $year AND $cur_month == $month) ? TRUE : FALSE; - + // Generate the template data array $this->parse_template(); - - // Begin building the calendar output + + // Begin building the calendar output $out = $this->temp['table_open']; - $out .= "\n"; + $out .= "\n"; - $out .= "\n"; + $out .= "\n"; $out .= $this->temp['heading_row_start']; $out .= "\n"; - + // "previous" month link if ($this->show_next_prev == TRUE) { // Add a trailing slash to the URL if needed $this->next_prev_url = preg_replace("/(.+?)\/*$/", "\\1/", $this->next_prev_url); - + $adjusted_date = $this->adjust_date($month - 1, $year); $out .= str_replace('{previous_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_previous_cell']); $out .= "\n"; @@ -169,26 +167,26 @@ class CI_Calendar { // Heading containing the month/year $colspan = ($this->show_next_prev == TRUE) ? 5 : 7; - + $this->temp['heading_title_cell'] = str_replace('{colspan}', $colspan, $this->temp['heading_title_cell']); $this->temp['heading_title_cell'] = str_replace('{heading}', $this->get_month_name($month)." ".$year, $this->temp['heading_title_cell']); - + $out .= $this->temp['heading_title_cell']; $out .= "\n"; // "next" month link if ($this->show_next_prev == TRUE) - { + { $adjusted_date = $this->adjust_date($month + 1, $year); $out .= str_replace('{next_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_next_cell']); } - $out .= "\n"; + $out .= "\n"; $out .= $this->temp['heading_row_end']; $out .= "\n"; // Write the cells containing the days of the week - $out .= "\n"; + $out .= "\n"; $out .= $this->temp['week_row_start']; $out .= "\n"; @@ -213,11 +211,11 @@ class CI_Calendar { for ($i = 0; $i < 7; $i++) { $out .= ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_start_today'] : $this->temp['cal_cell_start']; - + if ($day > 0 AND $day <= $total_days) - { + { if (isset($data[$day])) - { + { // Cells with content $temp = ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content']; $out .= str_replace('{day}', $day, str_replace('{content}', $data[$day], $temp)); @@ -234,22 +232,22 @@ class CI_Calendar { // Blank cells $out .= $this->temp['cal_cell_blank']; } - - $out .= ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_end_today'] : $this->temp['cal_cell_end']; + + $out .= ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_end_today'] : $this->temp['cal_cell_end']; $day++; } - - $out .= "\n"; + + $out .= "\n"; $out .= $this->temp['cal_row_end']; - $out .= "\n"; + $out .= "\n"; } - $out .= "\n"; + $out .= "\n"; $out .= $this->temp['table_close']; return $out; } - + // -------------------------------------------------------------------- /** @@ -272,9 +270,9 @@ class CI_Calendar { { $month_names = array('01' => 'cal_january', '02' => 'cal_february', '03' => 'cal_march', '04' => 'cal_april', '05' => 'cal_mayl', '06' => 'cal_june', '07' => 'cal_july', '08' => 'cal_august', '09' => 'cal_september', '10' => 'cal_october', '11' => 'cal_november', '12' => 'cal_december'); } - + $month = $month_names[$month]; - + if ($this->CI->lang->line($month) === FALSE) { return ucfirst(str_replace('cal_', '', $month)); @@ -282,7 +280,7 @@ class CI_Calendar { return $this->CI->lang->line($month); } - + // -------------------------------------------------------------------- /** @@ -299,7 +297,7 @@ class CI_Calendar { { if ($day_type != '') $this->day_type = $day_type; - + if ($this->day_type == 'long') { $day_names = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'); @@ -312,16 +310,16 @@ class CI_Calendar { { $day_names = array('su', 'mo', 'tu', 'we', 'th', 'fr', 'sa'); } - + $days = array(); foreach ($day_names as $val) - { + { $days[] = ($this->CI->lang->line('cal_'.$val) === FALSE) ? ucfirst($val) : $this->CI->lang->line('cal_'.$val); } - + return $days; } - + // -------------------------------------------------------------------- /** @@ -362,7 +360,7 @@ class CI_Calendar { return $date; } - + // -------------------------------------------------------------------- /** @@ -393,7 +391,7 @@ class CI_Calendar { return $days_in_month[$month - 1]; } - + // -------------------------------------------------------------------- /** @@ -407,17 +405,17 @@ class CI_Calendar { function default_template() { return array ( - 'table_open' => '<table border="0" cellpadding="4" cellspacing="0">', - 'heading_row_start' => '<tr>', + 'table_open' => '<table border="0" cellpadding="4" cellspacing="0">', + 'heading_row_start' => '<tr>', 'heading_previous_cell' => '<th><a href="{previous_url}"><<</a></th>', - 'heading_title_cell' => '<th colspan="{colspan}">{heading}</th>', - 'heading_next_cell' => '<th><a href="{next_url}">>></a></th>', - 'heading_row_end' => '</tr>', - 'week_row_start' => '<tr>', - 'week_day_cell' => '<td>{week_day}</td>', - 'week_row_end' => '</tr>', - 'cal_row_start' => '<tr>', - 'cal_cell_start' => '<td>', + 'heading_title_cell' => '<th colspan="{colspan}">{heading}</th>', + 'heading_next_cell' => '<th><a href="{next_url}">>></a></th>', + 'heading_row_end' => '</tr>', + 'week_row_start' => '<tr>', + 'week_day_cell' => '<td>{week_day}</td>', + 'week_row_end' => '</tr>', + 'cal_row_start' => '<tr>', + 'cal_cell_start' => '<td>', 'cal_cell_start_today' => '<td>', 'cal_cell_content' => '<a href="{content}">{day}</a>', 'cal_cell_content_today' => '<a href="{content}"><strong>{day}</strong></a>', @@ -428,9 +426,9 @@ class CI_Calendar { 'cal_cell_end_today' => '</td>', 'cal_row_end' => '</tr>', 'table_close' => '</table>' - ); + ); } - + // -------------------------------------------------------------------- /** @@ -442,17 +440,17 @@ class CI_Calendar { * @access public * @return void */ - function parse_template() - { + function parse_template() + { $this->temp = $this->default_template(); - - if ($this->template == '') - { - return; - } - + + if ($this->template == '') + { + return; + } + $today = array('cal_cell_start_today', 'cal_cell_content_today', 'cal_cell_no_content_today', 'cal_cell_end_today'); - + foreach (array('table_open', 'table_close', 'heading_row_start', 'heading_previous_cell', 'heading_title_cell', 'heading_next_cell', 'heading_row_end', 'week_row_start', 'week_day_cell', 'week_row_end', 'cal_row_start', 'cal_cell_start', 'cal_cell_content', 'cal_cell_no_content', 'cal_cell_blank', 'cal_cell_end', 'cal_row_end', 'cal_cell_start_today', 'cal_cell_content_today', 'cal_cell_no_content_today', 'cal_cell_end_today') as $val) { if (preg_match("/\{".$val."\}(.*?)\{\/".$val."\}/si", $this->template, $match)) @@ -466,8 +464,8 @@ class CI_Calendar { $this->temp[$val] = $this->temp[str_replace('_today', '', $val)]; } } - } - } + } + } } diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index 643d2eca4..7f65b48b9 100644..100755 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2006 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2006 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -29,7 +29,7 @@ class CI_Cart { // These are the regular expression rules that we use to validate the product ID and product name var $product_id_rules = '\.a-z0-9_-'; // alpha-numeric, dashes, underscores, or periods var $product_name_rules = '\.\:\-_ a-z0-9'; // alpha-numeric, dashes, underscores, colons or periods - + // Private variables. Do not change! var $CI; var $_cart_contents = array(); @@ -39,12 +39,12 @@ class CI_Cart { * Shopping Class Constructor * * The constructor loads the Session class, used to store the shopping cart contents. - */ - function CI_Cart($params = array()) - { + */ + public function __construct($params = array()) + { // Set the super object to a local variable for use later $this->CI =& get_instance(); - + // Are any config settings being passed manually? If so, set them $config = array(); if (count($params) > 0) @@ -54,10 +54,10 @@ class CI_Cart { $config[$key] = $val; } } - + // Load the Sessions class $this->CI->load->library('session', $config); - + // Grab the shopping cart array from the session table, if it exists if ($this->CI->session->userdata('cart_contents') !== FALSE) { @@ -66,15 +66,15 @@ class CI_Cart { else { // No cart exists so we'll set some base values - $this->_cart_contents['cart_total'] = 0; - $this->_cart_contents['total_items'] = 0; + $this->_cart_contents['cart_total'] = 0; + $this->_cart_contents['total_items'] = 0; } - + log_message('debug', "Cart Class Initialized"); } // -------------------------------------------------------------------- - + /** * Insert items into the cart and save it to the session table * @@ -90,15 +90,15 @@ class CI_Cart { log_message('error', 'The insert method must be passed an array containing data.'); return FALSE; } - - // You can either insert a single product using a one-dimensional array, + + // You can either insert a single product using a one-dimensional array, // or multiple products using a multi-dimensional one. The way we // determine the array type is by looking for a required array key named "id" // at the top level. If it's not found, we will assume it's a multi-dimensional array. - - $save_cart = FALSE; + + $save_cart = FALSE; if (isset($items['id'])) - { + { if ($this->_insert($items) == TRUE) { $save_cart = TRUE; @@ -114,7 +114,7 @@ class CI_Cart { { $save_cart = TRUE; } - } + } } } @@ -129,7 +129,7 @@ class CI_Cart { } // -------------------------------------------------------------------- - + /** * Insert * @@ -145,9 +145,9 @@ class CI_Cart { log_message('error', 'The insert method must be passed an array containing data.'); return FALSE; } - + // -------------------------------------------------------------------- - + // Does the $items array contain an id, quantity, price, and name? These are required if ( ! isset($items['id']) OR ! isset($items['qty']) OR ! isset($items['price']) OR ! isset($items['name'])) { @@ -156,7 +156,7 @@ class CI_Cart { } // -------------------------------------------------------------------- - + // Prep the quantity. It can only be a number. Duh... $items['qty'] = trim(preg_replace('/([^0-9])/i', '', $items['qty'])); // Trim any leading zeros @@ -167,9 +167,9 @@ class CI_Cart { { return FALSE; } - + // -------------------------------------------------------------------- - + // Validate the product ID. It can only be alpha-numeric, dashes, underscores or periods // Not totally sure we should impose this rule, but it seems prudent to standardize IDs. // Note: These can be user-specified by setting the $this->product_id_rules variable. @@ -180,7 +180,7 @@ class CI_Cart { } // -------------------------------------------------------------------- - + // Validate the product name. It can only be alpha-numeric, dashes, underscores, colons or periods. // Note: These can be user-specified by setting the $this->product_name_rules variable. if ( ! preg_match("/^[".$this->product_name_rules."]+$/i", $items['name'])) @@ -195,7 +195,7 @@ class CI_Cart { $items['price'] = trim(preg_replace('/([^0-9\.])/i', '', $items['price'])); // Trim any leading zeros $items['price'] = trim(preg_replace('/(^[0]+)/i', '', $items['price'])); - + // Is the price a valid number? if ( ! is_numeric($items['price'])) { @@ -204,13 +204,13 @@ class CI_Cart { } // -------------------------------------------------------------------- - + // We now need to create a unique identifier for the item being inserted into the cart. - // Every time something is added to the cart it is stored in the master cart array. - // Each row in the cart array, however, must have a unique index that identifies not only - // a particular product, but makes it possible to store identical products with different options. - // For example, what if someone buys two identical t-shirts (same product ID), but in - // different sizes? The product ID (and other attributes, like the name) will be identical for + // Every time something is added to the cart it is stored in the master cart array. + // Each row in the cart array, however, must have a unique index that identifies not only + // a particular product, but makes it possible to store identical products with different options. + // For example, what if someone buys two identical t-shirts (same product ID), but in + // different sizes? The product ID (and other attributes, like the name) will be identical for // both sizes because it's the same shirt. The only difference will be the size. // Internally, we need to treat identical submissions, but with different options, as a unique product. // Our solution is to convert the options array to a string and MD5 it along with the product ID. @@ -225,19 +225,19 @@ class CI_Cart { // Technically, we don't need to MD5 the ID in this case, but it makes // sense to standardize the format of array indexes for both conditions $rowid = md5($items['id']); - } + } // -------------------------------------------------------------------- // Now that we have our unique "row ID", we'll add our cart items to the master array - + // let's unset this first, just to make sure our index contains only the data from this submission - unset($this->_cart_contents[$rowid]); - + unset($this->_cart_contents[$rowid]); + // Create a new index with our new row ID $this->_cart_contents[$rowid]['rowid'] = $rowid; - - // And add the new items to the cart array + + // And add the new items to the cart array foreach ($items as $key => $val) { $this->_cart_contents[$rowid][$key] = $val; @@ -248,11 +248,11 @@ class CI_Cart { } // -------------------------------------------------------------------- - + /** * Update the cart * - * This function permits the quantity of a given item to be changed. + * This function permits the quantity of a given item to be changed. * Typically it is called from the "view cart" page if a user makes * changes to the quantity before checkout. That array must contain the * product ID and quantity for each item. @@ -269,8 +269,8 @@ class CI_Cart { { return FALSE; } - - // You can either update a single product using a one-dimensional array, + + // You can either update a single product using a one-dimensional array, // or multiple products using a multi-dimensional one. The way we // determine the array type is by looking for a required array key named "id". // If it's not found we assume it's a multi-dimensional array @@ -292,7 +292,7 @@ class CI_Cart { { $save_cart = TRUE; } - } + } } } @@ -307,11 +307,11 @@ class CI_Cart { } // -------------------------------------------------------------------- - + /** * Update the cart * - * This function permits the quantity of a given item to be changed. + * This function permits the quantity of a given item to be changed. * Typically it is called from the "view cart" page if a user makes * changes to the quantity before checkout. That array must contain the * product ID and quantity for each item. @@ -319,7 +319,7 @@ class CI_Cart { * @access private * @param array * @return bool - */ + */ function _update($items = array()) { // Without these array indexes there is nothing we can do @@ -327,7 +327,7 @@ class CI_Cart { { return FALSE; } - + // Prep the quantity $items['qty'] = preg_replace('/([^0-9])/i', '', $items['qty']); @@ -336,7 +336,7 @@ class CI_Cart { { return FALSE; } - + // Is the new quantity different than what is already saved in the cart? // If it's the same there's nothing to do if ($this->_cart_contents[$items['rowid']]['qty'] == $items['qty']) @@ -348,18 +348,18 @@ class CI_Cart { // If the quantity is greater than zero we are updating if ($items['qty'] == 0) { - unset($this->_cart_contents[$items['rowid']]); + unset($this->_cart_contents[$items['rowid']]); } else { $this->_cart_contents[$items['rowid']]['qty'] = $items['qty']; } - + return TRUE; } // -------------------------------------------------------------------- - + /** * Save the cart array to the session DB * @@ -383,20 +383,20 @@ class CI_Cart { } $total += ($val['price'] * $val['qty']); - + // Set the subtotal $this->_cart_contents[$key]['subtotal'] = ($this->_cart_contents[$key]['price'] * $this->_cart_contents[$key]['qty']); } // Set the cart total and total items. - $this->_cart_contents['total_items'] = count($this->_cart_contents); + $this->_cart_contents['total_items'] = count($this->_cart_contents); $this->_cart_contents['cart_total'] = $total; - + // Is our cart empty? If so we delete it from the session if (count($this->_cart_contents) <= 2) { $this->CI->session->unset_userdata('cart_contents'); - + // Nothing more to do... coffee time! return FALSE; } @@ -406,11 +406,11 @@ class CI_Cart { $this->CI->session->set_userdata(array('cart_contents' => $this->_cart_contents)); // Woot! - return TRUE; + return TRUE; } // -------------------------------------------------------------------- - + /** * Cart Total * @@ -423,7 +423,7 @@ class CI_Cart { } // -------------------------------------------------------------------- - + /** * Total Items * @@ -438,7 +438,7 @@ class CI_Cart { } // -------------------------------------------------------------------- - + /** * Cart Contents * @@ -450,16 +450,16 @@ class CI_Cart { function contents() { $cart = $this->_cart_contents; - + // Remove these so they don't create a problem when showing the cart table unset($cart['total_items']); unset($cart['cart_total']); - + return $cart; } // -------------------------------------------------------------------- - + /** * Has options * @@ -475,12 +475,12 @@ class CI_Cart { { return FALSE; } - + return TRUE; } // -------------------------------------------------------------------- - + /** * Product options * @@ -500,7 +500,7 @@ class CI_Cart { } // -------------------------------------------------------------------- - + /** * Format Number * @@ -515,15 +515,15 @@ class CI_Cart { { return ''; } - + // Remove anything that isn't a number or decimal point. $n = trim(preg_replace('/([^0-9\.])/i', '', $n)); - + return number_format($n, 2, '.', ','); } - + // -------------------------------------------------------------------- - + /** * Destroy the cart * @@ -535,9 +535,9 @@ class CI_Cart { function destroy() { unset($this->_cart_contents); - - $this->_cart_contents['cart_total'] = 0; - $this->_cart_contents['total_items'] = 0; + + $this->_cart_contents['cart_total'] = 0; + $this->_cart_contents['total_items'] = 0; $this->CI->session->unset_userdata('cart_contents'); } diff --git a/system/libraries/Controller.php b/system/libraries/Controller.php deleted file mode 100644 index c5637c951..000000000 --- a/system/libraries/Controller.php +++ /dev/null @@ -1,127 +0,0 @@ -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); -/** - * CodeIgniter - * - * An open source application development framework for PHP 4.3.2 or newer - * - * @package CodeIgniter - * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. - * @license http://codeigniter.com/user_guide/license.html - * @link http://codeigniter.com - * @since Version 1.0 - * @filesource - */ - -// ------------------------------------------------------------------------ - -/** - * CodeIgniter 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 Controller extends CI_Base { - - var $_ci_scaffolding = FALSE; - var $_ci_scaff_table = FALSE; - - /** - * Constructor - * - * Calls the initialize() function - */ - function Controller() - { - parent::CI_Base(); - $this->_ci_initialize(); - log_message('debug', "Controller Class Initialized"); - } - - // -------------------------------------------------------------------- - - /** - * Initialize - * - * Assigns all the bases classes loaded by the front controller to - * variables in this class. Also calls the autoload routine. - * - * @access private - * @return void - */ - function _ci_initialize() - { - // Assign all the class objects that were instantiated by the - // front controller to local class variables so that CI can be - // run as one big super object. - $classes = array( - 'config' => 'Config', - 'input' => 'Input', - 'benchmark' => 'Benchmark', - 'uri' => 'URI', - 'output' => 'Output', - 'lang' => 'Language', - 'router' => 'Router' - ); - - foreach ($classes as $var => $class) - { - $this->$var =& load_class($class); - } - - // In PHP 5 the Loader class is run as a discreet - // class. In PHP 4 it extends the Controller - if (floor(phpversion()) >= 5) - { - $this->load =& load_class('Loader'); - $this->load->_ci_autoloader(); - } - else - { - $this->_ci_autoloader(); - - // sync up the objects since PHP4 was working from a copy - foreach (array_keys(get_object_vars($this)) as $attribute) - { - if (is_object($this->$attribute)) - { - $this->load->$attribute =& $this->$attribute; - } - } - } - } - - // -------------------------------------------------------------------- - - /** - * Run Scaffolding - * - * @access private - * @return void - */ - function _ci_scaffolding() - { - if ($this->_ci_scaffolding === FALSE OR $this->_ci_scaff_table === FALSE) - { - show_404('Scaffolding unavailable'); - } - - $method = ( ! in_array($this->uri->segment(3), array('add', 'insert', 'edit', 'update', 'view', 'delete', 'do_delete'), TRUE)) ? 'view' : $this->uri->segment(3); - - require_once(BASEPATH.'scaffolding/Scaffolding'.EXT); - $scaff = new Scaffolding($this->_ci_scaff_table); - $scaff->$method(); - } - - -} -// END _Controller class - -/* End of file Controller.php */ -/* Location: ./system/libraries/Controller.php */
\ No newline at end of file diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php new file mode 100755 index 000000000..15fc3da26 --- /dev/null +++ b/system/libraries/Driver.php @@ -0,0 +1,229 @@ +<?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 EllisLab Dev Team + * @copyright Copyright (c) 2006 - 2011, EllisLab, Inc. + * @license http://codeigniter.com/user_guide/license.html + * @link http://codeigniter.com + * @since Version 1.0 + * @filesource + */ + +// ------------------------------------------------------------------------ + +/** + * CodeIgniter Driver Library Class + * + * This class enables you to create "Driver" libraries that add runtime ability + * to extend the capabilities of a class via additional driver objects + * + * @package CodeIgniter + * @subpackage Libraries + * @category Libraries + * @author EllisLab Dev Team + * @link + */ +class CI_Driver_Library { + + protected $valid_drivers = array(); + protected static $lib_name; + + // The first time a child is used it won't exist, so we instantiate it + // subsequents calls will go straight to the proper child. + function __get($child) + { + if (! isset($this->lib_name)) + { + $this->lib_name = get_class($this); + } + + // The class will be prefixed with the parent lib + $child_class = $this->lib_name.'_'.$child; + + if (in_array(strtolower($child_class), array_map('strtolower', $this->valid_drivers))) + { + // check and see if the driver is in a separate file + if ( ! class_exists($child_class)) + { + // check application path first + foreach (array(APPPATH, BASEPATH) as $path) + { + // and check for case sensitivity of both the parent and child libs + foreach (array(ucfirst($this->lib_name), strtolower($this->lib_name)) as $lib) + { + // loves me some nesting! + foreach (array(ucfirst($child_class), strtolower($child_class)) as $class) + { + $filepath = $path.'libraries/'.$this->lib_name.'/drivers/'.$child_class.EXT; + + if (file_exists($filepath)) + { + include_once $filepath; + break; + } + } + } + } + + // it's a valid driver, but the file simply can't be found + if ( ! class_exists($child_class)) + { + log_message('error', "Unable to load the requested driver: ".$child_class); + show_error("Unable to load the requested driver: ".$child_class); + } + } + + $obj = new $child_class; + $obj->decorate($this); + $this->$child = $obj; + return $this->$child; + } + + // The requested driver isn't valid! + log_message('error', "Invalid driver requested: ".$child_class); + show_error("Invalid driver requested: ".$child_class); + } + + // -------------------------------------------------------------------- + +} +// END CI_Driver_Library CLASS + + +/** + * CodeIgniter Driver Class + * + * This class enables you to create drivers for a Library based on the Driver Library. + * It handles the drivers' access to the parent library + * + * @package CodeIgniter + * @subpackage Libraries + * @category Libraries + * @author EllisLab Dev Team + * @link + */ +class CI_Driver { + protected $parent; + + private $methods = array(); + private $properties = array(); + + private static $reflections = array(); + + /** + * Decorate + * + * Decorates the child with the parent driver lib's methods and properties + * + * @param object + * @return void + */ + public function decorate($parent) + { + $this->parent = $parent; + + // Lock down attributes to what is defined in the class + // and speed up references in magic methods + + $class_name = get_class($parent); + + if ( ! isset(self::$reflections[$class_name])) + { + $r = new ReflectionObject($parent); + + foreach ($r->getMethods() as $method) + { + if ($method->isPublic()) + { + $this->methods[] = $method->getName(); + } + } + + foreach($r->getProperties() as $prop) + { + if ($prop->isPublic()) + { + $this->properties[] = $prop->getName(); + } + } + + self::$reflections[$class_name] = array($this->methods, $this->properties); + } + else + { + list($this->methods, $this->properties) = self::$reflections[$class_name]; + } + } + + // -------------------------------------------------------------------- + + /** + * __call magic method + * + * Handles access to the parent driver library's methods + * + * @access public + * @param string + * @param array + * @return mixed + */ + public function __call($method, $args = array()) + { + if (in_array($method, $this->methods)) + { + return call_user_func_array(array($this->parent, $method), $args); + } + + $trace = debug_backtrace(); + _exception_handler(E_ERROR, "No such method '{$method}'", $trace[1]['file'], $trace[1]['line']); + exit; + } + + // -------------------------------------------------------------------- + + /** + * __get magic method + * + * Handles reading of the parent driver library's properties + * + * @param string + * @return mixed + */ + public function __get($var) + { + if (in_array($var, $this->properties)) + { + return $this->parent->$var; + } + } + + // -------------------------------------------------------------------- + + /** + * __set magic method + * + * Handles writing to the parent driver library's properties + * + * @param string + * @param array + * @return mixed + */ + public function __set($var, $val) + { + if (in_array($var, $this->properties)) + { + $this->parent->$var = $val; + } + } + + // -------------------------------------------------------------------- + +} +// END CI_Driver CLASS + +/* End of file Driver.php */ +/* Location: ./system/libraries/Driver.php */
\ No newline at end of file diff --git a/system/libraries/Email.php b/system/libraries/Email.php index d0f2ea9a5..e5af38f45 100644..100755 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -82,7 +82,7 @@ class CI_Email { * * The constructor can be passed an array of config values */ - function CI_Email($config = array()) + public function __construct($config = array()) { if (count($config) > 0) { @@ -106,9 +106,8 @@ class CI_Email { * @param array * @return void */ - function initialize($config = array()) + public function initialize($config = array()) { - $this->clear(); foreach ($config as $key => $val) { if (isset($this->$key)) @@ -125,11 +124,14 @@ class CI_Email { } } } + $this->clear(); $this->_smtp_auth = ($this->smtp_user == '' AND $this->smtp_pass == '') ? FALSE : TRUE; $this->_safe_mode = ((boolean)@ini_get("safe_mode") === FALSE) ? FALSE : TRUE; + + return $this; } - + // -------------------------------------------------------------------- /** @@ -138,7 +140,7 @@ class CI_Email { * @access public * @return void */ - function clear($clear_attachments = FALSE) + public function clear($clear_attachments = FALSE) { $this->_subject = ""; $this->_body = ""; @@ -146,6 +148,8 @@ class CI_Email { $this->_header_str = ""; $this->_replyto_flag = FALSE; $this->_recipients = array(); + $this->_cc_array = array(); + $this->_bcc_array = array(); $this->_headers = array(); $this->_debug_msg = array(); @@ -158,8 +162,10 @@ class CI_Email { $this->_attach_type = array(); $this->_attach_disp = array(); } + + return $this; } - + // -------------------------------------------------------------------- /** @@ -170,7 +176,7 @@ class CI_Email { * @param string * @return void */ - function from($from, $name = '') + public function from($from, $name = '') { if (preg_match( '/\<(.*)\>/', $from, $match)) { @@ -199,8 +205,10 @@ class CI_Email { $this->_set_header('From', $name.' <'.$from.'>'); $this->_set_header('Return-Path', '<'.$from.'>'); + + return $this; } - + // -------------------------------------------------------------------- /** @@ -211,7 +219,7 @@ class CI_Email { * @param string * @return void */ - function reply_to($replyto, $name = '') + public function reply_to($replyto, $name = '') { if (preg_match( '/\<(.*)\>/', $replyto, $match)) { @@ -235,8 +243,10 @@ class CI_Email { $this->_set_header('Reply-To', $name.' <'.$replyto.'>'); $this->_replyto_flag = TRUE; + + return $this; } - + // -------------------------------------------------------------------- /** @@ -246,7 +256,7 @@ class CI_Email { * @param string * @return void */ - function to($to) + public function to($to) { $to = $this->_str_to_array($to); $to = $this->clean_email($to); @@ -263,15 +273,18 @@ class CI_Email { switch ($this->_get_protocol()) { - case 'smtp' : $this->_recipients = $to; - break; - case 'sendmail' : $this->_recipients = implode(", ", $to); + case 'smtp' : + $this->_recipients = $to; break; - case 'mail' : $this->_recipients = implode(", ", $to); + case 'sendmail' : + case 'mail' : + $this->_recipients = implode(", ", $to); break; } + + return $this; } - + // -------------------------------------------------------------------- /** @@ -281,7 +294,7 @@ class CI_Email { * @param string * @return void */ - function cc($cc) + public function cc($cc) { $cc = $this->_str_to_array($cc); $cc = $this->clean_email($cc); @@ -297,8 +310,10 @@ class CI_Email { { $this->_cc_array = $cc; } + + return $this; } - + // -------------------------------------------------------------------- /** @@ -309,7 +324,7 @@ class CI_Email { * @param string * @return void */ - function bcc($bcc, $limit = '') + public function bcc($bcc, $limit = '') { if ($limit != '' && is_numeric($limit)) { @@ -333,8 +348,10 @@ class CI_Email { { $this->_set_header('Bcc', implode(", ", $bcc)); } + + return $this; } - + // -------------------------------------------------------------------- /** @@ -344,12 +361,13 @@ class CI_Email { * @param string * @return void */ - function subject($subject) + public function subject($subject) { $subject = $this->_prep_q_encoding($subject); $this->_set_header('Subject', $subject); + return $this; } - + // -------------------------------------------------------------------- /** @@ -359,11 +377,12 @@ class CI_Email { * @param string * @return void */ - function message($body) + public function message($body) { $this->_body = stripslashes(rtrim(str_replace("\r", "", $body))); + return $this; } - + // -------------------------------------------------------------------- /** @@ -373,11 +392,12 @@ class CI_Email { * @param string * @return void */ - function attach($filename, $disposition = 'attachment') + public function attach($filename, $disposition = 'attachment') { $this->_attach_name[] = $filename; $this->_attach_type[] = $this->_mime_types(next(explode('.', basename($filename)))); $this->_attach_disp[] = $disposition; // Can also be 'inline' Not sure if it matters + return $this; } // -------------------------------------------------------------------- @@ -390,11 +410,11 @@ class CI_Email { * @param string * @return void */ - function _set_header($header, $value) + private function _set_header($header, $value) { $this->_headers[$header] = $value; } - + // -------------------------------------------------------------------- /** @@ -404,7 +424,7 @@ class CI_Email { * @param string * @return array */ - function _str_to_array($email) + private function _str_to_array($email) { if ( ! is_array($email)) { @@ -420,7 +440,7 @@ class CI_Email { } return $email; } - + // -------------------------------------------------------------------- /** @@ -430,11 +450,12 @@ class CI_Email { * @param string * @return void */ - function set_alt_message($str = '') + public function set_alt_message($str = '') { $this->alt_message = ($str == '') ? '' : $str; + return $this; } - + // -------------------------------------------------------------------- /** @@ -444,11 +465,12 @@ class CI_Email { * @param string * @return void */ - function set_mailtype($type = 'text') + public function set_mailtype($type = 'text') { $this->mailtype = ($type == 'html') ? 'html' : 'text'; + return $this; } - + // -------------------------------------------------------------------- /** @@ -458,11 +480,12 @@ class CI_Email { * @param string * @return void */ - function set_wordwrap($wordwrap = TRUE) + public function set_wordwrap($wordwrap = TRUE) { $this->wordwrap = ($wordwrap === FALSE) ? FALSE : TRUE; + return $this; } - + // -------------------------------------------------------------------- /** @@ -472,11 +495,12 @@ class CI_Email { * @param string * @return void */ - function set_protocol($protocol = 'mail') + public function set_protocol($protocol = 'mail') { $this->protocol = ( ! in_array($protocol, $this->_protocols, TRUE)) ? 'mail' : strtolower($protocol); + return $this; } - + // -------------------------------------------------------------------- /** @@ -486,7 +510,7 @@ class CI_Email { * @param integer * @return void */ - function set_priority($n = 3) + public function set_priority($n = 3) { if ( ! is_numeric($n)) { @@ -501,8 +525,9 @@ class CI_Email { } $this->priority = $n; + return $this; } - + // -------------------------------------------------------------------- /** @@ -512,7 +537,7 @@ class CI_Email { * @param string * @return void */ - function set_newline($newline = "\n") + public function set_newline($newline = "\n") { if ($newline != "\n" AND $newline != "\r\n" AND $newline != "\r") { @@ -521,8 +546,10 @@ class CI_Email { } $this->newline = $newline; + + return $this; } - + // -------------------------------------------------------------------- /** @@ -532,7 +559,7 @@ class CI_Email { * @param string * @return void */ - function set_crlf($crlf = "\n") + public function set_crlf($crlf = "\n") { if ($crlf != "\n" AND $crlf != "\r\n" AND $crlf != "\r") { @@ -541,8 +568,10 @@ class CI_Email { } $this->crlf = $crlf; + + return $this; } - + // -------------------------------------------------------------------- /** @@ -551,12 +580,12 @@ class CI_Email { * @access private * @return void */ - function _set_boundaries() + private function _set_boundaries() { $this->_alt_boundary = "B_ALT_".uniqid(''); // multipart/alternative $this->_atc_boundary = "B_ATC_".uniqid(''); // attachment boundary } - + // -------------------------------------------------------------------- /** @@ -565,7 +594,7 @@ class CI_Email { * @access private * @return string */ - function _get_message_id() + private function _get_message_id() { $from = $this->_headers['Return-Path']; $from = str_replace(">", "", $from); @@ -573,7 +602,7 @@ class CI_Email { return "<".uniqid('').strstr($from, '@').">"; } - + // -------------------------------------------------------------------- /** @@ -583,7 +612,7 @@ class CI_Email { * @param bool * @return string */ - function _get_protocol($return = TRUE) + private function _get_protocol($return = TRUE) { $this->protocol = strtolower($this->protocol); $this->protocol = ( ! in_array($this->protocol, $this->_protocols, TRUE)) ? 'mail' : $this->protocol; @@ -593,7 +622,7 @@ class CI_Email { return $this->protocol; } } - + // -------------------------------------------------------------------- /** @@ -603,7 +632,7 @@ class CI_Email { * @param bool * @return string */ - function _get_encoding($return = TRUE) + private function _get_encoding($return = TRUE) { $this->_encoding = ( ! in_array($this->_encoding, $this->_bit_depths)) ? '8bit' : $this->_encoding; @@ -629,7 +658,7 @@ class CI_Email { * @access private * @return string */ - function _get_content_type() + private function _get_content_type() { if ($this->mailtype == 'html' && count($this->_attach_name) == 0) { @@ -648,7 +677,7 @@ class CI_Email { return 'plain'; } } - + // -------------------------------------------------------------------- /** @@ -657,7 +686,7 @@ class CI_Email { * @access private * @return string */ - function _set_date() + private function _set_date() { $timezone = date("Z"); $operator = (strncmp($timezone, '-', 1) == 0) ? '-' : '+'; @@ -666,7 +695,7 @@ class CI_Email { return sprintf("%s %s%04d", date("D, j M Y H:i:s"), $operator, $timezone); } - + // -------------------------------------------------------------------- /** @@ -675,11 +704,11 @@ class CI_Email { * @access private * @return string */ - function _get_mime_message() + private function _get_mime_message() { return "This is a multi-part message in MIME format.".$this->newline."Your email application may not support this format."; } - + // -------------------------------------------------------------------- /** @@ -689,7 +718,7 @@ class CI_Email { * @param string * @return bool */ - function validate_email($email) + public function validate_email($email) { if ( ! is_array($email)) { @@ -708,7 +737,7 @@ class CI_Email { return TRUE; } - + // -------------------------------------------------------------------- /** @@ -718,11 +747,11 @@ class CI_Email { * @param string * @return bool */ - function valid_email($address) + public function valid_email($address) { return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $address)) ? FALSE : TRUE; } - + // -------------------------------------------------------------------- /** @@ -732,17 +761,17 @@ class CI_Email { * @param string * @return string */ - function clean_email($email) + public function clean_email($email) { if ( ! is_array($email)) { if (preg_match('/\<(.*)\>/', $email, $match)) { - return $match['1']; + return $match['1']; } - else + else { - return $email; + return $email; } } @@ -752,23 +781,23 @@ class CI_Email { { if (preg_match( '/\<(.*)\>/', $addy, $match)) { - $clean_email[] = $match['1']; + $clean_email[] = $match['1']; } - else + else { - $clean_email[] = $addy; + $clean_email[] = $addy; } } return $clean_email; } - + // -------------------------------------------------------------------- /** * Build alternative plain text message * - * This function provides the raw message for use + * This public function provides the raw message for use * in plain-text headers of HTML-formatted emails. * If the user hasn't specified his own alternative message * it creates one by stripping the HTML @@ -776,7 +805,7 @@ class CI_Email { * @access private * @return string */ - function _get_alt_message() + private function _get_alt_message() { if ($this->alt_message != "") { @@ -802,7 +831,7 @@ class CI_Email { for ($x = 1; $x <= $i; $x ++) { - $n .= "\n"; + $n .= "\n"; } $body = str_replace($n, "\n\n", $body); @@ -810,7 +839,7 @@ class CI_Email { return $this->word_wrap($body, '76'); } - + // -------------------------------------------------------------------- /** @@ -821,7 +850,7 @@ class CI_Email { * @param integer * @return string */ - function word_wrap($str, $charlim = '') + public function word_wrap($str, $charlim = '') { // Se the character limit if ($charlim == '') @@ -850,7 +879,7 @@ class CI_Email { } } - // Use PHP's native function to do the initial wordwrap. + // Use PHP's native public function to do the initial wordwrap. // We set the cut flag to FALSE so that any individual words that are // too long get left alone. In the next step we'll deal with them. $str = wordwrap($str, $charlim, "\n", FALSE); @@ -906,7 +935,7 @@ class CI_Email { return $output; } - + // -------------------------------------------------------------------- /** @@ -916,7 +945,7 @@ class CI_Email { * @param string * @return string */ - function _build_headers() + private function _build_headers() { $this->_set_header('X-Sender', $this->clean_email($this->_headers['From'])); $this->_set_header('X-Mailer', $this->useragent); @@ -924,7 +953,7 @@ class CI_Email { $this->_set_header('Message-ID', $this->_get_message_id()); $this->_set_header('Mime-Version', '1.0'); } - + // -------------------------------------------------------------------- /** @@ -933,7 +962,7 @@ class CI_Email { * @access private * @return void */ - function _write_headers() + private function _write_headers() { if ($this->protocol == 'mail') { @@ -959,7 +988,7 @@ class CI_Email { $this->_header_str = rtrim($this->_header_str); } } - + // -------------------------------------------------------------------- /** @@ -968,7 +997,7 @@ class CI_Email { * @access private * @return void */ - function _build_message() + private function _build_message() { if ($this->wordwrap === TRUE AND $this->mailtype != 'html') { @@ -979,6 +1008,7 @@ class CI_Email { $this->_write_headers(); $hdr = ($this->_get_protocol() == 'mail') ? $this->newline : ''; + $body = ''; switch ($this->_get_content_type()) { @@ -991,13 +1021,12 @@ class CI_Email { { $this->_header_str .= $hdr; $this->_finalbody = $this->_body; - - return; + } + else + { + $this->_finalbody = $hdr . $this->newline . $this->newline . $this->_body; } - $hdr .= $this->newline . $this->newline . $this->_body; - - $this->_finalbody = $hdr; return; break; @@ -1011,93 +1040,81 @@ class CI_Email { else { $hdr .= "Content-Type: multipart/alternative; boundary=\"" . $this->_alt_boundary . "\"" . $this->newline . $this->newline; - $hdr .= $this->_get_mime_message() . $this->newline . $this->newline; - $hdr .= "--" . $this->_alt_boundary . $this->newline; - $hdr .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline; - $hdr .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline; - $hdr .= $this->_get_alt_message() . $this->newline . $this->newline . "--" . $this->_alt_boundary . $this->newline; + $body .= $this->_get_mime_message() . $this->newline . $this->newline; + $body .= "--" . $this->_alt_boundary . $this->newline; - $hdr .= "Content-Type: text/html; charset=" . $this->charset . $this->newline; - $hdr .= "Content-Transfer-Encoding: quoted-printable"; + $body .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline; + $body .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline; + $body .= $this->_get_alt_message() . $this->newline . $this->newline . "--" . $this->_alt_boundary . $this->newline; + + $body .= "Content-Type: text/html; charset=" . $this->charset . $this->newline; + $body .= "Content-Transfer-Encoding: quoted-printable" . $this->newline . $this->newline; } - $this->_body = $this->_prep_quoted_printable($this->_body); + $this->_finalbody = $body . $this->_prep_quoted_printable($this->_body) . $this->newline . $this->newline; + if ($this->_get_protocol() == 'mail') { $this->_header_str .= $hdr; - $this->_finalbody = $this->_body . $this->newline . $this->newline; - - if ($this->send_multipart !== FALSE) - { - $this->_finalbody .= "--" . $this->_alt_boundary . "--"; - } - - return; + } + else + { + $this->_finalbody = $hdr . $this->_finalbody; } - $hdr .= $this->newline . $this->newline; - $hdr .= $this->_body . $this->newline . $this->newline; if ($this->send_multipart !== FALSE) { - $hdr .= "--" . $this->_alt_boundary . "--"; + $this->_finalbody .= "--" . $this->_alt_boundary . "--"; } - $this->_finalbody = $hdr; return; break; case 'plain-attach' : $hdr .= "Content-Type: multipart/".$this->multipart."; boundary=\"" . $this->_atc_boundary."\"" . $this->newline . $this->newline; - $hdr .= $this->_get_mime_message() . $this->newline . $this->newline; - $hdr .= "--" . $this->_atc_boundary . $this->newline; - - $hdr .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline; - $hdr .= "Content-Transfer-Encoding: " . $this->_get_encoding(); if ($this->_get_protocol() == 'mail') { $this->_header_str .= $hdr; - - $body = $this->_body . $this->newline . $this->newline; } - $hdr .= $this->newline . $this->newline; - $hdr .= $this->_body . $this->newline . $this->newline; + $body .= $this->_get_mime_message() . $this->newline . $this->newline; + $body .= "--" . $this->_atc_boundary . $this->newline; + + $body .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline; + $body .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline; + + $body .= $this->_body . $this->newline . $this->newline; break; case 'html-attach' : $hdr .= "Content-Type: multipart/".$this->multipart."; boundary=\"" . $this->_atc_boundary."\"" . $this->newline . $this->newline; - $hdr .= $this->_get_mime_message() . $this->newline . $this->newline; - $hdr .= "--" . $this->_atc_boundary . $this->newline; - - $hdr .= "Content-Type: multipart/alternative; boundary=\"" . $this->_alt_boundary . "\"" . $this->newline .$this->newline; - $hdr .= "--" . $this->_alt_boundary . $this->newline; - - $hdr .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline; - $hdr .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline; - $hdr .= $this->_get_alt_message() . $this->newline . $this->newline . "--" . $this->_alt_boundary . $this->newline; - - $hdr .= "Content-Type: text/html; charset=" . $this->charset . $this->newline; - $hdr .= "Content-Transfer-Encoding: quoted-printable"; - - $this->_body = $this->_prep_quoted_printable($this->_body); if ($this->_get_protocol() == 'mail') { $this->_header_str .= $hdr; - - $body = $this->_body . $this->newline . $this->newline; - $body .= "--" . $this->_alt_boundary . "--" . $this->newline . $this->newline; } - $hdr .= $this->newline . $this->newline; - $hdr .= $this->_body . $this->newline . $this->newline; - $hdr .= "--" . $this->_alt_boundary . "--" . $this->newline . $this->newline; + $body .= $this->_get_mime_message() . $this->newline . $this->newline; + $body .= "--" . $this->_atc_boundary . $this->newline; + + $body .= "Content-Type: multipart/alternative; boundary=\"" . $this->_alt_boundary . "\"" . $this->newline .$this->newline; + $body .= "--" . $this->_alt_boundary . $this->newline; + + $body .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline; + $body .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline; + $body .= $this->_get_alt_message() . $this->newline . $this->newline . "--" . $this->_alt_boundary . $this->newline; + + $body .= "Content-Type: text/html; charset=" . $this->charset . $this->newline; + $body .= "Content-Transfer-Encoding: quoted-printable" . $this->newline . $this->newline; + + $body .= $this->_prep_quoted_printable($this->_body) . $this->newline . $this->newline; + $body .= "--" . $this->_alt_boundary . "--" . $this->newline . $this->newline; break; } @@ -1137,18 +1154,21 @@ class CI_Email { fclose($fp); } + $body .= implode($this->newline, $attachment).$this->newline."--".$this->_atc_boundary."--"; + + if ($this->_get_protocol() == 'mail') { - $this->_finalbody = $body . implode($this->newline, $attachment).$this->newline."--".$this->_atc_boundary."--"; - - return; + $this->_finalbody = $body; + } + else + { + $this->_finalbody = $hdr . $body; } - - $this->_finalbody = $hdr.implode($this->newline, $attachment).$this->newline."--".$this->_atc_boundary."--"; return; } - + // -------------------------------------------------------------------- /** @@ -1162,7 +1182,7 @@ class CI_Email { * @param integer * @return string */ - function _prep_quoted_printable($str, $charlim = '') + private function _prep_quoted_printable($str, $charlim = '') { // Set the character limit // Don't allow over 76, as that will make servers and MUAs barf @@ -1243,7 +1263,7 @@ class CI_Email { } // -------------------------------------------------------------------- - + /** * Prep Q Encoding * @@ -1255,7 +1275,7 @@ class CI_Email { * @param bool // set to TRUE for processing From: headers * @return str */ - function _prep_q_encoding($str, $from = FALSE) + private function _prep_q_encoding($str, $from = FALSE) { $str = str_replace(array("\r", "\n"), array('', ''), $str); @@ -1315,14 +1335,14 @@ class CI_Email { } // -------------------------------------------------------------------- - + /** * Send Email * * @access public * @return bool */ - function send() + public function send() { if ($this->_replyto_flag == FALSE) { @@ -1356,7 +1376,7 @@ class CI_Email { return TRUE; } } - + // -------------------------------------------------------------------- /** @@ -1365,7 +1385,7 @@ class CI_Email { * @access public * @return bool */ - function batch_bcc_send() + public function batch_bcc_send() { $float = $this->bcc_batch_size -1; @@ -1414,7 +1434,7 @@ class CI_Email { $this->_spool_email(); } } - + // -------------------------------------------------------------------- /** @@ -1423,11 +1443,11 @@ class CI_Email { * @access private * @return void */ - function _unwrap_specials() + private function _unwrap_specials() { $this->_finalbody = preg_replace_callback("/\{unwrap\}(.*?)\{\/unwrap\}/si", array($this, '_remove_nl_callback'), $this->_finalbody); } - + // -------------------------------------------------------------------- /** @@ -1436,7 +1456,7 @@ class CI_Email { * @access private * @return string */ - function _remove_nl_callback($matches) + private function _remove_nl_callback($matches) { if (strpos($matches[1], "\r") !== FALSE OR strpos($matches[1], "\n") !== FALSE) { @@ -1445,7 +1465,7 @@ class CI_Email { return $matches[1]; } - + // -------------------------------------------------------------------- /** @@ -1454,7 +1474,7 @@ class CI_Email { * @access private * @return bool */ - function _spool_email() + private function _spool_email() { $this->_unwrap_specials(); @@ -1490,7 +1510,7 @@ class CI_Email { $this->_set_error_message('email_sent', $this->_get_protocol()); return TRUE; } - + // -------------------------------------------------------------------- /** @@ -1499,7 +1519,7 @@ class CI_Email { * @access private * @return bool */ - function _send_with_mail() + private function _send_with_mail() { if ($this->_safe_mode == TRUE) { @@ -1516,6 +1536,7 @@ class CI_Email { { // most documentation of sendmail using the "-f" flag lacks a space after it, however // we've encountered servers that seem to require it to be in place. + if ( ! mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str, "-f ".$this->clean_email($this->_headers['From']))) { return FALSE; @@ -1526,7 +1547,7 @@ class CI_Email { } } } - + // -------------------------------------------------------------------- /** @@ -1535,7 +1556,7 @@ class CI_Email { * @access private * @return bool */ - function _send_with_sendmail() + private function _send_with_sendmail() { $fp = @popen($this->mailpath . " -oi -f ".$this->clean_email($this->_headers['From'])." -t", 'w'); @@ -1544,17 +1565,17 @@ class CI_Email { // server probably has popen disabled, so nothing we can do to get a verbose error. return FALSE; } - + fputs($fp, $this->_header_str); fputs($fp, $this->_finalbody); - $status = pclose($fp); - + $status = pclose($fp); + if (version_compare(PHP_VERSION, '4.2.3') == -1) { $status = $status >> 8 & 0xFF; - } - + } + if ($status != 0) { $this->_set_error_message('email_exit_status', $status); @@ -1564,7 +1585,7 @@ class CI_Email { return TRUE; } - + // -------------------------------------------------------------------- /** @@ -1573,7 +1594,7 @@ class CI_Email { * @access private * @return bool */ - function _send_with_smtp() + private function _send_with_smtp() { if ($this->smtp_host == '') { @@ -1633,7 +1654,7 @@ class CI_Email { $this->_send_command('quit'); return TRUE; } - + // -------------------------------------------------------------------- /** @@ -1643,7 +1664,7 @@ class CI_Email { * @param string * @return string */ - function _smtp_connect() + private function _smtp_connect() { $this->_smtp_connect = fsockopen($this->smtp_host, $this->smtp_port, @@ -1660,7 +1681,7 @@ class CI_Email { $this->_set_error_message($this->_get_smtp_data()); return $this->_send_command('hello'); } - + // -------------------------------------------------------------------- /** @@ -1671,7 +1692,7 @@ class CI_Email { * @param string * @return string */ - function _send_command($cmd, $data = '') + private function _send_command($cmd, $data = '') { switch ($cmd) { @@ -1727,7 +1748,7 @@ class CI_Email { return TRUE; } - + // -------------------------------------------------------------------- /** @@ -1736,7 +1757,7 @@ class CI_Email { * @access private * @return bool */ - function _smtp_authenticate() + private function _smtp_authenticate() { if ( ! $this->_smtp_auth) { @@ -1781,7 +1802,7 @@ class CI_Email { return TRUE; } - + // -------------------------------------------------------------------- /** @@ -1790,7 +1811,7 @@ class CI_Email { * @access private * @return bool */ - function _send_data($data) + private function _send_data($data) { if ( ! fwrite($this->_smtp_connect, $data . $this->newline)) { @@ -1802,7 +1823,7 @@ class CI_Email { return TRUE; } } - + // -------------------------------------------------------------------- /** @@ -1811,7 +1832,7 @@ class CI_Email { * @access private * @return string */ - function _get_smtp_data() + private function _get_smtp_data() { $data = ""; @@ -1827,7 +1848,7 @@ class CI_Email { return $data; } - + // -------------------------------------------------------------------- /** @@ -1836,11 +1857,11 @@ class CI_Email { * @access private * @return string */ - function _get_hostname() + private function _get_hostname() { return (isset($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : 'localhost.localdomain'; } - + // -------------------------------------------------------------------- /** @@ -1849,7 +1870,7 @@ class CI_Email { * @access private * @return string */ - function _get_ip() + private function _get_ip() { if ($this->_IP !== FALSE) { @@ -1860,12 +1881,12 @@ class CI_Email { $rip = (isset($_SERVER['REMOTE_ADDR']) AND $_SERVER['REMOTE_ADDR'] != "") ? $_SERVER['REMOTE_ADDR'] : FALSE; $fip = (isset($_SERVER['HTTP_X_FORWARDED_FOR']) AND $_SERVER['HTTP_X_FORWARDED_FOR'] != "") ? $_SERVER['HTTP_X_FORWARDED_FOR'] : FALSE; - if ($cip && $rip) $this->_IP = $cip; + if ($cip && $rip) $this->_IP = $cip; elseif ($rip) $this->_IP = $rip; elseif ($cip) $this->_IP = $cip; elseif ($fip) $this->_IP = $fip; - if (strstr($this->_IP, ',')) + if (strpos($this->_IP, ',') !== FALSE) { $x = explode(',', $this->_IP); $this->_IP = end($x); @@ -1882,7 +1903,7 @@ class CI_Email { return $this->_IP; } - + // -------------------------------------------------------------------- /** @@ -1891,7 +1912,7 @@ class CI_Email { * @access public * @return string */ - function print_debugger() + public function print_debugger() { $msg = ''; @@ -1906,7 +1927,7 @@ class CI_Email { $msg .= "<pre>".$this->_header_str."\n".htmlspecialchars($this->_subject)."\n".htmlspecialchars($this->_finalbody).'</pre>'; return $msg; } - + // -------------------------------------------------------------------- /** @@ -1916,7 +1937,7 @@ class CI_Email { * @param string * @return string */ - function _set_error_message($msg, $val = '') + private function _set_error_message($msg, $val = '') { $CI =& get_instance(); $CI->lang->load('email'); @@ -1930,7 +1951,7 @@ class CI_Email { $this->_debug_msg[] = str_replace('%s', $val, $line)."<br />"; } } - + // -------------------------------------------------------------------- /** @@ -1940,7 +1961,7 @@ class CI_Email { * @param string * @return string */ - function _mime_types($ext = "") + private function _mime_types($ext = "") { $mimes = array( 'hqx' => 'application/mac-binhex40', 'cpt' => 'application/mac-compactpro', diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php index c893fbf9e..e5f65878a 100644..100755 --- a/system/libraries/Encrypt.php +++ b/system/libraries/Encrypt.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -41,7 +41,7 @@ class CI_Encrypt { * Simply determines whether the mcrypt library exists. * */ - function CI_Encrypt() + public function __construct() { $this->CI =& get_instance(); $this->_mcrypt_exists = ( ! function_exists('mcrypt_encrypt')) ? FALSE : TRUE; @@ -72,7 +72,7 @@ class CI_Encrypt { $CI =& get_instance(); $key = $CI->config->item('encryption_key'); - if ($key === FALSE) + if ($key == FALSE) { show_error('In order to use the encryption class requires that you set an encryption key in your config file.'); } @@ -116,12 +116,16 @@ class CI_Encrypt { function encode($string, $key = '') { $key = $this->get_key($key); - $enc = $this->_xor_encode($string, $key); - + if ($this->_mcrypt_exists === TRUE) { - $enc = $this->mcrypt_encode($enc, $key); + $enc = $this->mcrypt_encode($string, $key); + } + else + { + $enc = $this->_xor_encode($string, $key); } + return base64_encode($enc); } @@ -140,7 +144,7 @@ class CI_Encrypt { function decode($string, $key = '') { $key = $this->get_key($key); - + if (preg_match('/[^a-zA-Z0-9\/\+=]/', $string)) { return FALSE; @@ -155,8 +159,67 @@ class CI_Encrypt { return FALSE; } } + else + { + $dec = $this->_xor_decode($dec, $key); + } - return $this->_xor_decode($dec, $key); + return $dec; + } + + // -------------------------------------------------------------------- + + /** + * Encode from Legacy + * + * Takes an encoded string from the original Encryption class algorithms and + * returns a newly encoded string using the improved method added in 2.0.0 + * This allows for backwards compatibility and a method to transition to the + * new encryption algorithms. + * + * For more details, see http://codeigniter.com/user_guide/installation/upgrade_200.html#encryption + * + * @access public + * @param string + * @param int (mcrypt mode constant) + * @param string + * @return string + */ + function encode_from_legacy($string, $legacy_mode = MCRYPT_MODE_ECB, $key = '') + { + if ($this->_mcrypt_exists === FALSE) + { + log_message('error', 'Encoding from legacy is available only when Mcrypt is in use.'); + return FALSE; + } + + // decode it first + // set mode temporarily to what it was when string was encoded with the legacy + // algorithm - typically MCRYPT_MODE_ECB + $current_mode = $this->_get_mode(); + $this->set_mode($legacy_mode); + + $key = $this->get_key($key); + + if (preg_match('/[^a-zA-Z0-9\/\+=]/', $string)) + { + return FALSE; + } + + $dec = base64_decode($string); + + if (($dec = $this->mcrypt_decode($dec, $key)) === FALSE) + { + return FALSE; + } + + $dec = $this->_xor_decode($dec, $key); + + // set the mcrypt mode back to what it should be, typically MCRYPT_MODE_CBC + $this->set_mode($current_mode); + + // and re-encode + return base64_encode($this->mcrypt_encode($dec, $key)); } // -------------------------------------------------------------------- @@ -184,7 +247,7 @@ class CI_Encrypt { $enc = ''; for ($i = 0; $i < strlen($string); $i++) - { + { $enc .= substr($rand, ($i % strlen($rand)), 1).(substr($rand, ($i % strlen($rand)), 1) ^ substr($string, $i, 1)); } @@ -347,7 +410,7 @@ class CI_Encrypt { { $temp = $temp + 256; } - + $str .= chr($temp); } @@ -355,7 +418,7 @@ class CI_Encrypt { } // -------------------------------------------------------------------- - + /** * Set the Mcrypt Cipher * @@ -412,9 +475,9 @@ class CI_Encrypt { { if ($this->_mcrypt_mode == '') { - $this->_mcrypt_mode = MCRYPT_MODE_ECB; + $this->_mcrypt_mode = MCRYPT_MODE_CBC; } - + return $this->_mcrypt_mode; } @@ -440,7 +503,7 @@ class CI_Encrypt { * @access public * @param string * @return string - */ + */ function hash($str) { return ($this->_hash_type == 'sha1') ? $this->sha1($str) : md5($str); diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 640bf9180..fc5b82ee3 100644..100755 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -25,29 +25,28 @@ * @link http://codeigniter.com/user_guide/libraries/form_validation.html */ class CI_Form_validation { - + var $CI; - var $_field_data = array(); + var $_field_data = array(); var $_config_rules = array(); var $_error_array = array(); - var $_error_messages = array(); + var $_error_messages = array(); var $_error_prefix = '<p>'; var $_error_suffix = '</p>'; var $error_string = ''; - var $_safe_form_data = FALSE; + var $_safe_form_data = FALSE; /** * Constructor - * - */ - function CI_Form_validation($rules = array()) - { + */ + public function __construct($rules = array()) + { $this->CI =& get_instance(); - + // Validation rules can be stored in a config file. $this->_config_rules = $rules; - + // Automatically load the form helper $this->CI->load->helper('form'); @@ -56,12 +55,12 @@ class CI_Form_validation { { mb_internal_encoding($this->CI->config->item('charset')); } - + log_message('debug', "Form Validation Class Initialized"); } - + // -------------------------------------------------------------------- - + /** * Set Rules * @@ -78,9 +77,9 @@ class CI_Form_validation { // No reason to set rules if we have no POST data if (count($_POST) == 0) { - return; + return $this; } - + // If an array was passed via the first parameter instead of indidual string // values we cycle through it and recursively call this function. if (is_array($field)) @@ -99,13 +98,13 @@ class CI_Form_validation { // Here we go! $this->set_rules($row['field'], $label, $row['rules']); } - return; + return $this; } - + // No fields? Nothing to do... if ( ! is_string($field) OR ! is_string($rules) OR $field == '') { - return; + return $this; } // If the field label wasn't passed we use the field name @@ -113,9 +112,9 @@ class CI_Form_validation { // Is the field name an array? We test for the existence of a bracket "[" in // the field name to determine this. If it is an array, we break it apart - // into its components so that we can fetch the corresponding POST data later + // into its components so that we can fetch the corresponding POST data later if (strpos($field, '[') !== FALSE AND preg_match_all('/\[(.*?)\]/', $field, $matches)) - { + { // Note: Due to a bug in current() that affects some versions // of PHP we can not pass function call directly into it $x = explode('[', $field); @@ -128,29 +127,31 @@ class CI_Form_validation { $indexes[] = $matches['1'][$i]; } } - + $is_array = TRUE; } else { - $indexes = array(); - $is_array = FALSE; + $indexes = array(); + $is_array = FALSE; } - - // Build our master array + + // Build our master array $this->_field_data[$field] = array( - 'field' => $field, - 'label' => $label, + 'field' => $field, + 'label' => $label, 'rules' => $rules, 'is_array' => $is_array, 'keys' => $indexes, 'postdata' => NULL, 'error' => '' ); + + return $this; } // -------------------------------------------------------------------- - + /** * Set Error Message * @@ -168,12 +169,14 @@ class CI_Form_validation { { $lang = array($lang => $val); } - + $this->_error_messages = array_merge($this->_error_messages, $lang); + + return $this; } - + // -------------------------------------------------------------------- - + /** * Set The Error Delimiter * @@ -183,15 +186,17 @@ class CI_Form_validation { * @param string * @param string * @return void - */ + */ function set_error_delimiters($prefix = '<p>', $suffix = '</p>') { $this->_error_prefix = $prefix; $this->_error_suffix = $suffix; + + return $this; } // -------------------------------------------------------------------- - + /** * Get Error Message * @@ -200,14 +205,14 @@ class CI_Form_validation { * @access public * @param string the field name * @return void - */ + */ function error($field = '', $prefix = '', $suffix = '') - { + { if ( ! isset($this->_field_data[$field]['error']) OR $this->_field_data[$field]['error'] == '') { return ''; } - + if ($prefix == '') { $prefix = $this->_error_prefix; @@ -222,7 +227,7 @@ class CI_Form_validation { } // -------------------------------------------------------------------- - + /** * Error String * @@ -232,7 +237,7 @@ class CI_Form_validation { * @param string * @param string * @return str - */ + */ function error_string($prefix = '', $suffix = '') { // No errrors, validation passes! @@ -240,7 +245,7 @@ class CI_Form_validation { { return ''; } - + if ($prefix == '') { $prefix = $this->_error_prefix; @@ -250,7 +255,7 @@ class CI_Form_validation { { $suffix = $this->_error_suffix; } - + // Generate the error string $str = ''; foreach ($this->_error_array as $val) @@ -260,12 +265,12 @@ class CI_Form_validation { $str .= $prefix.$val.$suffix."\n"; } } - + return $str; } // -------------------------------------------------------------------- - + /** * Run the Validator * @@ -273,7 +278,7 @@ class CI_Form_validation { * * @access public * @return bool - */ + */ function run($group = '') { // Do we even have any data to process? Mm? @@ -281,7 +286,7 @@ class CI_Form_validation { { return FALSE; } - + // Does the _field_data array containing the validation rules exist? // If not, we look to see if they were assigned via a config file if (count($this->_field_data) == 0) @@ -291,10 +296,10 @@ class CI_Form_validation { { return FALSE; } - + // Is there a validation rule for the particular URI being accessed? $uri = ($group == '') ? trim($this->CI->uri->ruri_string(), '/') : $group; - + if ($uri != '' AND isset($this->_config_rules[$uri])) { $this->set_rules($this->_config_rules[$uri]); @@ -303,7 +308,7 @@ class CI_Form_validation { { $this->set_rules($this->_config_rules); } - + // We're we able to set the rules correctly? if (count($this->_field_data) == 0) { @@ -311,17 +316,17 @@ class CI_Form_validation { return FALSE; } } - + // Load the language file containing error messages $this->CI->lang->load('form_validation'); - - // Cycle through the rules for each field, match the + + // Cycle through the rules for each field, match the // corresponding $_POST item and test for errors foreach ($this->_field_data as $field => $row) - { + { // Fetch the data from the corresponding $_POST array and cache it in the _field_data array. // Depending on whether the field name is an array or a string will determine where we get it from. - + if ($row['is_array'] == TRUE) { $this->_field_data[$field]['postdata'] = $this->_reduce_array($_POST, $row['keys']); @@ -333,8 +338,8 @@ class CI_Form_validation { $this->_field_data[$field]['postdata'] = $_POST[$field]; } } - - $this->_execute($row, explode('|', $row['rules']), $this->_field_data[$field]['postdata']); + + $this->_execute($row, explode('|', $row['rules']), $this->_field_data[$field]['postdata']); } // Did we end up with any errors? @@ -347,7 +352,7 @@ class CI_Form_validation { // Now we need to re-set the POST data with the new, processed data $this->_reset_post_array(); - + // No errors, validation passes! if ($total_errors == 0) { @@ -359,7 +364,7 @@ class CI_Form_validation { } // -------------------------------------------------------------------- - + /** * Traverse a multidimensional $_POST array index until the data is found * @@ -368,7 +373,7 @@ class CI_Form_validation { * @param array * @param integer * @return mixed - */ + */ function _reduce_array($array, $keys, $i = 0) { if (is_array($array)) @@ -389,18 +394,18 @@ class CI_Form_validation { return $array; } } - + return $array; } // -------------------------------------------------------------------- - + /** * Re-populate the _POST array with our finalized and processed data * * @access private * @return null - */ + */ function _reset_post_array() { foreach ($this->_field_data as $field => $row) @@ -418,7 +423,7 @@ class CI_Form_validation { { // start with a reference $post_ref =& $_POST; - + // before we assign values, make a reference to the right POST key if (count($row['keys']) == 1) { @@ -452,7 +457,7 @@ class CI_Form_validation { } // -------------------------------------------------------------------- - + /** * Executes the Validation routines * @@ -462,21 +467,21 @@ class CI_Form_validation { * @param mixed * @param integer * @return mixed - */ + */ function _execute($row, $rules, $postdata = NULL, $cycles = 0) { // If the $_POST data is an array we will run a recursive call if (is_array($postdata)) - { + { foreach ($postdata as $key => $val) { $this->_execute($row, $rules, $val, $cycles); $cycles++; } - + return; } - + // -------------------------------------------------------------------- // If the field is blank, but NOT required, no further tests are necessary @@ -496,7 +501,7 @@ class CI_Form_validation { } // -------------------------------------------------------------------- - + // Isset Test. Typically this rule will only apply to checkboxes. if (is_null($postdata) AND $callback == FALSE) { @@ -504,31 +509,31 @@ class CI_Form_validation { { // Set the message type $type = (in_array('required', $rules)) ? 'required' : 'isset'; - + if ( ! isset($this->_error_messages[$type])) { if (FALSE === ($line = $this->CI->lang->line($type))) { $line = 'The field was not set'; - } + } } else { $line = $this->_error_messages[$type]; } - + // Build the error message $message = sprintf($line, $this->_translate_fieldname($row['label'])); // Save the error message $this->_field_data[$row['field']]['error'] = $message; - + if ( ! isset($this->_error_array[$row['field']])) { $this->_error_array[$row['field']] = $message; } } - + return; } @@ -538,7 +543,7 @@ class CI_Form_validation { foreach ($rules As $rule) { $_in_array = FALSE; - + // We set the $postdata variable with the current data in our master array so that // each cycle of the loop is dealing with the processed data from the last cycle if ($row['is_array'] == TRUE AND is_array($this->_field_data[$row['field']]['postdata'])) @@ -549,7 +554,7 @@ class CI_Form_validation { { continue; } - + $postdata = $this->_field_data[$row['field']]['postdata'][$cycles]; $_in_array = TRUE; } @@ -559,32 +564,32 @@ class CI_Form_validation { } // -------------------------------------------------------------------- - - // Is the rule a callback? + + // Is the rule a callback? $callback = FALSE; if (substr($rule, 0, 9) == 'callback_') { $rule = substr($rule, 9); $callback = TRUE; } - + // Strip the parameter (if exists) from the rule // Rules can contain a parameter: max_length[5] $param = FALSE; - if (preg_match("/(.*?)\[(.*?)\]/", $rule, $match)) + if (preg_match("/(.*?)\[(.*)\]/", $rule, $match)) { $rule = $match[1]; $param = $match[2]; } - + // Call the function that corresponds to the rule if ($callback === TRUE) { if ( ! method_exists($this->CI, $rule)) - { + { continue; } - + // Run the function and grab the result $result = $this->CI->$rule($postdata, $param); @@ -597,7 +602,7 @@ class CI_Form_validation { { $this->_field_data[$row['field']]['postdata'] = (is_bool($result)) ? $postdata : $result; } - + // If the field isn't required and we just processed a callback we'll move on... if ( ! in_array('required', $rules, TRUE) AND $result !== FALSE) { @@ -605,15 +610,15 @@ class CI_Form_validation { } } else - { + { if ( ! method_exists($this, $rule)) { - // If our own wrapper function doesn't exist we see if a native PHP function does. + // If our own wrapper function doesn't exist we see if a native PHP function does. // Users can use any native PHP function call that has one param. if (function_exists($rule)) { $result = $rule($postdata); - + if ($_in_array == TRUE) { $this->_field_data[$row['field']]['postdata'][$cycles] = (is_bool($result)) ? $postdata : $result; @@ -623,7 +628,7 @@ class CI_Form_validation { $this->_field_data[$row['field']]['postdata'] = (is_bool($result)) ? $postdata : $result; } } - + continue; } @@ -638,54 +643,54 @@ class CI_Form_validation { $this->_field_data[$row['field']]['postdata'] = (is_bool($result)) ? $postdata : $result; } } - + // Did the rule test negatively? If so, grab the error. if ($result === FALSE) - { + { if ( ! isset($this->_error_messages[$rule])) { if (FALSE === ($line = $this->CI->lang->line($rule))) { $line = 'Unable to access an error message corresponding to your field name.'; - } + } } else { $line = $this->_error_messages[$rule]; } - + // Is the parameter we are inserting into the error message the name // of another field? If so we need to grab its "field label" if (isset($this->_field_data[$param]) AND isset($this->_field_data[$param]['label'])) { - $param = $this->_field_data[$param]['label']; + $param = $this->_translate_fieldname($this->_field_data[$param]['label']); } - + // Build the error message $message = sprintf($line, $this->_translate_fieldname($row['label']), $param); // Save the error message $this->_field_data[$row['field']]['error'] = $message; - + if ( ! isset($this->_error_array[$row['field']])) { $this->_error_array[$row['field']] = $message; } - + return; } } } // -------------------------------------------------------------------- - + /** * Translate a field name * * @access private * @param string the field name * @return string - */ + */ function _translate_fieldname($fieldname) { // Do we need to translate the field name? @@ -693,8 +698,8 @@ class CI_Form_validation { if (substr($fieldname, 0, 5) == 'lang:') { // Grab the variable - $line = substr($fieldname, 5); - + $line = substr($fieldname, 5); + // Were we able to translate the field name? If not we use $line if (FALSE === ($fieldname = $this->CI->lang->line($line))) { @@ -706,7 +711,7 @@ class CI_Form_validation { } // -------------------------------------------------------------------- - + /** * Get the value from a form * @@ -717,19 +722,26 @@ class CI_Form_validation { * @param string the field name * @param string * @return void - */ + */ function set_value($field = '', $default = '') { if ( ! isset($this->_field_data[$field])) { return $default; } - + + // If the data is an array output them one at a time. + // E.g: form_input('name[]', set_value('name[]'); + if (is_array($this->_field_data[$field]['postdata'])) + { + return array_shift($this->_field_data[$field]['postdata']); + } + return $this->_field_data[$field]['postdata']; } - + // -------------------------------------------------------------------- - + /** * Set Select * @@ -740,9 +752,9 @@ class CI_Form_validation { * @param string * @param string * @return string - */ + */ function set_select($field = '', $value = '', $default = FALSE) - { + { if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata'])) { if ($default === TRUE AND count($this->_field_data) === 0) @@ -751,9 +763,9 @@ class CI_Form_validation { } return ''; } - + $field = $this->_field_data[$field]['postdata']; - + if (is_array($field)) { if ( ! in_array($value, $field)) @@ -768,12 +780,12 @@ class CI_Form_validation { return ''; } } - + return ' selected="selected"'; } - + // -------------------------------------------------------------------- - + /** * Set Radio * @@ -784,7 +796,7 @@ class CI_Form_validation { * @param string * @param string * @return string - */ + */ function set_radio($field = '', $value = '', $default = FALSE) { if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata'])) @@ -795,9 +807,9 @@ class CI_Form_validation { } return ''; } - + $field = $this->_field_data[$field]['postdata']; - + if (is_array($field)) { if ( ! in_array($value, $field)) @@ -812,12 +824,12 @@ class CI_Form_validation { return ''; } } - + return ' checked="checked"'; } - + // -------------------------------------------------------------------- - + /** * Set Checkbox * @@ -828,7 +840,7 @@ class CI_Form_validation { * @param string * @param string * @return string - */ + */ function set_checkbox($field = '', $value = '', $default = FALSE) { if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata'])) @@ -839,9 +851,9 @@ class CI_Form_validation { } return ''; } - + $field = $this->_field_data[$field]['postdata']; - + if (is_array($field)) { if ( ! in_array($value, $field)) @@ -856,12 +868,12 @@ class CI_Form_validation { return ''; } } - + return ' checked="checked"'; } - + // -------------------------------------------------------------------- - + /** * Required * @@ -880,9 +892,29 @@ class CI_Form_validation { return ( ! empty($str)); } } - + + // -------------------------------------------------------------------- + + /** + * Performs a Regular Expression match test. + * + * @access public + * @param string + * @param regex + * @return bool + */ + function regex_match($str, $regex) + { + if ( ! preg_match($regex, $str)) + { + return FALSE; + } + + return TRUE; + } + // -------------------------------------------------------------------- - + /** * Match one field to another * @@ -895,16 +927,16 @@ class CI_Form_validation { { if ( ! isset($_POST[$field])) { - return FALSE; + return FALSE; } - + $field = $_POST[$field]; return ($str !== $field) ? FALSE : TRUE; } - + // -------------------------------------------------------------------- - + /** * Minimum Length * @@ -912,7 +944,7 @@ class CI_Form_validation { * @param string * @param value * @return bool - */ + */ function min_length($str, $val) { if (preg_match("/[^0-9]/", $val)) @@ -922,14 +954,14 @@ class CI_Form_validation { if (function_exists('mb_strlen')) { - return (mb_strlen($str) < $val) ? FALSE : TRUE; + return (mb_strlen($str) < $val) ? FALSE : TRUE; } - + return (strlen($str) < $val) ? FALSE : TRUE; } - + // -------------------------------------------------------------------- - + /** * Max Length * @@ -937,7 +969,7 @@ class CI_Form_validation { * @param string * @param value * @return bool - */ + */ function max_length($str, $val) { if (preg_match("/[^0-9]/", $val)) @@ -947,14 +979,14 @@ class CI_Form_validation { if (function_exists('mb_strlen')) { - return (mb_strlen($str) > $val) ? FALSE : TRUE; + return (mb_strlen($str) > $val) ? FALSE : TRUE; } - + return (strlen($str) > $val) ? FALSE : TRUE; } - + // -------------------------------------------------------------------- - + /** * Exact Length * @@ -962,7 +994,7 @@ class CI_Form_validation { * @param string * @param value * @return bool - */ + */ function exact_length($str, $val) { if (preg_match("/[^0-9]/", $val)) @@ -972,42 +1004,42 @@ class CI_Form_validation { if (function_exists('mb_strlen')) { - return (mb_strlen($str) != $val) ? FALSE : TRUE; + return (mb_strlen($str) != $val) ? FALSE : TRUE; } - + return (strlen($str) != $val) ? FALSE : TRUE; } - + // -------------------------------------------------------------------- - + /** * Valid Email * * @access public * @param string * @return bool - */ + */ function valid_email($str) { return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE; } // -------------------------------------------------------------------- - + /** * Valid Emails * * @access public * @param string * @return bool - */ + */ function valid_emails($str) { if (strpos($str, ',') === FALSE) { return $this->valid_email(trim($str)); } - + foreach(explode(',', $str) as $email) { if (trim($email) != '' && $this->valid_email(trim($email)) === FALSE) @@ -1015,12 +1047,12 @@ class CI_Form_validation { return FALSE; } } - + return TRUE; } // -------------------------------------------------------------------- - + /** * Validate IP Address * @@ -1034,56 +1066,56 @@ class CI_Form_validation { } // -------------------------------------------------------------------- - + /** * Alpha * * @access public * @param string * @return bool - */ + */ function alpha($str) { return ( ! preg_match("/^([a-z])+$/i", $str)) ? FALSE : TRUE; } - + // -------------------------------------------------------------------- - + /** * Alpha-numeric * * @access public * @param string * @return bool - */ + */ function alpha_numeric($str) { return ( ! preg_match("/^([a-z0-9])+$/i", $str)) ? FALSE : TRUE; } - + // -------------------------------------------------------------------- - + /** * Alpha-numeric with underscores and dashes * * @access public * @param string * @return bool - */ + */ function alpha_dash($str) { return ( ! preg_match("/^([-a-z0-9_-])+$/i", $str)) ? FALSE : TRUE; } - + // -------------------------------------------------------------------- - + /** * Numeric * * @access public * @param string * @return bool - */ + */ function numeric($str) { return (bool)preg_match( '/^[\-+]?[0-9]*\.?[0-9]+$/', $str); @@ -1092,72 +1124,72 @@ class CI_Form_validation { // -------------------------------------------------------------------- - /** - * Is Numeric - * - * @access public - * @param string - * @return bool - */ - function is_numeric($str) - { - return ( ! is_numeric($str)) ? FALSE : TRUE; - } + /** + * Is Numeric + * + * @access public + * @param string + * @return bool + */ + function is_numeric($str) + { + return ( ! is_numeric($str)) ? FALSE : TRUE; + } // -------------------------------------------------------------------- - + /** * Integer * * @access public * @param string * @return bool - */ + */ function integer($str) { return (bool)preg_match( '/^[\-+]?[0-9]+$/', $str); } - + // -------------------------------------------------------------------- - /** - * Is a Natural number (0,1,2,3, etc.) - * - * @access public - * @param string - * @return bool - */ - function is_natural($str) - { - return (bool)preg_match( '/^[0-9]+$/', $str); - } + /** + * Is a Natural number (0,1,2,3, etc.) + * + * @access public + * @param string + * @return bool + */ + function is_natural($str) + { + return (bool)preg_match( '/^[0-9]+$/', $str); + } // -------------------------------------------------------------------- - /** - * Is a Natural number, but not a zero (1,2,3, etc.) - * - * @access public - * @param string - * @return bool - */ + /** + * Is a Natural number, but not a zero (1,2,3, etc.) + * + * @access public + * @param string + * @return bool + */ function is_natural_no_zero($str) - { - if ( ! preg_match( '/^[0-9]+$/', $str)) - { - return FALSE; - } - - if ($str == 0) - { - return FALSE; - } - - return TRUE; - } - + { + if ( ! preg_match( '/^[0-9]+$/', $str)) + { + return FALSE; + } + + if ($str == 0) + { + return FALSE; + } + + return TRUE; + } + // -------------------------------------------------------------------- - + /** * Valid Base64 * @@ -1172,9 +1204,9 @@ class CI_Form_validation { { return (bool) ! preg_match('/[^a-zA-Z0-9\/\+=]/', $str); } - + // -------------------------------------------------------------------- - + /** * Prep data for form * @@ -1193,10 +1225,10 @@ class CI_Form_validation { { $data[$key] = $this->prep_for_form($val); } - + return $data; } - + if ($this->_safe_form_data == FALSE OR $data === '') { return $data; @@ -1204,68 +1236,73 @@ class CI_Form_validation { return str_replace(array("'", '"', '<', '>'), array("'", """, '<', '>'), stripslashes($data)); } - + // -------------------------------------------------------------------- - + /** * Prep URL * * @access public * @param string * @return string - */ + */ function prep_url($str = '') { if ($str == 'http://' OR $str == '') { return ''; } - + if (substr($str, 0, 7) != 'http://' && substr($str, 0, 8) != 'https://') { $str = 'http://'.$str; } - + return $str; } - + // -------------------------------------------------------------------- - + /** * Strip Image Tags * * @access public * @param string * @return string - */ + */ function strip_image_tags($str) { return $this->CI->input->strip_image_tags($str); } - + // -------------------------------------------------------------------- - + /** * XSS Clean * * @access public * @param string * @return string - */ + */ function xss_clean($str) { - return $this->CI->input->xss_clean($str); + if ( ! isset($this->CI->security)) + { + $this->CI->load->library('security'); + } + + return $this->CI->security->xss_clean($str); } - + // -------------------------------------------------------------------- - + /** * Convert PHP tags to entities * * @access public * @param string * @return string - */ + */ function encode_php_tags($str) { return str_replace(array('<?php', '<?PHP', '<?', '?>'), array('<?php', '<?PHP', '<?', '?>'), $str); diff --git a/system/libraries/Ftp.php b/system/libraries/Ftp.php index 16ad9ad43..d7a8b3b02 100644..100755 --- a/system/libraries/Ftp.php +++ b/system/libraries/Ftp.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -40,7 +40,7 @@ class CI_FTP { * * The constructor can be passed an array of config values */ - function CI_FTP($config = array()) + public function __construct($config = array()) { if (count($config) > 0) { @@ -281,6 +281,48 @@ class CI_FTP { // -------------------------------------------------------------------- /** + * Download a file from a remote server to the local server + * + * @access public + * @param string + * @param string + * @param string + * @return bool + */ + function download($rempath, $locpath, $mode = 'auto') + { + if ( ! $this->_is_conn()) + { + return FALSE; + } + + // Set the mode if not specified + if ($mode == 'auto') + { + // Get the file extension so we can set the upload type + $ext = $this->_getext($rempath); + $mode = $this->_settype($ext); + } + + $mode = ($mode == 'ascii') ? FTP_ASCII : FTP_BINARY; + + $result = @ftp_get($this->conn_id, $locpath, $rempath, $mode); + + if ($result === FALSE) + { + if ($this->debug == TRUE) + { + $this->_error('ftp_unable_to_download'); + } + return FALSE; + } + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** * Rename (or move) a file * * @access public @@ -412,7 +454,7 @@ class CI_FTP { * Set file permissions * * @access public - * @param string the file path + * @param string the file path * @param string the permissions * @return bool */ diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 0b29c1fbd..41f9ad393 100644..100755 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -26,7 +26,7 @@ */ class CI_Image_lib { - var $image_library = 'gd2'; // Can be: imagemagick, netpbm, gd, gd2 + var $image_library = 'gd2'; // Can be: imagemagick, netpbm, gd, gd2 var $library_path = ''; var $dynamic_output = FALSE; // Whether to send to browser or write to disk var $source_image = ''; @@ -36,7 +36,7 @@ class CI_Image_lib { var $quality = '90'; var $create_thumb = FALSE; var $thumb_marker = '_thumb'; - var $maintain_ratio = TRUE; // Whether to maintain aspect ratio when resizing or use hard values + var $maintain_ratio = TRUE; // Whether to maintain aspect ratio when resizing or use hard values var $master_dim = 'auto'; // auto, height, or width. Determines what to use as the master dimension var $rotation_angle = ''; var $x_axis = ''; @@ -54,11 +54,11 @@ class CI_Image_lib { var $wm_hor_alignment = 'C'; // Horizontal alignment: L R C var $wm_padding = 0; // Padding around text var $wm_hor_offset = 0; // Lets you push text to the right - var $wm_vrt_offset = 0; // Lets you push text down + var $wm_vrt_offset = 0; // Lets you push text down var $wm_font_color = '#ffffff'; // Text color var $wm_shadow_color = ''; // Dropshadow color var $wm_shadow_distance = 2; // Dropshadow distance - var $wm_opacity = 50; // Image opacity: 1 - 100 Only works with image + var $wm_opacity = 50; // Image opacity: 1 - 100 Only works with image // Private Vars var $source_folder = ''; @@ -79,11 +79,10 @@ class CI_Image_lib { /** * Constructor * - * @access public * @param string * @return void */ - function CI_Image_lib($props = array()) + public function __construct($props = array()) { if (count($props) > 0) { @@ -147,7 +146,7 @@ class CI_Image_lib { if ($this->source_image == '') { $this->set_error('imglib_source_image_required'); - return FALSE; + return FALSE; } /* @@ -190,7 +189,7 @@ class CI_Image_lib { // Set the Image Properties if ( ! $this->get_image_properties($this->source_folder.$this->source_image)) { - return FALSE; + return FALSE; } /* @@ -400,7 +399,7 @@ class CI_Image_lib { if ($this->rotation_angle == '' OR ! in_array($this->rotation_angle, $degs)) { $this->set_error('imglib_rotation_angle_required'); - return FALSE; + return FALSE; } // Reassign the width and height @@ -455,11 +454,11 @@ class CI_Image_lib { { if ($this->orig_width == $this->width AND $this->orig_height == $this->height) { - if ($this->source_image != $this->new_image) - { + if ($this->source_image != $this->new_image) + { if (@copy($this->full_src_path, $this->full_dst_path)) { - @chmod($this->full_dst_path, DIR_WRITE_MODE); + @chmod($this->full_dst_path, FILE_WRITE_MODE); } } @@ -494,14 +493,14 @@ class CI_Image_lib { return FALSE; } - // Create The Image + // Create The Image // // old conditional which users report cause problems with shared GD libs who report themselves as "2.0 or greater" // it appears that this is no longer the issue that it was in 2004, so we've removed it, retaining it in the comment // below should that ever prove inaccurate. // // if ($this->image_library == 'gd2' AND function_exists('imagecreatetruecolor') AND $v2_override == FALSE) - if ($this->image_library == 'gd2' AND function_exists('imagecreatetruecolor')) + if ($this->image_library == 'gd2' AND function_exists('imagecreatetruecolor')) { $create = 'imagecreatetruecolor'; $copy = 'imagecopyresampled'; @@ -513,6 +512,13 @@ class CI_Image_lib { } $dst_img = $create($this->width, $this->height); + + if ($this->image_type == 3) // png we can actually preserve transparency + { + imagealphablending($dst_img, FALSE); + imagesavealpha($dst_img, TRUE); + } + $copy($dst_img, $src_img, 0, 0, $this->x_axis, $this->y_axis, $this->width, $this->height, $this->orig_width, $this->orig_height); // Show the image @@ -534,7 +540,7 @@ class CI_Image_lib { imagedestroy($src_img); // Set the file to 777 - @chmod($this->full_dst_path, DIR_WRITE_MODE); + @chmod($this->full_dst_path, FILE_WRITE_MODE); return TRUE; } @@ -577,9 +583,9 @@ class CI_Image_lib { { switch ($this->rotation_angle) { - case 'hor' : $angle = '-flop'; + case 'hor' : $angle = '-flop'; break; - case 'vrt' : $angle = '-flip'; + case 'vrt' : $angle = '-flip'; break; default : $angle = '-rotate '.$this->rotation_angle; break; @@ -604,7 +610,7 @@ class CI_Image_lib { } // Set the file to 777 - @chmod($this->full_dst_path, DIR_WRITE_MODE); + @chmod($this->full_dst_path, FILE_WRITE_MODE); return TRUE; } @@ -657,7 +663,7 @@ class CI_Image_lib { break; case 180 : $angle = 'r180'; break; - case 270 : $angle = 'r90'; + case 270 : $angle = 'r90'; break; case 'vrt' : $angle = 'tb'; break; @@ -690,7 +696,7 @@ class CI_Image_lib { // we have to rename the temp file. copy ($this->dest_folder.'netpbm.tmp', $this->full_dst_path); unlink ($this->dest_folder.'netpbm.tmp'); - @chmod($this->full_dst_path, DIR_WRITE_MODE); + @chmod($this->full_dst_path, FILE_WRITE_MODE); return TRUE; } @@ -705,14 +711,6 @@ class CI_Image_lib { */ function image_rotate_gd() { - // Is Image Rotation Supported? - // this function is only supported as of PHP 4.3 - if ( ! function_exists('imagerotate')) - { - $this->set_error('imglib_rotate_unsupported'); - return FALSE; - } - // Create the image handle if ( ! ($src_img = $this->image_create_gd())) { @@ -749,7 +747,7 @@ class CI_Image_lib { // Set the file to 777 - @chmod($this->full_dst_path, DIR_WRITE_MODE); + @chmod($this->full_dst_path, FILE_WRITE_MODE); return true; } @@ -833,7 +831,7 @@ class CI_Image_lib { imagedestroy($src_img); // Set the file to 777 - @chmod($this->full_dst_path, DIR_WRITE_MODE); + @chmod($this->full_dst_path, FILE_WRITE_MODE); return TRUE; } @@ -882,7 +880,7 @@ class CI_Image_lib { $this->get_image_properties(); // Fetch watermark image properties - $props = $this->get_image_properties($this->wm_overlay_path, TRUE); + $props = $this->get_image_properties($this->wm_overlay_path, TRUE); $wm_img_type = $props['image_type']; $wm_width = $props['width']; $wm_height = $props['height']; @@ -937,7 +935,7 @@ class CI_Image_lib { if ($wm_img_type == 3 AND function_exists('imagealphablending')) { @imagealphablending($src_img, TRUE); - } + } // Set RGB values for text and shadow $rgba = imagecolorat($wm_img, $this->wm_x_transp, $this->wm_y_transp); @@ -1208,11 +1206,6 @@ class CI_Image_lib { return FALSE; } - if (phpversion() == '4.4.1') - { - @touch($this->full_dst_path); // PHP 4.4.1 bug #35060 - workaround - } - if ( ! @imagejpeg($resource, $this->full_dst_path, $this->quality)) { $this->set_error('imglib_save_failed'); @@ -1259,7 +1252,7 @@ class CI_Image_lib { switch ($this->image_type) { - case 1 : imagegif($resource); + case 1 : imagegif($resource); break; case 2 : imagejpeg($resource, '', $this->quality); break; @@ -1377,8 +1370,8 @@ class CI_Image_lib { * new variable needs to be known * * $props = array( - * 'width' => $width, - * 'height' => $height, + * 'width' => $width, + * 'height' => $height, * 'new_width' => 40, * 'new_height' => '' * ); @@ -1439,7 +1432,7 @@ class CI_Image_lib { { $ext = strrchr($source_image, '.'); $name = ($ext === FALSE) ? $source_image : substr($source_image, 0, -strlen($ext)); - + return array('ext' => $ext, 'name' => $name); } diff --git a/system/libraries/Input.php b/system/libraries/Input.php deleted file mode 100644 index 396815194..000000000 --- a/system/libraries/Input.php +++ /dev/null @@ -1,1067 +0,0 @@ -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); -/** - * CodeIgniter - * - * An open source application development framework for PHP 4.3.2 or newer - * - * @package CodeIgniter - * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. - * @license http://codeigniter.com/user_guide/license.html - * @link http://codeigniter.com - * @since Version 1.0 - * @filesource - */ - -// ------------------------------------------------------------------------ - -/** - * Input Class - * - * Pre-processes global input data for security - * - * @package CodeIgniter - * @subpackage Libraries - * @category Input - * @author ExpressionEngine Dev Team - * @link http://codeigniter.com/user_guide/libraries/input.html - */ -class CI_Input { - var $use_xss_clean = FALSE; - var $xss_hash = ''; - var $ip_address = FALSE; - var $user_agent = FALSE; - var $allow_get_array = FALSE; - - /* never allowed, string replacement */ - var $never_allowed_str = array( - 'document.cookie' => '[removed]', - 'document.write' => '[removed]', - '.parentNode' => '[removed]', - '.innerHTML' => '[removed]', - 'window.location' => '[removed]', - '-moz-binding' => '[removed]', - '<!--' => '<!--', - '-->' => '-->', - '<![CDATA[' => '<![CDATA[' - ); - /* never allowed, regex replacement */ - var $never_allowed_regex = array( - "javascript\s*:" => '[removed]', - "expression\s*(\(|&\#40;)" => '[removed]', // CSS and IE - "vbscript\s*:" => '[removed]', // IE, surprise! - "Redirect\s+302" => '[removed]' - ); - - /** - * Constructor - * - * Sets whether to globally enable the XSS processing - * and whether to allow the $_GET array - * - * @access public - */ - function CI_Input() - { - log_message('debug', "Input Class Initialized"); - - $CFG =& load_class('Config'); - $this->use_xss_clean = ($CFG->item('global_xss_filtering') === TRUE) ? TRUE : FALSE; - $this->allow_get_array = ($CFG->item('enable_query_strings') === TRUE) ? TRUE : FALSE; - $this->_sanitize_globals(); - } - - // -------------------------------------------------------------------- - - /** - * 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() - { - // Would kind of 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 security. - // This is effectively the same as register_globals = off - foreach (array($_GET, $_POST, $_COOKIE, $_SERVER, $_FILES, $_ENV, (isset($_SESSION) && is_array($_SESSION)) ? $_SESSION : array()) as $global) - { - if ( ! is_array($global)) - { - if ( ! in_array($global, $protected)) - { - unset($GLOBALS[$global]); - } - } - else - { - foreach ($global as $key => $val) - { - if ( ! in_array($key, $protected)) - { - unset($GLOBALS[$key]); - } - - if (is_array($val)) - { - foreach($val as $k => $v) - { - if ( ! in_array($k, $protected)) - { - unset($GLOBALS[$k]); - } - } - } - } - } - } - - // Is $_GET data allowed? If not we'll set the $_GET to an empty array - if ($this->allow_get_array == FALSE) - { - $_GET = array(); - } - else - { - $_GET = $this->_clean_input_data($_GET); - } - - // Clean $_POST Data - $_POST = $this->_clean_input_data($_POST); - - // Clean $_COOKIE Data - // 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']); - $_COOKIE = $this->_clean_input_data($_COOKIE); - - log_message('debug', "Global POST and COOKIE data sanitized"); - } - - // -------------------------------------------------------------------- - - /** - * Clean Input Data - * - * This is a helper function. It escapes data and - * standardizes newline characters to \n - * - * @access private - * @param string - * @return string - */ - function _clean_input_data($str) - { - if (is_array($str)) - { - $new_array = array(); - foreach ($str as $key => $val) - { - $new_array[$this->_clean_input_keys($key)] = $this->_clean_input_data($val); - } - return $new_array; - } - - // We strip slashes if magic quotes is on to keep things consistent - if (get_magic_quotes_gpc()) - { - $str = stripslashes($str); - } - - // Should we filter the input data? - if ($this->use_xss_clean === TRUE) - { - $str = $this->xss_clean($str); - } - - // Standardize newlines - if (strpos($str, "\r") !== FALSE) - { - $str = str_replace(array("\r\n", "\r"), "\n", $str); - } - - return $str; - } - - // -------------------------------------------------------------------- - - /** - * Clean Keys - * - * This is a helper function. To prevent malicious users - * from trying to exploit keys we make sure that keys are - * only named with alpha-numeric text and a few other items. - * - * @access private - * @param string - * @return string - */ - function _clean_input_keys($str) - { - if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str)) - { - exit('Disallowed Key Characters.'); - } - - return $str; - } - - // -------------------------------------------------------------------- - - /** - * 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->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 = '', $xss_clean = FALSE) - { - 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 = '', $xss_clean = FALSE) - { - 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); - } - - // -------------------------------------------------------------------- - - /** - * Fetch an item from the SERVER array - * - * @access public - * @param string - * @param bool - * @return string - */ - function server($index = '', $xss_clean = FALSE) - { - return $this->_fetch_from_array($_SERVER, $index, $xss_clean); - } - - // -------------------------------------------------------------------- - - /** - * Fetch the IP Address - * - * @access public - * @return string - */ - function ip_address() - { - if ($this->ip_address !== FALSE) - { - return $this->ip_address; - } - - if (config_item('proxy_ips') != '' && $this->server('HTTP_X_FORWARDED_FOR') && $this->server('REMOTE_ADDR')) - { - $proxies = preg_split('/[\s,]/', config_item('proxy_ips'), -1, PREG_SPLIT_NO_EMPTY); - $proxies = is_array($proxies) ? $proxies : array($proxies); - - $this->ip_address = in_array($_SERVER['REMOTE_ADDR'], $proxies) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; - } - elseif ($this->server('REMOTE_ADDR') AND $this->server('HTTP_CLIENT_IP')) - { - $this->ip_address = $_SERVER['HTTP_CLIENT_IP']; - } - elseif ($this->server('REMOTE_ADDR')) - { - $this->ip_address = $_SERVER['REMOTE_ADDR']; - } - elseif ($this->server('HTTP_CLIENT_IP')) - { - $this->ip_address = $_SERVER['HTTP_CLIENT_IP']; - } - elseif ($this->server('HTTP_X_FORWARDED_FOR')) - { - $this->ip_address = $_SERVER['HTTP_X_FORWARDED_FOR']; - } - - if ($this->ip_address === FALSE) - { - $this->ip_address = '0.0.0.0'; - return $this->ip_address; - } - - if (strstr($this->ip_address, ',')) - { - $x = explode(',', $this->ip_address); - $this->ip_address = trim(end($x)); - } - - if ( ! $this->valid_ip($this->ip_address)) - { - $this->ip_address = '0.0.0.0'; - } - - return $this->ip_address; - } - - // -------------------------------------------------------------------- - - /** - * Validate IP Address - * - * Updated version suggested by Geert De Deckere - * - * @access public - * @param string - * @return string - */ - function valid_ip($ip) - { - $ip_segments = explode('.', $ip); - - // Always 4 segments needed - if (count($ip_segments) != 4) - { - return FALSE; - } - // IP can not start with 0 - if ($ip_segments[0][0] == '0') - { - return FALSE; - } - // Check each segment - foreach ($ip_segments as $segment) - { - // IP segments must be digits and can not be - // longer than 3 digits or greater then 255 - if ($segment == '' OR preg_match("/[^0-9]/", $segment) OR $segment > 255 OR strlen($segment) > 3) - { - return FALSE; - } - } - - return TRUE; - } - - // -------------------------------------------------------------------- - - /** - * User Agent - * - * @access public - * @return string - */ - function user_agent() - { - if ($this->user_agent !== FALSE) - { - return $this->user_agent; - } - - $this->user_agent = ( ! isset($_SERVER['HTTP_USER_AGENT'])) ? FALSE : $_SERVER['HTTP_USER_AGENT']; - - return $this->user_agent; - } - - // -------------------------------------------------------------------- - - /** - * Filename Security - * - * @access public - * @param string - * @return string - */ - function filename_security($str) - { - $bad = array( - "../", - "./", - "<!--", - "-->", - "<", - ">", - "'", - '"', - '&', - '$', - '#', - '{', - '}', - '[', - ']', - '=', - ';', - '?', - "%20", - "%22", - "%3c", // < - "%253c", // < - "%3e", // > - "%0e", // > - "%28", // ( - "%29", // ) - "%2528", // ( - "%26", // & - "%24", // $ - "%3f", // ? - "%3b", // ; - "%3d" // = - ); - - return stripslashes(str_replace($bad, '', $str)); - } - - // -------------------------------------------------------------------- - - /** - * XSS Clean - * - * Sanitizes data so that Cross Site Scripting Hacks can be - * prevented. This function does a fair amount of work but - * it is extremely thorough, designed to prevent even the - * most obscure XSS attempts. Nothing is ever 100% foolproof, - * of course, but I haven't been able to get anything passed - * the filter. - * - * Note: This function should only be used to deal with data - * upon submission. It's not something that should - * be used for general runtime processing. - * - * This function was based in part on some code and ideas I - * got from Bitflux: http://blog.bitflux.ch/wiki/XSS_Prevention - * - * To help develop this script I used this great list of - * vulnerabilities along with a few other hacks I've - * harvested from examining vulnerabilities in other programs: - * http://ha.ckers.org/xss.html - * - * @access public - * @param string - * @return string - */ - function xss_clean($str, $is_image = FALSE) - { - /* - * Is the string an array? - * - */ - if (is_array($str)) - { - while (list($key) = each($str)) - { - $str[$key] = $this->xss_clean($str[$key]); - } - - return $str; - } - - /* - * Remove Invisible Characters - */ - $str = $this->_remove_invisible_characters($str); - - /* - * Protect GET variables in URLs - */ - - // 901119URL5918AMP18930PROTECT8198 - - $str = preg_replace('|\&([a-z\_0-9]+)\=([a-z\_0-9]+)|i', $this->xss_hash()."\\1=\\2", $str); - - /* - * Validate standard character entities - * - * Add a semicolon if missing. We do this to enable - * the conversion of entities to ASCII later. - * - */ - $str = preg_replace('#(&\#?[0-9a-z]{2,})([\x00-\x20])*;?#i', "\\1;\\2", $str); - - /* - * Validate UTF16 two byte encoding (x00) - * - * Just as above, adds a semicolon if missing. - * - */ - $str = preg_replace('#(&\#x?)([0-9A-F]+);?#i',"\\1\\2;",$str); - - /* - * Un-Protect GET variables in URLs - */ - $str = str_replace($this->xss_hash(), '&', $str); - - /* - * URL Decode - * - * Just in case stuff like this is submitted: - * - * <a href="http://%77%77%77%2E%67%6F%6F%67%6C%65%2E%63%6F%6D">Google</a> - * - * Note: Use rawurldecode() so it does not remove plus signs - * - */ - $str = rawurldecode($str); - - /* - * Convert character entities to ASCII - * - * This permits our tests below to work reliably. - * We only convert entities that are within tags since - * these are the ones that will pose security problems. - * - */ - - $str = preg_replace_callback("/[a-z]+=([\'\"]).*?\\1/si", array($this, '_convert_attribute'), $str); - - $str = preg_replace_callback("/<\w+.*?(?=>|<|$)/si", array($this, '_html_entity_decode_callback'), $str); - - /* - * Remove Invisible Characters Again! - */ - $str = $this->_remove_invisible_characters($str); - - /* - * Convert all tabs to spaces - * - * This prevents strings like this: ja vascript - * NOTE: we deal with spaces between characters later. - * NOTE: preg_replace was found to be amazingly slow here on large blocks of data, - * so we use str_replace. - * - */ - - if (strpos($str, "\t") !== FALSE) - { - $str = str_replace("\t", ' ', $str); - } - - /* - * Capture converted string for later comparison - */ - $converted_string = $str; - - /* - * Not Allowed Under Any Conditions - */ - - foreach ($this->never_allowed_str as $key => $val) - { - $str = str_replace($key, $val, $str); - } - - foreach ($this->never_allowed_regex as $key => $val) - { - $str = preg_replace("#".$key."#i", $val, $str); - } - - /* - * Makes PHP tags safe - * - * Note: XML tags are inadvertently replaced too: - * - * <?xml - * - * But it doesn't seem to pose a problem. - * - */ - if ($is_image === TRUE) - { - // Images have a tendency to have the PHP short opening and closing tags every so often - // so we skip those and only do the long opening tags. - $str = preg_replace('/<\?(php)/i', "<?\\1", $str); - } - else - { - $str = str_replace(array('<?', '?'.'>'), array('<?', '?>'), $str); - } - - /* - * Compact any exploded words - * - * This corrects words like: j a v a s c r i p t - * These words are compacted back to their correct state. - * - */ - $words = array('javascript', 'expression', 'vbscript', 'script', 'applet', 'alert', 'document', 'write', 'cookie', 'window'); - foreach ($words as $word) - { - $temp = ''; - - for ($i = 0, $wordlen = strlen($word); $i < $wordlen; $i++) - { - $temp .= substr($word, $i, 1)."\s*"; - } - - // We only want to do this when it is followed by a non-word character - // That way valid stuff like "dealer to" does not become "dealerto" - $str = preg_replace_callback('#('.substr($temp, 0, -3).')(\W)#is', array($this, '_compact_exploded_words'), $str); - } - - /* - * Remove disallowed Javascript in links or img tags - * We used to do some version comparisons and use of stripos for PHP5, but it is dog slow compared - * to these simplified non-capturing preg_match(), especially if the pattern exists in the string - */ - do - { - $original = $str; - - if (preg_match("/<a/i", $str)) - { - $str = preg_replace_callback("#<a\s+([^>]*?)(>|$)#si", array($this, '_js_link_removal'), $str); - } - - if (preg_match("/<img/i", $str)) - { - $str = preg_replace_callback("#<img\s+([^>]*?)(\s?/?>|$)#si", array($this, '_js_img_removal'), $str); - } - - if (preg_match("/script/i", $str) OR preg_match("/xss/i", $str)) - { - $str = preg_replace("#<(/*)(script|xss)(.*?)\>#si", '[removed]', $str); - } - } - while($original != $str); - - unset($original); - - /* - * Remove JavaScript Event Handlers - * - * Note: This code is a little blunt. It removes - * the event handler and anything up to the closing >, - * but it's unlikely to be a problem. - * - */ - $event_handlers = array('[^a-z_\-]on\w*','xmlns'); - - if ($is_image === TRUE) - { - /* - * Adobe Photoshop puts XML metadata into JFIF images, including namespacing, - * so we have to allow this for images. -Paul - */ - unset($event_handlers[array_search('xmlns', $event_handlers)]); - } - - $str = preg_replace("#<([^><]+?)(".implode('|', $event_handlers).")(\s*=\s*[^><]*)([><]*)#i", "<\\1\\4", $str); - - /* - * Sanitize naughty HTML elements - * - * If a tag containing any of the words in the list - * below is found, the tag gets converted to entities. - * - * So this: <blink> - * Becomes: <blink> - * - */ - $naughty = 'alert|applet|audio|basefont|base|behavior|bgsound|blink|body|embed|expression|form|frameset|frame|head|html|ilayer|iframe|input|isindex|layer|link|meta|object|plaintext|style|script|textarea|title|video|xml|xss'; - $str = preg_replace_callback('#<(/*\s*)('.$naughty.')([^><]*)([><]*)#is', array($this, '_sanitize_naughty_html'), $str); - - /* - * Sanitize naughty scripting elements - * - * Similar to above, only instead of looking for - * tags it looks for PHP and JavaScript commands - * that are disallowed. Rather than removing the - * code, it simply converts the parenthesis to entities - * rendering the code un-executable. - * - * For example: eval('some code') - * Becomes: eval('some code') - * - */ - $str = preg_replace('#(alert|cmd|passthru|eval|exec|expression|system|fopen|fsockopen|file|file_get_contents|readfile|unlink)(\s*)\((.*?)\)#si', "\\1\\2(\\3)", $str); - - /* - * Final clean up - * - * This adds a bit of extra precaution in case - * something got through the above filters - * - */ - foreach ($this->never_allowed_str as $key => $val) - { - $str = str_replace($key, $val, $str); - } - - foreach ($this->never_allowed_regex as $key => $val) - { - $str = preg_replace("#".$key."#i", $val, $str); - } - - /* - * Images are Handled in a Special Way - * - Essentially, we want to know that after all of the character conversion is done whether - * any unwanted, likely XSS, code was found. If not, we return TRUE, as the image is clean. - * However, if the string post-conversion does not matched the string post-removal of XSS, - * then it fails, as there was unwanted XSS code found and removed/changed during processing. - */ - - if ($is_image === TRUE) - { - if ($str == $converted_string) - { - return TRUE; - } - else - { - return FALSE; - } - } - - log_message('debug', "XSS Filtering completed"); - return $str; - } - - // -------------------------------------------------------------------- - - /** - * Random Hash for protecting URLs - * - * @access public - * @return string - */ - function xss_hash() - { - if ($this->xss_hash == '') - { - if (phpversion() >= 4.2) - mt_srand(); - else - mt_srand(hexdec(substr(md5(microtime()), -8)) & 0x7fffffff); - - $this->xss_hash = md5(time() + mt_rand(0, 1999999999)); - } - - return $this->xss_hash; - } - - // -------------------------------------------------------------------- - - /** - * Remove Invisible Characters - * - * This prevents sandwiching null characters - * between ascii characters, like Java\0script. - * - * @access public - * @param string - * @return string - */ - function _remove_invisible_characters($str) - { - static $non_displayables; - - if ( ! isset($non_displayables)) - { - // every control character except newline (dec 10), carriage return (dec 13), and horizontal tab (dec 09), - $non_displayables = array( - '/%0[0-8bcef]/', // url encoded 00-08, 11, 12, 14, 15 - '/%1[0-9a-f]/', // url encoded 16-31 - '/[\x00-\x08]/', // 00-08 - '/\x0b/', '/\x0c/', // 11, 12 - '/[\x0e-\x1f]/' // 14-31 - ); - } - - do - { - $cleaned = $str; - $str = preg_replace($non_displayables, '', $str); - } - while ($cleaned != $str); - - return $str; - } - - // -------------------------------------------------------------------- - - /** - * Compact Exploded Words - * - * Callback function for xss_clean() to remove whitespace from - * things like j a v a s c r i p t - * - * @access public - * @param type - * @return type - */ - function _compact_exploded_words($matches) - { - return preg_replace('/\s+/s', '', $matches[1]).$matches[2]; - } - - // -------------------------------------------------------------------- - - /** - * Sanitize Naughty HTML - * - * Callback function for xss_clean() to remove naughty HTML elements - * - * @access private - * @param array - * @return string - */ - function _sanitize_naughty_html($matches) - { - // encode opening brace - $str = '<'.$matches[1].$matches[2].$matches[3]; - - // encode captured opening or closing brace to prevent recursive vectors - $str .= str_replace(array('>', '<'), array('>', '<'), $matches[4]); - - return $str; - } - - // -------------------------------------------------------------------- - - /** - * JS Link Removal - * - * Callback function for xss_clean() to sanitize links - * This limits the PCRE backtracks, making it more performance friendly - * and prevents PREG_BACKTRACK_LIMIT_ERROR from being triggered in - * PHP 5.2+ on link-heavy strings - * - * @access private - * @param array - * @return string - */ - function _js_link_removal($match) - { - $attributes = $this->_filter_attributes(str_replace(array('<', '>'), '', $match[1])); - return str_replace($match[1], preg_replace("#href=.*?(alert\(|alert&\#40;|javascript\:|charset\=|window\.|document\.|\.cookie|<script|<xss|base64\s*,)#si", "", $attributes), $match[0]); - } - - /** - * JS Image Removal - * - * Callback function for xss_clean() to sanitize image tags - * This limits the PCRE backtracks, making it more performance friendly - * and prevents PREG_BACKTRACK_LIMIT_ERROR from being triggered in - * PHP 5.2+ on image tag heavy strings - * - * @access private - * @param array - * @return string - */ - function _js_img_removal($match) - { - $attributes = $this->_filter_attributes(str_replace(array('<', '>'), '', $match[1])); - return str_replace($match[1], preg_replace("#src=.*?(alert\(|alert&\#40;|javascript\:|charset\=|window\.|document\.|\.cookie|<script|<xss|base64\s*,)#si", "", $attributes), $match[0]); - } - - // -------------------------------------------------------------------- - - /** - * Attribute Conversion - * - * Used as a callback for XSS Clean - * - * @access public - * @param array - * @return string - */ - function _convert_attribute($match) - { - return str_replace(array('>', '<', '\\'), array('>', '<', '\\\\'), $match[0]); - } - - // -------------------------------------------------------------------- - - /** - * HTML Entity Decode Callback - * - * Used as a callback for XSS Clean - * - * @access public - * @param array - * @return string - */ - function _html_entity_decode_callback($match) - { - $CFG =& load_class('Config'); - $charset = $CFG->item('charset'); - - return $this->_html_entity_decode($match[0], strtoupper($charset)); - } - - // -------------------------------------------------------------------- - - /** - * HTML Entities Decode - * - * This function is a replacement for html_entity_decode() - * - * In some versions of PHP the native function does not work - * when UTF-8 is the specified character set, so this gives us - * a work-around. More info here: - * http://bugs.php.net/bug.php?id=25670 - * - * @access private - * @param string - * @param string - * @return string - */ - /* ------------------------------------------------- - /* Replacement for html_entity_decode() - /* -------------------------------------------------*/ - - /* - NOTE: html_entity_decode() has a bug in some PHP versions when UTF-8 is the - character set, and the PHP developers said they were not back porting the - fix to versions other than PHP 5.x. - */ - function _html_entity_decode($str, $charset='UTF-8') - { - if (stristr($str, '&') === FALSE) return $str; - - // The reason we are not using html_entity_decode() by itself is because - // while it is not technically correct to leave out the semicolon - // at the end of an entity most browsers will still interpret the entity - // correctly. html_entity_decode() does not convert entities without - // semicolons, so we are left with our own little solution here. Bummer. - - if (function_exists('html_entity_decode') && (strtolower($charset) != 'utf-8' OR version_compare(phpversion(), '5.0.0', '>='))) - { - $str = html_entity_decode($str, ENT_COMPAT, $charset); - $str = preg_replace('~&#x(0*[0-9a-f]{2,5})~ei', 'chr(hexdec("\\1"))', $str); - return preg_replace('~&#([0-9]{2,4})~e', 'chr(\\1)', $str); - } - - // Numeric Entities - $str = preg_replace('~&#x(0*[0-9a-f]{2,5});{0,1}~ei', 'chr(hexdec("\\1"))', $str); - $str = preg_replace('~&#([0-9]{2,4});{0,1}~e', 'chr(\\1)', $str); - - // Literal Entities - Slightly slow so we do another check - if (stristr($str, '&') === FALSE) - { - $str = strtr($str, array_flip(get_html_translation_table(HTML_ENTITIES))); - } - - return $str; - } - - // -------------------------------------------------------------------- - - /** - * Filter Attributes - * - * Filters tag attributes for consistency and safety - * - * @access public - * @param string - * @return string - */ - function _filter_attributes($str) - { - $out = ''; - - if (preg_match_all('#\s*[a-z\-]+\s*=\s*(\042|\047)([^\\1]*?)\\1#is', $str, $matches)) - { - foreach ($matches[0] as $match) - { - $out .= preg_replace("#/\*.*?\*/#s", '', $match); - } - } - - return $out; - } - - // -------------------------------------------------------------------- - -} -// END Input class - -/* End of file Input.php */ -/* Location: ./system/libraries/Input.php */
\ No newline at end of file diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php new file mode 100755 index 000000000..167859abd --- /dev/null +++ b/system/libraries/Javascript.php @@ -0,0 +1,871 @@ +<?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 + */ + +// ------------------------------------------------------------------------ + +/** + * Javascript Class + * + * @package CodeIgniter + * @subpackage Libraries + * @category Javascript + * @author ExpressionEngine Dev Team + * @link http://codeigniter.com/user_guide/libraries/javascript.html + */ +class CI_Javascript { + + var $_javascript_location = 'js'; + + public function __construct($params = array()) + { + $defaults = array('js_library_driver' => 'jquery', 'autoload' => TRUE); + + foreach ($defaults as $key => $val) + { + if (isset($params[$key]) && $params[$key] !== "") + { + $defaults[$key] = $params[$key]; + } + } + + extract($defaults); + + $this->CI =& get_instance(); + + // load the requested js library + $this->CI->load->library('javascript/'.$js_library_driver, array('autoload' => $autoload)); + // make js to refer to current library + $this->js =& $this->CI->$js_library_driver; + + log_message('debug', "Javascript Class Initialized and loaded. Driver used: $js_library_driver"); + } + + // -------------------------------------------------------------------- + // Event Code + // -------------------------------------------------------------------- + + /** + * Blur + * + * Outputs a javascript library blur event + * + * @access public + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function blur($element = 'this', $js = '') + { + return $this->js->_blur($element, $js); + } + + // -------------------------------------------------------------------- + + /** + * Change + * + * Outputs a javascript library change event + * + * @access public + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function change($element = 'this', $js = '') + { + return $this->js->_change($element, $js); + } + + // -------------------------------------------------------------------- + + /** + * Click + * + * Outputs a javascript library click event + * + * @access public + * @param string The element to attach the event to + * @param string The code to execute + * @param boolean whether or not to return false + * @return string + */ + function click($element = 'this', $js = '', $ret_false = TRUE) + { + return $this->js->_click($element, $js, $ret_false); + } + + // -------------------------------------------------------------------- + + /** + * Double Click + * + * Outputs a javascript library dblclick event + * + * @access public + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function dblclick($element = 'this', $js = '') + { + return $this->js->_dblclick($element, $js); + } + + // -------------------------------------------------------------------- + + /** + * Error + * + * Outputs a javascript library error event + * + * @access public + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function error($element = 'this', $js = '') + { + return $this->js->_error($element, $js); + } + + // -------------------------------------------------------------------- + + /** + * Focus + * + * Outputs a javascript library focus event + * + * @access public + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function focus($element = 'this', $js = '') + { + return $this->js->__add_event($focus, $js); + } + + // -------------------------------------------------------------------- + + /** + * Hover + * + * Outputs a javascript library hover event + * + * @access public + * @param string - element + * @param string - Javascript code for mouse over + * @param string - Javascript code for mouse out + * @return string + */ + function hover($element = 'this', $over, $out) + { + return $this->js->__hover($element, $over, $out); + } + + // -------------------------------------------------------------------- + + /** + * Keydown + * + * Outputs a javascript library keydown event + * + * @access public + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function keydown($element = 'this', $js = '') + { + return $this->js->_keydown($element, $js); + } + + // -------------------------------------------------------------------- + + /** + * Keyup + * + * Outputs a javascript library keydown event + * + * @access public + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function keyup($element = 'this', $js = '') + { + return $this->js->_keyup($element, $js); + } + + // -------------------------------------------------------------------- + + /** + * Load + * + * Outputs a javascript library load event + * + * @access public + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function load($element = 'this', $js = '') + { + return $this->js->_load($element, $js); + } + + // -------------------------------------------------------------------- + + /** + * Mousedown + * + * Outputs a javascript library mousedown event + * + * @access public + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function mousedown($element = 'this', $js = '') + { + return $this->js->_mousedown($element, $js); + } + + // -------------------------------------------------------------------- + + /** + * Mouse Out + * + * Outputs a javascript library mouseout event + * + * @access public + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function mouseout($element = 'this', $js = '') + { + return $this->js->_mouseout($element, $js); + } + + // -------------------------------------------------------------------- + + /** + * Mouse Over + * + * Outputs a javascript library mouseover event + * + * @access public + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function mouseover($element = 'this', $js = '') + { + return $this->js->_mouseover($element, $js); + } + + // -------------------------------------------------------------------- + + /** + * Mouseup + * + * Outputs a javascript library mouseup event + * + * @access public + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function mouseup($element = 'this', $js = '') + { + return $this->js->_mouseup($element, $js); + } + + // -------------------------------------------------------------------- + + /** + * Output + * + * Outputs the called javascript to the screen + * + * @access public + * @param string The code to output + * @return string + */ + function output($js) + { + return $this->js->_output($js); + } + + // -------------------------------------------------------------------- + + /** + * Ready + * + * Outputs a javascript library mouseup event + * + * @access public + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function ready($js) + { + return $this->js->_document_ready($js); + } + + // -------------------------------------------------------------------- + + /** + * Resize + * + * Outputs a javascript library resize event + * + * @access public + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function resize($element = 'this', $js = '') + { + return $this->js->_resize($element, $js); + } + + // -------------------------------------------------------------------- + + /** + * Scroll + * + * Outputs a javascript library scroll event + * + * @access public + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function scroll($element = 'this', $js = '') + { + return $this->js->_scroll($element, $js); + } + + // -------------------------------------------------------------------- + + /** + * Unload + * + * Outputs a javascript library unload event + * + * @access public + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function unload($element = 'this', $js = '') + { + return $this->js->_unload($element, $js); + } + + // -------------------------------------------------------------------- + // Effects + // -------------------------------------------------------------------- + + + /** + * Add Class + * + * Outputs a javascript library addClass event + * + * @access public + * @param string - element + * @param string - Class to add + * @return string + */ + function addClass($element = 'this', $class = '') + { + return $this->js->_addClass($element, $class); + } + + // -------------------------------------------------------------------- + + /** + * Animate + * + * Outputs a javascript library animate event + * + * @access public + * @param string - element + * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds + * @param string - Javascript callback function + * @return string + */ + function animate($element = 'this', $params = array(), $speed = '', $extra = '') + { + return $this->js->_animate($element, $params, $speed, $extra); + } + + // -------------------------------------------------------------------- + + /** + * Fade In + * + * Outputs a javascript library hide event + * + * @access public + * @param string - element + * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds + * @param string - Javascript callback function + * @return string + */ + function fadeIn($element = 'this', $speed = '', $callback = '') + { + return $this->js->_fadeIn($element, $speed, $callback); + } + + // -------------------------------------------------------------------- + + /** + * Fade Out + * + * Outputs a javascript library hide event + * + * @access public + * @param string - element + * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds + * @param string - Javascript callback function + * @return string + */ + function fadeOut($element = 'this', $speed = '', $callback = '') + { + return $this->js->_fadeOut($element, $speed, $callback); + } + // -------------------------------------------------------------------- + + /** + * Slide Up + * + * Outputs a javascript library slideUp event + * + * @access public + * @param string - element + * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds + * @param string - Javascript callback function + * @return string + */ + function slideUp($element = 'this', $speed = '', $callback = '') + { + return $this->js->_slideUp($element, $speed, $callback); + + } + + // -------------------------------------------------------------------- + + /** + * Remove Class + * + * Outputs a javascript library removeClass event + * + * @access public + * @param string - element + * @param string - Class to add + * @return string + */ + function removeClass($element = 'this', $class = '') + { + return $this->js->_removeClass($element, $class); + } + + // -------------------------------------------------------------------- + + /** + * Slide Down + * + * Outputs a javascript library slideDown event + * + * @access public + * @param string - element + * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds + * @param string - Javascript callback function + * @return string + */ + function slideDown($element = 'this', $speed = '', $callback = '') + { + return $this->js->_slideDown($element, $speed, $callback); + } + + // -------------------------------------------------------------------- + + /** + * Slide Toggle + * + * Outputs a javascript library slideToggle event + * + * @access public + * @param string - element + * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds + * @param string - Javascript callback function + * @return string + */ + function slideToggle($element = 'this', $speed = '', $callback = '') + { + return $this->js->_slideToggle($element, $speed, $callback); + + } + + // -------------------------------------------------------------------- + + /** + * Hide + * + * Outputs a javascript library hide action + * + * @access public + * @param string - element + * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds + * @param string - Javascript callback function + * @return string + */ + function hide($element = 'this', $speed = '', $callback = '') + { + return $this->js->_hide($element, $speed, $callback); + } + + // -------------------------------------------------------------------- + + /** + * Toggle + * + * Outputs a javascript library toggle event + * + * @access public + * @param string - element + * @return string + */ + function toggle($element = 'this') + { + return $this->js->_toggle($element); + + } + + // -------------------------------------------------------------------- + + /** + * Toggle Class + * + * Outputs a javascript library toggle class event + * + * @access public + * @param string - element + * @return string + */ + function toggleClass($element = 'this', $class='') + { + return $this->js->_toggleClass($element, $class); + } + + // -------------------------------------------------------------------- + + /** + * Show + * + * Outputs a javascript library show event + * + * @access public + * @param string - element + * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds + * @param string - Javascript callback function + * @return string + */ + function show($element = 'this', $speed = '', $callback = '') + { + return $this->js->_show($element, $speed, $callback); + } + + + // -------------------------------------------------------------------- + + /** + * Compile + * + * gather together all script needing to be output + * + * @access public + * @param string The element to attach the event to + * @return string + */ + function compile($view_var = 'script_foot', $script_tags = TRUE) + { + $this->js->_compile($view_var, $script_tags); + } + + /** + * Clear Compile + * + * Clears any previous javascript collected for output + * + * @access public + * @return void + */ + function clear_compile() + { + $this->js->_clear_compile(); + } + + // -------------------------------------------------------------------- + + /** + * External + * + * Outputs a <script> tag with the source as an external js file + * + * @access public + * @param string The element to attach the event to + * @return string + */ + function external($external_file = '', $relative = FALSE) + { + if ($external_file !== '') + { + $this->_javascript_location = $external_file; + } + else + { + if ($this->CI->config->item('javascript_location') != '') + { + $this->_javascript_location = $this->CI->config->item('javascript_location'); + } + } + + if ($relative === TRUE OR strncmp($external_file, 'http://', 7) == 0 OR strncmp($external_file, 'https://', 8) == 0) + { + $str = $this->_open_script($external_file); + } + elseif (strpos($this->_javascript_location, 'http://') !== FALSE) + { + $str = $this->_open_script($this->_javascript_location.$external_file); + } + else + { + $str = $this->_open_script($this->CI->config->slash_item('base_url').$this->_javascript_location.$external_file); + } + + $str .= $this->_close_script(); + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Inline + * + * Outputs a <script> tag + * + * @access public + * @param string The element to attach the event to + * @param boolean If a CDATA section should be added + * @return string + */ + function inline($script, $cdata = TRUE) + { + $str = $this->_open_script(); + $str .= ($cdata) ? "\n// <![CDATA[\n{$script}\n// ]]>\n" : "\n{$script}\n"; + $str .= $this->_close_script(); + + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Open Script + * + * Outputs an opening <script> + * + * @access private + * @param string + * @return string + */ + function _open_script($src = '') + { + $str = '<script type="text/javascript" charset="'.strtolower($this->CI->config->item('charset')).'"'; + $str .= ($src == '') ? '>' : ' src="'.$src.'">'; + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Close Script + * + * Outputs an closing </script> + * + * @access private + * @param string + * @return string + */ + function _close_script($extra = "\n") + { + return "</script>$extra"; + } + + + // -------------------------------------------------------------------- + // -------------------------------------------------------------------- + // AJAX-Y STUFF - still a testbed + // -------------------------------------------------------------------- + // -------------------------------------------------------------------- + + /** + * Update + * + * Outputs a javascript library slideDown event + * + * @access public + * @param string - element + * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds + * @param string - Javascript callback function + * @return string + */ + function update($element = 'this', $speed = '', $callback = '') + { + return $this->js->_updater($element, $speed, $callback); + } + + // -------------------------------------------------------------------- + + /** + * Generate JSON + * + * Can be passed a database result or associative array and returns a JSON formatted string + * + * @param mixed result set or array + * @param bool match array types (defaults to objects) + * @return string a json formatted string + */ + function generate_json($result = NULL, $match_array_type = FALSE) + { + // JSON data can optionally be passed to this function + // either as a database result object or an array, or a user supplied array + if ( ! is_null($result)) + { + if (is_object($result)) + { + $json_result = $result->result_array(); + } + elseif (is_array($result)) + { + $json_result = $result; + } + else + { + return $this->_prep_args($result); + } + } + else + { + return 'null'; + } + + $json = array(); + $_is_assoc = TRUE; + + if ( ! is_array($json_result) AND empty($json_result)) + { + show_error("Generate JSON Failed - Illegal key, value pair."); + } + elseif ($match_array_type) + { + $_is_assoc = $this->_is_associative_array($json_result); + } + + foreach ($json_result as $k => $v) + { + if ($_is_assoc) + { + $json[] = $this->_prep_args($k, TRUE).':'.$this->generate_json($v, $match_array_type); + } + else + { + $json[] = $this->generate_json($v, $match_array_type); + } + } + + $json = implode(',', $json); + + return $_is_assoc ? "{".$json."}" : "[".$json."]"; + + } + + // -------------------------------------------------------------------- + + /** + * Is associative array + * + * Checks for an associative array + * + * @access public + * @param type + * @return type + */ + function _is_associative_array($arr) + { + foreach (array_keys($arr) as $key => $val) + { + if ($key !== $val) + { + return TRUE; + } + } + + return FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Prep Args + * + * Ensures a standard json value and escapes values + * + * @access public + * @param type + * @return type + */ + function _prep_args($result, $is_key = FALSE) + { + if (is_null($result)) + { + return 'null'; + } + elseif (is_bool($result)) + { + return ($result === TRUE) ? 'true' : 'false'; + } + elseif (is_string($result) OR $is_key) + { + return '"'.str_replace(array('\\', "\t", "\n", "\r", '"'), array('\\\\', '\\t', '\\n', "\\r", '\"'), $result).'"'; + } + elseif (is_scalar($result)) + { + return $result; + } + } + + // -------------------------------------------------------------------- +} +// END Javascript Class + +/* End of file Javascript.php */ +/* Location: ./system/libraries/Javascript.php */
\ No newline at end of file diff --git a/system/libraries/Log.php b/system/libraries/Log.php index 4e6b3bc39..fb2c5a49b 100644..100755 --- a/system/libraries/Log.php +++ b/system/libraries/Log.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -26,87 +26,84 @@ */ class CI_Log { - var $log_path; - var $_threshold = 1; - var $_date_fmt = 'Y-m-d H:i:s'; - var $_enabled = TRUE; - var $_levels = array('ERROR' => '1', 'DEBUG' => '2', 'INFO' => '3', 'ALL' => '4'); + protected $_log_path; + protected $_threshold = 1; + protected $_date_fmt = 'Y-m-d H:i:s'; + protected $_enabled = TRUE; + protected $_levels = array('ERROR' => '1', 'DEBUG' => '2', 'INFO' => '3', 'ALL' => '4'); /** * Constructor - * - * @access public */ - function CI_Log() + public function __construct() { $config =& get_config(); - - $this->log_path = ($config['log_path'] != '') ? $config['log_path'] : BASEPATH.'logs/'; - - if ( ! is_dir($this->log_path) OR ! is_really_writable($this->log_path)) + + $this->_log_path = ($config['log_path'] != '') ? $config['log_path'] : APPPATH.'logs/'; + + if ( ! is_dir($this->_log_path) OR ! is_really_writable($this->_log_path)) { $this->_enabled = FALSE; } - + if (is_numeric($config['log_threshold'])) { $this->_threshold = $config['log_threshold']; } - + if ($config['log_date_format'] != '') { $this->_date_fmt = $config['log_date_format']; } } - + // -------------------------------------------------------------------- - + /** * Write Log File * * Generally this function will be called using the global log_message() function * - * @access public * @param string the error level * @param string the error message * @param bool whether the error is a native PHP error * @return bool - */ - function write_log($level = 'error', $msg, $php_error = FALSE) - { + */ + public function write_log($level = 'error', $msg, $php_error = FALSE) + { if ($this->_enabled === FALSE) { return FALSE; } - + $level = strtoupper($level); - + if ( ! isset($this->_levels[$level]) OR ($this->_levels[$level] > $this->_threshold)) { return FALSE; } - - $filepath = $this->log_path.'log-'.date('Y-m-d').EXT; + + $filepath = $this->_log_path.'log-'.date('Y-m-d').EXT; $message = ''; - + if ( ! file_exists($filepath)) { $message .= "<"."?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?".">\n\n"; } - + if ( ! $fp = @fopen($filepath, FOPEN_WRITE_CREATE)) { return FALSE; } $message .= $level.' '.(($level == 'INFO') ? ' -' : '-').' '.date($this->_date_fmt). ' --> '.$msg."\n"; - - flock($fp, LOCK_EX); + + flock($fp, LOCK_EX); fwrite($fp, $message); flock($fp, LOCK_UN); fclose($fp); - - @chmod($filepath, FILE_WRITE_MODE); + + @chmod($filepath, FILE_WRITE_MODE); return TRUE; } diff --git a/system/libraries/Model.php b/system/libraries/Model.php deleted file mode 100644 index e9c2d24d1..000000000 --- a/system/libraries/Model.php +++ /dev/null @@ -1,83 +0,0 @@ -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); -/** - * CodeIgniter - * - * An open source application development framework for PHP 4.3.2 or newer - * - * @package CodeIgniter - * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. - * @license http://codeigniter.com/user_guide/license.html - * @link http://codeigniter.com - * @since Version 1.0 - * @filesource - */ - -// ------------------------------------------------------------------------ - -/** - * CodeIgniter Model Class - * - * @package CodeIgniter - * @subpackage Libraries - * @category Libraries - * @author ExpressionEngine Dev Team - * @link http://codeigniter.com/user_guide/libraries/config.html - */ -class Model { - - var $_parent_name = ''; - - /** - * Constructor - * - * @access public - */ - function Model() - { - // If the magic __get() or __set() methods are used in a Model references can't be used. - $this->_assign_libraries( (method_exists($this, '__get') OR method_exists($this, '__set')) ? FALSE : TRUE ); - - // We don't want to assign the model object to itself when using the - // assign_libraries function below so we'll grab the name of the model parent - $this->_parent_name = ucfirst(get_class($this)); - - log_message('debug', "Model Class Initialized"); - } - - /** - * Assign Libraries - * - * Creates local references to all currently instantiated objects - * so that any syntax that can be legally used in a controller - * can be used within models. - * - * @access private - */ - function _assign_libraries($use_reference = TRUE) - { - $CI =& get_instance(); - foreach (array_keys(get_object_vars($CI)) as $key) - { - if ( ! isset($this->$key) AND $key != $this->_parent_name) - { - // In some cases using references can cause - // problems so we'll conditionally use them - if ($use_reference == TRUE) - { - $this->$key = NULL; // Needed to prevent reference errors with some configurations - $this->$key =& $CI->$key; - } - else - { - $this->$key = $CI->$key; - } - } - } - } - -} -// END Model Class - -/* End of file Model.php */ -/* Location: ./system/libraries/Model.php */
\ No newline at end of file diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index d6321f41c..1113f862f 100644..100755 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -27,11 +27,14 @@ class CI_Pagination { var $base_url = ''; // The page we are linking to - var $total_rows = ''; // Total number of items (database results) - var $per_page = 10; // Max number of items you want shown per page + var $prefix = ''; // A custom prefix added to the path. + var $suffix = ''; // A custom suffix added to the path. + + var $total_rows = ''; // Total number of items (database results) + var $per_page = 10; // Max number of items you want shown per page var $num_links = 2; // Number of "digit" links to show before/after the currently viewed page - var $cur_page = 0; // The current page being viewed - var $first_link = '‹ First'; + var $cur_page = 0; // The current page being viewed + var $first_link = '‹ First'; var $next_link = '>'; var $prev_link = '<'; var $last_link = 'Last ›'; @@ -42,6 +45,7 @@ class CI_Pagination { var $first_tag_close = ' '; var $last_tag_open = ' '; var $last_tag_close = ''; + var $first_url = ''; // Alternative URL for the First Page. var $cur_tag_open = ' <strong>'; var $cur_tag_close = '</strong>'; var $next_tag_open = ' '; @@ -52,6 +56,8 @@ class CI_Pagination { var $num_tag_close = ''; var $page_query_string = FALSE; var $query_string_segment = 'per_page'; + var $display_pages = TRUE; + var $anchor_class = ''; /** * Constructor @@ -59,13 +65,18 @@ class CI_Pagination { * @access public * @param array initialization parameters */ - function CI_Pagination($params = array()) + public function __construct($params = array()) { if (count($params) > 0) { $this->initialize($params); } + if ($this->anchor_class != '') + { + $this->anchor_class = 'class="'.$this->anchor_class.'" '; + } + log_message('debug', "Pagination Class Initialized"); } @@ -179,53 +190,77 @@ class CI_Pagination { $this->base_url = rtrim($this->base_url, '/') .'/'; } - // And here we go... + // And here we go... $output = ''; // Render the "First" link - if ($this->cur_page > ($this->num_links + 1)) + if ($this->first_link !== FALSE AND $this->cur_page > ($this->num_links + 1)) { - $output .= $this->first_tag_open.'<a href="'.$this->base_url.'">'.$this->first_link.'</a>'.$this->first_tag_close; + $first_url = ($this->first_url == '') ? $this->base_url : $this->first_url; + $output .= $this->first_tag_open.'<a '.$this->anchor_class.'href="'.$first_url.'">'.$this->first_link.'</a>'.$this->first_tag_close; } // Render the "previous" link - if ($this->cur_page != 1) + if ($this->prev_link !== FALSE AND $this->cur_page != 1) { $i = $uri_page_number - $this->per_page; - if ($i == 0) $i = ''; - $output .= $this->prev_tag_open.'<a href="'.$this->base_url.$i.'">'.$this->prev_link.'</a>'.$this->prev_tag_close; + + if ($i == 0 && $this->first_url != '') + { + $output .= $this->prev_tag_open.'<a '.$this->anchor_class.'href="'.$this->first_url.'">'.$this->prev_link.'</a>'.$this->prev_tag_close; + } + else + { + $i = ($i == 0) ? '' : $this->prefix.$i.$this->suffix; + $output .= $this->prev_tag_open.'<a '.$this->anchor_class.'href="'.$this->base_url.$i.'">'.$this->prev_link.'</a>'.$this->prev_tag_close; + } + } - // Write the digit links - for ($loop = $start -1; $loop <= $end; $loop++) + // Render the pages + if ($this->display_pages !== FALSE) { - $i = ($loop * $this->per_page) - $this->per_page; - - if ($i >= 0) + // Write the digit links + for ($loop = $start -1; $loop <= $end; $loop++) { - if ($this->cur_page == $loop) - { - $output .= $this->cur_tag_open.$loop.$this->cur_tag_close; // Current page - } - else + $i = ($loop * $this->per_page) - $this->per_page; + + if ($i >= 0) { - $n = ($i == 0) ? '' : $i; - $output .= $this->num_tag_open.'<a href="'.$this->base_url.$n.'">'.$loop.'</a>'.$this->num_tag_close; + if ($this->cur_page == $loop) + { + $output .= $this->cur_tag_open.$loop.$this->cur_tag_close; // Current page + } + else + { + $n = ($i == 0) ? '' : $i; + + if ($n == '' && $this->first_url != '') + { + $output .= $this->num_tag_open.'<a '.$this->anchor_class.'href="'.$this->first_url.'">'.$loop.'</a>'.$this->num_tag_close; + } + else + { + $n = ($n == '') ? '' : $this->prefix.$n.$this->suffix; + + $output .= $this->num_tag_open.'<a '.$this->anchor_class.'href="'.$this->base_url.$n.'">'.$loop.'</a>'.$this->num_tag_close; + } + } } } } // Render the "next" link - if ($this->cur_page < $num_pages) + if ($this->next_link !== FALSE AND $this->cur_page < $num_pages) { - $output .= $this->next_tag_open.'<a href="'.$this->base_url.($this->cur_page * $this->per_page).'">'.$this->next_link.'</a>'.$this->next_tag_close; + $output .= $this->next_tag_open.'<a '.$this->anchor_class.'href="'.$this->base_url.$this->prefix.($this->cur_page * $this->per_page).$this->suffix.'">'.$this->next_link.'</a>'.$this->next_tag_close; } // Render the "Last" link - if (($this->cur_page + $this->num_links) < $num_pages) + if ($this->last_link !== FALSE AND ($this->cur_page + $this->num_links) < $num_pages) { $i = (($num_pages * $this->per_page) - $this->per_page); - $output .= $this->last_tag_open.'<a href="'.$this->base_url.$i.'">'.$this->last_link.'</a>'.$this->last_tag_close; + $output .= $this->last_tag_open.'<a '.$this->anchor_class.'href="'.$this->base_url.$this->prefix.$i.$this->suffix.'">'.$this->last_link.'</a>'.$this->last_tag_close; } // Kill double slashes. Note: Sometimes we can end up with a double slash diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php index 399b14b2d..d223da020 100644..100755 --- a/system/libraries/Parser.php +++ b/system/libraries/Parser.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -29,11 +29,11 @@ class CI_Parser { var $l_delim = '{'; var $r_delim = '}'; var $object; - + /** * Parse a template * - * Parses pseudo-variables contained in the specified template, + * Parses pseudo-variables contained in the specified template view, * replacing them with the data in the second param * * @access public @@ -42,38 +42,77 @@ class CI_Parser { * @param bool * @return string */ - function parse($template, $data, $return = FALSE) + public function parse($template, $data, $return = FALSE) { $CI =& get_instance(); $template = $CI->load->view($template, $data, TRUE); - + + return $this->_parse($template, $data, $return); + } + + // -------------------------------------------------------------------- + + /** + * Parse a String + * + * Parses pseudo-variables contained in the specified string, + * replacing them with the data in the second param + * + * @access public + * @param string + * @param array + * @param bool + * @return string + */ + function parse_string($template, $data, $return = FALSE) + { + return $this->_parse($template, $data, $return); + } + + // -------------------------------------------------------------------- + + /** + * Parse a template + * + * Parses pseudo-variables contained in the specified template, + * replacing them with the data in the second param + * + * @access public + * @param string + * @param array + * @param bool + * @return string + */ + function _parse($template, $data, $return = FALSE) + { if ($template == '') { return FALSE; } - + foreach ($data as $key => $val) { if (is_array($val)) { - $template = $this->_parse_pair($key, $val, $template); + $template = $this->_parse_pair($key, $val, $template); } else { $template = $this->_parse_single($key, (string)$val, $template); } } - + if ($return == FALSE) { + $CI =& get_instance(); $CI->output->append_output($template); } - + return $template; } - + // -------------------------------------------------------------------- - + /** * Set the left/right variable delimiters * @@ -87,9 +126,9 @@ class CI_Parser { $this->l_delim = $l; $this->r_delim = $r; } - + // -------------------------------------------------------------------- - + /** * Parse a single key/value * @@ -103,9 +142,9 @@ class CI_Parser { { return str_replace($this->l_delim.$key.$this->r_delim, $val, $string); } - + // -------------------------------------------------------------------- - + /** * Parse a tag pair * @@ -118,7 +157,7 @@ class CI_Parser { * @return string */ function _parse_pair($variable, $data, $string) - { + { if (FALSE === ($match = $this->_match_pair($string, $variable))) { return $string; @@ -139,15 +178,15 @@ class CI_Parser { $temp = $this->_parse_pair($key, $val, $temp); } } - + $str .= $temp; } - + return str_replace($match['0'], $str, $string); } - + // -------------------------------------------------------------------- - + /** * Matches a variable pair * @@ -158,11 +197,11 @@ class CI_Parser { */ function _match_pair($string, $variable) { - if ( ! preg_match("|".$this->l_delim . $variable . $this->r_delim."(.+?)".$this->l_delim . '/' . $variable . $this->r_delim."|s", $string, $match)) + if ( ! preg_match("|" . preg_quote($this->l_delim) . $variable . preg_quote($this->r_delim) . "(.+?)". preg_quote($this->l_delim) . '/' . $variable . preg_quote($this->r_delim) . "|s", $string, $match)) { return FALSE; } - + return $match; } @@ -170,4 +209,4 @@ class CI_Parser { // END Parser Class /* End of file Parser.php */ -/* Location: ./system/libraries/Parser.php */
\ No newline at end of file +/* Location: ./system/libraries/Parser.php */ diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php index 84f7871b5..6587eae0b 100644..100755 --- a/system/libraries/Profiler.php +++ b/system/libraries/Profiler.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -33,13 +33,57 @@ class CI_Profiler { var $CI; - - function CI_Profiler() - { - $this->CI =& get_instance(); - $this->CI->load->language('profiler'); - } - + + protected $_available_sections = array( + 'benchmarks', + 'get', + 'memory_usage', + 'post', + 'uri_string', + 'controller_info', + 'queries', + 'http_headers', + 'config' + ); + + public function __construct($config = array()) + { + $this->CI =& get_instance(); + $this->CI->load->language('profiler'); + + // default all sections to display + foreach ($this->_available_sections as $section) + { + if ( ! isset($config[$section])) + { + $this->_compile_{$section} = TRUE; + } + } + + $this->set_sections($config); + } + + // -------------------------------------------------------------------- + + /** + * Set Sections + * + * Sets the private _compile_* properties to enable/disable Profiler sections + * + * @param mixed + * @return void + */ + public function set_sections($config) + { + foreach ($config as $method => $enable) + { + if (in_array($method, $this->_available_sections)) + { + $this->_compile_{$method} = ($enable !== FALSE) ? TRUE : FALSE; + } + } + } + // -------------------------------------------------------------------- /** @@ -50,57 +94,55 @@ class CI_Profiler { * and "_end" respectively). It then compiles the execution times for * all points and returns it as an array * - * @access private * @return array */ - function _compile_benchmarks() - { - $profile = array(); - foreach ($this->CI->benchmark->marker as $key => $val) - { - // We match the "end" marker so that the list ends - // up in the order that it was defined - if (preg_match("/(.+?)_end/i", $key, $match)) - { - if (isset($this->CI->benchmark->marker[$match[1].'_end']) AND isset($this->CI->benchmark->marker[$match[1].'_start'])) - { - $profile[$match[1]] = $this->CI->benchmark->elapsed_time($match[1].'_start', $key); - } - } - } + protected function _compile_benchmarks() + { + $profile = array(); + foreach ($this->CI->benchmark->marker as $key => $val) + { + // We match the "end" marker so that the list ends + // up in the order that it was defined + if (preg_match("/(.+?)_end/i", $key, $match)) + { + if (isset($this->CI->benchmark->marker[$match[1].'_end']) AND isset($this->CI->benchmark->marker[$match[1].'_start'])) + { + $profile[$match[1]] = $this->CI->benchmark->elapsed_time($match[1].'_start', $key); + } + } + } // Build a table containing the profile data. // Note: At some point we should turn this into a template that can // be modified. We also might want to make this data available to be logged - + $output = "\n\n"; - $output .= '<fieldset style="border:1px solid #990000;padding:6px 10px 10px 10px;margin:0 0 20px 0;background-color:#eee">'; + $output .= '<fieldset id="ci_profiler_benchmarks" style="border:1px solid #900;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; + $output .= "\n"; + $output .= '<legend style="color:#900;"> '.$this->CI->lang->line('profiler_benchmarks').' </legend>'; $output .= "\n"; - $output .= '<legend style="color:#990000;"> '.$this->CI->lang->line('profiler_benchmarks').' </legend>'; - $output .= "\n"; - $output .= "\n\n<table cellpadding='4' cellspacing='1' border='0' width='100%'>\n"; - + $output .= "\n\n<table style='width:100%'>\n"; + foreach ($profile as $key => $val) { $key = ucwords(str_replace(array('_', '-'), ' ', $key)); - $output .= "<tr><td width='50%' style='color:#000;font-weight:bold;background-color:#ddd;'>".$key." </td><td width='50%' style='color:#990000;font-weight:normal;background-color:#ddd;'>".$val."</td></tr>\n"; + $output .= "<tr><td style='padding:5px;width:50%;color:#000;font-weight:bold;background-color:#ddd;'>".$key." </td><td style='padding:5px;width:50%;color:#900;font-weight:normal;background-color:#ddd;'>".$val."</td></tr>\n"; } - + $output .= "</table>\n"; $output .= "</fieldset>"; - - return $output; - } - + + return $output; + } + // -------------------------------------------------------------------- /** * Compile Queries * - * @access private * @return string - */ - function _compile_queries() + */ + protected function _compile_queries() { $dbs = array(); @@ -112,100 +154,99 @@ class CI_Profiler { $dbs[] = $CI_object; } } - + if (count($dbs) == 0) { $output = "\n\n"; - $output .= '<fieldset style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; + $output .= '<fieldset id="ci_profiler_queries" style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; $output .= "\n"; $output .= '<legend style="color:#0000FF;"> '.$this->CI->lang->line('profiler_queries').' </legend>'; - $output .= "\n"; - $output .= "\n\n<table cellpadding='4' cellspacing='1' border='0' width='100%'>\n"; - $output .="<tr><td width='100%' style='color:#0000FF;font-weight:normal;background-color:#eee;'>".$this->CI->lang->line('profiler_no_db')."</td></tr>\n"; + $output .= "\n"; + $output .= "\n\n<table style='border:none; width:100%'>\n"; + $output .="<tr><td style='width:100%;color:#0000FF;font-weight:normal;background-color:#eee;padding:5px'>".$this->CI->lang->line('profiler_no_db')."</td></tr>\n"; $output .= "</table>\n"; $output .= "</fieldset>"; - + return $output; } - + // Load the text helper so we can highlight the SQL $this->CI->load->helper('text'); // Key words we want bolded - $highlight = array('SELECT', 'DISTINCT', 'FROM', 'WHERE', 'AND', 'LEFT JOIN', 'ORDER BY', 'GROUP BY', 'LIMIT', 'INSERT', 'INTO', 'VALUES', 'UPDATE', 'OR', 'HAVING', 'OFFSET', 'NOT IN', 'IN', 'LIKE', 'NOT LIKE', 'COUNT', 'MAX', 'MIN', 'ON', 'AS', 'AVG', 'SUM', '(', ')'); + $highlight = array('SELECT', 'DISTINCT', 'FROM', 'WHERE', 'AND', 'LEFT JOIN', 'ORDER BY', 'GROUP BY', 'LIMIT', 'INSERT', 'INTO', 'VALUES', 'UPDATE', 'OR ', 'HAVING', 'OFFSET', 'NOT IN', 'IN', 'LIKE', 'NOT LIKE', 'COUNT', 'MAX', 'MIN', 'ON', 'AS', 'AVG', 'SUM', '(', ')'); $output = "\n\n"; - + foreach ($dbs as $db) { $output .= '<fieldset style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; $output .= "\n"; - $output .= '<legend style="color:#0000FF;"> '.$this->CI->lang->line('profiler_database').': '.$db->database.' '.$this->CI->lang->line('profiler_queries').': '.count($this->CI->db->queries).' </legend>'; - $output .= "\n"; - $output .= "\n\n<table cellpadding='4' cellspacing='1' border='0' width='100%'>\n"; - + $output .= '<legend style="color:#0000FF;"> '.$this->CI->lang->line('profiler_database').': '.$db->database.' '.$this->CI->lang->line('profiler_queries').': '.count($db->queries).' </legend>'; + $output .= "\n"; + $output .= "\n\n<table style='width:100%;'>\n"; + if (count($db->queries) == 0) { - $output .= "<tr><td width='100%' style='color:#0000FF;font-weight:normal;background-color:#eee;'>".$this->CI->lang->line('profiler_no_queries')."</td></tr>\n"; + $output .= "<tr><td style='width:100%;color:#0000FF;font-weight:normal;background-color:#eee;padding:5px;'>".$this->CI->lang->line('profiler_no_queries')."</td></tr>\n"; } else - { + { foreach ($db->queries as $key => $val) - { + { $time = number_format($db->query_times[$key], 4); $val = highlight_code($val, ENT_QUOTES); - + foreach ($highlight as $bold) { - $val = str_replace($bold, '<strong>'.$bold.'</strong>', $val); + $val = str_replace($bold, '<strong>'.$bold.'</strong>', $val); } - - $output .= "<tr><td width='1%' valign='top' style='color:#990000;font-weight:normal;background-color:#ddd;'>".$time." </td><td style='color:#000;font-weight:normal;background-color:#ddd;'>".$val."</td></tr>\n"; + + $output .= "<tr><td style='padding:5px; vertical-align: top;width:1%;color:#900;font-weight:normal;background-color:#ddd;'>".$time." </td><td style='padding:5px; color:#000;font-weight:normal;background-color:#ddd;'>".$val."</td></tr>\n"; } } - + $output .= "</table>\n"; $output .= "</fieldset>"; - + } - + return $output; } - + // -------------------------------------------------------------------- /** * Compile $_GET Data * - * @access private * @return string - */ - function _compile_get() - { + */ + protected function _compile_get() + { $output = "\n\n"; - $output .= '<fieldset style="border:1px solid #cd6e00;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; + $output .= '<fieldset id="ci_profiler_get" style="border:1px solid #cd6e00;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; $output .= "\n"; $output .= '<legend style="color:#cd6e00;"> '.$this->CI->lang->line('profiler_get_data').' </legend>'; $output .= "\n"; - + if (count($_GET) == 0) { $output .= "<div style='color:#cd6e00;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_get')."</div>"; } else { - $output .= "\n\n<table cellpadding='4' cellspacing='1' border='0' width='100%'>\n"; - + $output .= "\n\n<table style='width:100%; border:none'>\n"; + foreach ($_GET as $key => $val) { if ( ! is_numeric($key)) { $key = "'".$key."'"; } - - $output .= "<tr><td width='50%' style='color:#000;background-color:#ddd;'>$_GET[".$key."] </td><td width='50%' style='color:#cd6e00;font-weight:normal;background-color:#ddd;'>"; + + $output .= "<tr><td style='width:50%;color:#000;background-color:#ddd;padding:5px'>$_GET[".$key."] </td><td style='width:50%;padding:5px;color:#cd6e00;font-weight:normal;background-color:#ddd;'>"; if (is_array($val)) { $output .= "<pre>" . htmlspecialchars(stripslashes(print_r($val, true))) . "</pre>"; @@ -216,49 +257,48 @@ class CI_Profiler { } $output .= "</td></tr>\n"; } - + $output .= "</table>\n"; } $output .= "</fieldset>"; - return $output; + return $output; } - + // -------------------------------------------------------------------- - + /** * Compile $_POST Data * - * @access private * @return string - */ - function _compile_post() - { + */ + protected function _compile_post() + { $output = "\n\n"; - $output .= '<fieldset style="border:1px solid #009900;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; + $output .= '<fieldset id="ci_profiler_post" style="border:1px solid #009900;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; $output .= "\n"; $output .= '<legend style="color:#009900;"> '.$this->CI->lang->line('profiler_post_data').' </legend>'; $output .= "\n"; - + if (count($_POST) == 0) { $output .= "<div style='color:#009900;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_post')."</div>"; } else { - $output .= "\n\n<table cellpadding='4' cellspacing='1' border='0' width='100%'>\n"; - + $output .= "\n\n<table style='width:100%'>\n"; + foreach ($_POST as $key => $val) { if ( ! is_numeric($key)) { $key = "'".$key."'"; } - - $output .= "<tr><td width='50%' style='color:#000;background-color:#ddd;'>$_POST[".$key."] </td><td width='50%' style='color:#009900;font-weight:normal;background-color:#ddd;'>"; + + $output .= "<tr><td style='width:50%;padding:5px;color:#000;background-color:#ddd;'>$_POST[".$key."] </td><td style='width:50%;padding:5px;color:#009900;font-weight:normal;background-color:#ddd;'>"; if (is_array($val)) { - $output .= "<pre>" . htmlspecialchars(stripslashes(print_r($val, true))) . "</pre>"; + $output .= "<pre>" . htmlspecialchars(stripslashes(print_r($val, TRUE))) . "</pre>"; } else { @@ -266,118 +306,188 @@ class CI_Profiler { } $output .= "</td></tr>\n"; } - + $output .= "</table>\n"; } $output .= "</fieldset>"; - return $output; + return $output; } - + // -------------------------------------------------------------------- - + /** * Show query string * - * @access private * @return string - */ - function _compile_uri_string() - { + */ + protected function _compile_uri_string() + { $output = "\n\n"; - $output .= '<fieldset style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; + $output .= '<fieldset id="ci_profiler_uri_string" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; $output .= "\n"; $output .= '<legend style="color:#000;"> '.$this->CI->lang->line('profiler_uri_string').' </legend>'; $output .= "\n"; - + if ($this->CI->uri->uri_string == '') { $output .= "<div style='color:#000;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_uri')."</div>"; } else { - $output .= "<div style='color:#000;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->uri->uri_string."</div>"; + $output .= "<div style='color:#000;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->uri->uri_string."</div>"; } - + $output .= "</fieldset>"; - return $output; + return $output; } // -------------------------------------------------------------------- - + /** * Show the controller and function that were called * - * @access private * @return string - */ - function _compile_controller_info() - { + */ + protected function _compile_controller_info() + { $output = "\n\n"; - $output .= '<fieldset style="border:1px solid #995300;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; + $output .= '<fieldset id="ci_profiler_controller_info" style="border:1px solid #995300;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; $output .= "\n"; $output .= '<legend style="color:#995300;"> '.$this->CI->lang->line('profiler_controller_info').' </legend>'; $output .= "\n"; - - $output .= "<div style='color:#995300;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->router->fetch_class()."/".$this->CI->router->fetch_method()."</div>"; - + $output .= "<div style='color:#995300;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->router->fetch_class()."/".$this->CI->router->fetch_method()."</div>"; + $output .= "</fieldset>"; - return $output; + return $output; } + // -------------------------------------------------------------------- - + /** * Compile memory usage * * Display total used memory * - * @access public * @return string */ - function _compile_memory_usage() + protected function _compile_memory_usage() { $output = "\n\n"; - $output .= '<fieldset style="border:1px solid #5a0099;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; + $output .= '<fieldset id="ci_profiler_memory_usage" style="border:1px solid #5a0099;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; $output .= "\n"; $output .= '<legend style="color:#5a0099;"> '.$this->CI->lang->line('profiler_memory_usage').' </legend>'; $output .= "\n"; - + if (function_exists('memory_get_usage') && ($usage = memory_get_usage()) != '') { $output .= "<div style='color:#5a0099;font-weight:normal;padding:4px 0 4px 0'>".number_format($usage).' bytes</div>'; } else { - $output .= "<div style='color:#5a0099;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_memory_usage')."</div>"; + $output .= "<div style='color:#5a0099;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_memory_usage')."</div>"; + } + + $output .= "</fieldset>"; + + return $output; + } + + // -------------------------------------------------------------------- + + /** + * Compile header information + * + * Lists HTTP headers + * + * @return string + */ + protected function _compile_http_headers() + { + $output = "\n\n"; + $output .= '<fieldset id="ci_profiler_http_headers" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; + $output .= "\n"; + $output .= '<legend style="color:#000;"> '.$this->CI->lang->line('profiler_headers').' </legend>'; + $output .= "\n"; + + $output .= "\n\n<table style='width:100%'>\n"; + + foreach(array('HTTP_ACCEPT', 'HTTP_USER_AGENT', 'HTTP_CONNECTION', 'SERVER_PORT', 'SERVER_NAME', 'REMOTE_ADDR', 'SERVER_SOFTWARE', 'HTTP_ACCEPT_LANGUAGE', 'SCRIPT_NAME', 'REQUEST_METHOD',' HTTP_HOST', 'REMOTE_HOST', 'CONTENT_TYPE', 'SERVER_PROTOCOL', 'QUERY_STRING', 'HTTP_ACCEPT_ENCODING', 'HTTP_X_FORWARDED_FOR') as $header) + { + $val = (isset($_SERVER[$header])) ? $_SERVER[$header] : ''; + $output .= "<tr><td style='vertical-align: top;width:50%;padding:5px;color:#900;background-color:#ddd;'>".$header." </td><td style='width:50%;padding:5px;color:#000;background-color:#ddd;'>".$val."</td></tr>\n"; } - + + $output .= "</table>\n"; + $output .= "</fieldset>"; + + return $output; + } + + // -------------------------------------------------------------------- + + /** + * Compile config information + * + * Lists developer config variables + * + * @return string + */ + protected function _compile_config() + { + $output = "\n\n"; + $output .= '<fieldset id="ci_profiler_config" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; + $output .= "\n"; + $output .= '<legend style="color:#000;"> '.$this->CI->lang->line('profiler_config').' </legend>'; + $output .= "\n"; + + $output .= "\n\n<table style='width:100%'>\n"; + + foreach($this->CI->config->config as $config=>$val) + { + if (is_array($val)) + { + $val = print_r($val, TRUE); + } + + $output .= "<tr><td style='padding:5px; vertical-align: top;color:#900;background-color:#ddd;'>".$config." </td><td style='padding:5px; color:#000;background-color:#ddd;'>".htmlspecialchars($val)."</td></tr>\n"; + } + + $output .= "</table>\n"; $output .= "</fieldset>"; return $output; } // -------------------------------------------------------------------- - + /** * Run the Profiler * - * @access private * @return string - */ - function run() + */ + public function run() { $output = "<div id='codeigniter_profiler' style='clear:both;background-color:#fff;padding:10px;'>"; + $fields_displayed = 0; - $output .= $this->_compile_uri_string(); - $output .= $this->_compile_controller_info(); - $output .= $this->_compile_memory_usage(); - $output .= $this->_compile_benchmarks(); - $output .= $this->_compile_get(); - $output .= $this->_compile_post(); - $output .= $this->_compile_queries(); + foreach ($this->_available_sections as $section) + { + if ($this->_compile_{$section} !== FALSE) + { + $func = "_compile_{$section}"; + $output .= $this->{$func}(); + $fields_displayed++; + } + } + + if ($fields_displayed == 0) + { + $output .= '<p style="border:1px solid #5a0099;padding:10px;margin:20px 0;background-color:#eee">'.$this->CI->lang->line('profiler_no_profiles').'</p>'; + } $output .= '</div>'; diff --git a/system/libraries/Security.php b/system/libraries/Security.php new file mode 100755 index 000000000..ba64c7326 --- /dev/null +++ b/system/libraries/Security.php @@ -0,0 +1,737 @@ +<?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 + */ + +// ------------------------------------------------------------------------ + +/** + * Security Class + * + * @package CodeIgniter + * @subpackage Libraries + * @category Security + * @author ExpressionEngine Dev Team + * @link http://codeigniter.com/user_guide/libraries/sessions.html + */ +class CI_Security { + + public $xss_hash = ''; + public $csrf_hash = ''; + public $csrf_expire = 7200; // Two hours (in seconds) + public $csrf_token_name = 'ci_csrf_token'; + public $csrf_cookie_name = 'ci_csrf_token'; + + /* never allowed, string replacement */ + public $never_allowed_str = array( + 'document.cookie' => '[removed]', + 'document.write' => '[removed]', + '.parentNode' => '[removed]', + '.innerHTML' => '[removed]', + 'window.location' => '[removed]', + '-moz-binding' => '[removed]', + '<!--' => '<!--', + '-->' => '-->', + '<![CDATA[' => '<![CDATA[' + ); + /* never allowed, regex replacement */ + public $never_allowed_regex = array( + "javascript\s*:" => '[removed]', + "expression\s*(\(|&\#40;)" => '[removed]', // CSS and IE + "vbscript\s*:" => '[removed]', // IE, surprise! + "Redirect\s+302" => '[removed]' + ); + + public function __construct() + { + $this->csrf_token_name = (config_item('csrf_token_name')) ? config_item('csrf_token_name') : 'csrf_token_name'; + $this->csrf_cookie_name = (config_item('csrf_cookie_name')) ? config_item('csrf_cookie_name') : 'csrf_cookie_name'; + $this->csrf_expire = (config_item('csrf_expire')) ? config_item('csrf_expire') : 7200; + + // Append application specific cookie prefix to token name + $this->csrf_cookie_name = (config_item('cookie_prefix')) ? config_item('cookie_prefix').$this->csrf_token_name : $this->csrf_token_name; + + // Set the CSRF hash + $this->_csrf_set_hash(); + + log_message('debug', "Security Class Initialized"); + } + + // -------------------------------------------------------------------- + + /** + * Verify Cross Site Request Forgery Protection + * + * @access public + * @return null + */ + public function csrf_verify() + { + // If no POST data exists we will set the CSRF cookie + if (count($_POST) == 0) + { + return $this->csrf_set_cookie(); + } + + // Do the tokens exist in both the _POST and _COOKIE arrays? + if ( ! isset($_POST[$this->csrf_token_name]) OR ! isset($_COOKIE[$this->csrf_cookie_name])) + { + $this->csrf_show_error(); + } + + // Do the tokens match? + if ($_POST[$this->csrf_token_name] != $_COOKIE[$this->csrf_cookie_name]) + { + $this->csrf_show_error(); + } + + // We kill this since we're done and we don't want to polute the _POST array + unset($_POST[$this->csrf_token_name]); + + // Nothing should last forever + unset($_COOKIE[$this->csrf_cookie_name]); + $this->_csrf_set_hash(); + $this->csrf_set_cookie(); + + log_message('debug', "CSRF token verified "); + } + + // -------------------------------------------------------------------- + + /** + * Set Cross Site Request Forgery Protection Cookie + * + * @access public + * @return null + */ + public function csrf_set_cookie() + { + $expire = time() + $this->csrf_expire; + + setcookie($this->csrf_cookie_name, $this->csrf_hash, $expire, config_item('cookie_path'), config_item('cookie_domain'), 0); + + log_message('debug', "CRSF cookie Set"); + } + + // -------------------------------------------------------------------- + + /** + * Set Cross Site Request Forgery Protection Cookie + * + * @access private + * @return null + */ + private function _csrf_set_hash() + { + if ($this->csrf_hash == '') + { + // If the cookie exists we will use it's value. We don't necessarily want to regenerate it with + // each page load since a page could contain embedded sub-pages causing this feature to fail + if (isset($_COOKIE[$this->csrf_cookie_name]) AND $_COOKIE[$this->csrf_cookie_name] != '') + { + $this->csrf_hash = $_COOKIE[$this->csrf_cookie_name]; + } + else + { + $this->csrf_hash = md5(uniqid(rand(), TRUE)); + } + } + + return $this->csrf_hash; + } + + // -------------------------------------------------------------------- + + /** + * Show CSRF Error + * + * @access public + * @return null + */ + public function csrf_show_error() + { + show_error('The action you have requested is not allowed.'); + } + + // -------------------------------------------------------------------- + + /** + * XSS Clean + * + * Sanitizes data so that Cross Site Scripting Hacks can be + * prevented. This function does a fair amount of work but + * it is extremely thorough, designed to prevent even the + * most obscure XSS attempts. Nothing is ever 100% foolproof, + * of course, but I haven't been able to get anything passed + * the filter. + * + * Note: This function should only be used to deal with data + * upon submission. It's not something that should + * be used for general runtime processing. + * + * This function was based in part on some code and ideas I + * got from Bitflux: http://channel.bitflux.ch/wiki/XSS_Prevention + * + * To help develop this script I used this great list of + * vulnerabilities along with a few other hacks I've + * harvested from examining vulnerabilities in other programs: + * http://ha.ckers.org/xss.html + * + * @access public + * @param mixed string or array + * @return string + */ + public function xss_clean($str, $is_image = FALSE) + { + /* + * Is the string an array? + * + */ + if (is_array($str)) + { + while (list($key) = each($str)) + { + $str[$key] = $this->xss_clean($str[$key]); + } + + return $str; + } + + /* + * Remove Invisible Characters + */ + $str = remove_invisible_characters($str); + + /* + * Protect GET variables in URLs + */ + + // 901119URL5918AMP18930PROTECT8198 + + $str = preg_replace('|\&([a-z\_0-9\-]+)\=([a-z\_0-9\-]+)|i', $this->xss_hash()."\\1=\\2", $str); + + /* + * Validate standard character entities + * + * Add a semicolon if missing. We do this to enable + * the conversion of entities to ASCII later. + * + */ + $str = preg_replace('#(&\#?[0-9a-z]{2,})([\x00-\x20])*;?#i', "\\1;\\2", $str); + + /* + * Validate UTF16 two byte encoding (x00) + * + * Just as above, adds a semicolon if missing. + * + */ + $str = preg_replace('#(&\#x?)([0-9A-F]+);?#i',"\\1\\2;",$str); + + /* + * Un-Protect GET variables in URLs + */ + $str = str_replace($this->xss_hash(), '&', $str); + + /* + * URL Decode + * + * Just in case stuff like this is submitted: + * + * <a href="http://%77%77%77%2E%67%6F%6F%67%6C%65%2E%63%6F%6D">Google</a> + * + * Note: Use rawurldecode() so it does not remove plus signs + * + */ + $str = rawurldecode($str); + + /* + * Convert character entities to ASCII + * + * This permits our tests below to work reliably. + * We only convert entities that are within tags since + * these are the ones that will pose security problems. + * + */ + + $str = preg_replace_callback("/[a-z]+=([\'\"]).*?\\1/si", array($this, '_convert_attribute'), $str); + + $str = preg_replace_callback("/<\w+.*?(?=>|<|$)/si", array($this, '_decode_entity'), $str); + + /* + * Remove Invisible Characters Again! + */ + $str = remove_invisible_characters($str); + + /* + * Convert all tabs to spaces + * + * This prevents strings like this: ja vascript + * NOTE: we deal with spaces between characters later. + * NOTE: preg_replace was found to be amazingly slow here on large blocks of data, + * so we use str_replace. + * + */ + + if (strpos($str, "\t") !== FALSE) + { + $str = str_replace("\t", ' ', $str); + } + + /* + * Capture converted string for later comparison + */ + $converted_string = $str; + + /* + * Not Allowed Under Any Conditions + */ + + foreach ($this->never_allowed_str as $key => $val) + { + $str = str_replace($key, $val, $str); + } + + foreach ($this->never_allowed_regex as $key => $val) + { + $str = preg_replace("#".$key."#i", $val, $str); + } + + /* + * Makes PHP tags safe + * + * Note: XML tags are inadvertently replaced too: + * + * <?xml + * + * But it doesn't seem to pose a problem. + * + */ + if ($is_image === TRUE) + { + // Images have a tendency to have the PHP short opening and closing tags every so often + // so we skip those and only do the long opening tags. + $str = preg_replace('/<\?(php)/i', "<?\\1", $str); + } + else + { + $str = str_replace(array('<?', '?'.'>'), array('<?', '?>'), $str); + } + + /* + * Compact any exploded words + * + * This corrects words like: j a v a s c r i p t + * These words are compacted back to their correct state. + * + */ + $words = array('javascript', 'expression', 'vbscript', 'script', 'applet', 'alert', 'document', 'write', 'cookie', 'window'); + foreach ($words as $word) + { + $temp = ''; + + for ($i = 0, $wordlen = strlen($word); $i < $wordlen; $i++) + { + $temp .= substr($word, $i, 1)."\s*"; + } + + // We only want to do this when it is followed by a non-word character + // That way valid stuff like "dealer to" does not become "dealerto" + $str = preg_replace_callback('#('.substr($temp, 0, -3).')(\W)#is', array($this, '_compact_exploded_words'), $str); + } + + /* + * Remove disallowed Javascript in links or img tags + * We used to do some version comparisons and use of stripos for PHP5, but it is dog slow compared + * to these simplified non-capturing preg_match(), especially if the pattern exists in the string + */ + do + { + $original = $str; + + if (preg_match("/<a/i", $str)) + { + $str = preg_replace_callback("#<a\s+([^>]*?)(>|$)#si", array($this, '_js_link_removal'), $str); + } + + if (preg_match("/<img/i", $str)) + { + $str = preg_replace_callback("#<img\s+([^>]*?)(\s?/?>|$)#si", array($this, '_js_img_removal'), $str); + } + + if (preg_match("/script/i", $str) OR preg_match("/xss/i", $str)) + { + $str = preg_replace("#<(/*)(script|xss)(.*?)\>#si", '[removed]', $str); + } + } + while($original != $str); + + unset($original); + + /* + * Remove JavaScript Event Handlers + * + * Note: This code is a little blunt. It removes + * the event handler and anything up to the closing >, + * but it's unlikely to be a problem. + * + */ + $event_handlers = array('[^a-z_\-]on\w*','xmlns'); + + if ($is_image === TRUE) + { + /* + * Adobe Photoshop puts XML metadata into JFIF images, including namespacing, + * so we have to allow this for images. -Paul + */ + unset($event_handlers[array_search('xmlns', $event_handlers)]); + } + + $str = preg_replace("#<([^><]+?)(".implode('|', $event_handlers).")(\s*=\s*[^><]*)([><]*)#i", "<\\1\\4", $str); + + /* + * Sanitize naughty HTML elements + * + * If a tag containing any of the words in the list + * below is found, the tag gets converted to entities. + * + * So this: <blink> + * Becomes: <blink> + * + */ + $naughty = 'alert|applet|audio|basefont|base|behavior|bgsound|blink|body|embed|expression|form|frameset|frame|head|html|ilayer|iframe|input|isindex|layer|link|meta|object|plaintext|style|script|textarea|title|video|xml|xss'; + $str = preg_replace_callback('#<(/*\s*)('.$naughty.')([^><]*)([><]*)#is', array($this, '_sanitize_naughty_html'), $str); + + /* + * Sanitize naughty scripting elements + * + * Similar to above, only instead of looking for + * tags it looks for PHP and JavaScript commands + * that are disallowed. Rather than removing the + * code, it simply converts the parenthesis to entities + * rendering the code un-executable. + * + * For example: eval('some code') + * Becomes: eval('some code') + * + */ + $str = preg_replace('#(alert|cmd|passthru|eval|exec|expression|system|fopen|fsockopen|file|file_get_contents|readfile|unlink)(\s*)\((.*?)\)#si', "\\1\\2(\\3)", $str); + + /* + * Final clean up + * + * This adds a bit of extra precaution in case + * something got through the above filters + * + */ + foreach ($this->never_allowed_str as $key => $val) + { + $str = str_replace($key, $val, $str); + } + + foreach ($this->never_allowed_regex as $key => $val) + { + $str = preg_replace("#".$key."#i", $val, $str); + } + + /* + * Images are Handled in a Special Way + * - Essentially, we want to know that after all of the character conversion is done whether + * any unwanted, likely XSS, code was found. If not, we return TRUE, as the image is clean. + * However, if the string post-conversion does not matched the string post-removal of XSS, + * then it fails, as there was unwanted XSS code found and removed/changed during processing. + */ + + if ($is_image === TRUE) + { + if ($str == $converted_string) + { + return TRUE; + } + else + { + return FALSE; + } + } + + log_message('debug', "XSS Filtering completed"); + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Random Hash for protecting URLs + * + * @access public + * @return string + */ + public function xss_hash() + { + if ($this->xss_hash == '') + { + if (phpversion() >= 4.2) + mt_srand(); + else + mt_srand(hexdec(substr(md5(microtime()), -8)) & 0x7fffffff); + + $this->xss_hash = md5(time() + mt_rand(0, 1999999999)); + } + + return $this->xss_hash; + } + + // -------------------------------------------------------------------- + + /** + * Compact Exploded Words + * + * Callback function for xss_clean() to remove whitespace from + * things like j a v a s c r i p t + * + * @access private + * @param type + * @return type + */ + private function _compact_exploded_words($matches) + { + return preg_replace('/\s+/s', '', $matches[1]).$matches[2]; + } + + // -------------------------------------------------------------------- + + /** + * Sanitize Naughty HTML + * + * Callback function for xss_clean() to remove naughty HTML elements + * + * @access private + * @param array + * @return string + */ + private function _sanitize_naughty_html($matches) + { + // encode opening brace + $str = '<'.$matches[1].$matches[2].$matches[3]; + + // encode captured opening or closing brace to prevent recursive vectors + $str .= str_replace(array('>', '<'), array('>', '<'), $matches[4]); + + return $str; + } + + // -------------------------------------------------------------------- + + /** + * JS Link Removal + * + * Callback function for xss_clean() to sanitize links + * This limits the PCRE backtracks, making it more performance friendly + * and prevents PREG_BACKTRACK_LIMIT_ERROR from being triggered in + * PHP 5.2+ on link-heavy strings + * + * @access private + * @param array + * @return string + */ + private function _js_link_removal($match) + { + $attributes = $this->_filter_attributes(str_replace(array('<', '>'), '', $match[1])); + return str_replace($match[1], preg_replace("#href=.*?(alert\(|alert&\#40;|javascript\:|charset\=|window\.|document\.|\.cookie|<script|<xss|base64\s*,)#si", "", $attributes), $match[0]); + } + + /** + * JS Image Removal + * + * Callback function for xss_clean() to sanitize image tags + * This limits the PCRE backtracks, making it more performance friendly + * and prevents PREG_BACKTRACK_LIMIT_ERROR from being triggered in + * PHP 5.2+ on image tag heavy strings + * + * @access private + * @param array + * @return string + */ + private function _js_img_removal($match) + { + $attributes = $this->_filter_attributes(str_replace(array('<', '>'), '', $match[1])); + return str_replace($match[1], preg_replace("#src=.*?(alert\(|alert&\#40;|javascript\:|charset\=|window\.|document\.|\.cookie|<script|<xss|base64\s*,)#si", "", $attributes), $match[0]); + } + + // -------------------------------------------------------------------- + + /** + * Attribute Conversion + * + * Used as a callback for XSS Clean + * + * @access private + * @param array + * @return string + */ + private function _convert_attribute($match) + { + return str_replace(array('>', '<', '\\'), array('>', '<', '\\\\'), $match[0]); + } + + // -------------------------------------------------------------------- + + /** + * Filter Attributes + * + * Filters tag attributes for consistency and safety + * + * @access private + * @param string + * @return string + */ + private function _filter_attributes($str) + { + $out = ''; + + if (preg_match_all('#\s*[a-z\-]+\s*=\s*(\042|\047)([^\\1]*?)\\1#is', $str, $matches)) + { + foreach ($matches[0] as $match) + { + $out .= preg_replace("#/\*.*?\*/#s", '', $match); + } + } + + return $out; + } + + // -------------------------------------------------------------------- + + /** + * HTML Entity Decode Callback + * + * Used as a callback for XSS Clean + * + * @access private + * @param array + * @return string + */ + private function _decode_entity($match) + { + return $this->entity_decode($match[0], strtoupper(config_item('charset'))); + } + + // -------------------------------------------------------------------- + + /** + * HTML Entities Decode + * + * This function is a replacement for html_entity_decode() + * + * In some versions of PHP the native function does not work + * when UTF-8 is the specified character set, so this gives us + * a work-around. More info here: + * http://bugs.php.net/bug.php?id=25670 + * + * NOTE: html_entity_decode() has a bug in some PHP versions when UTF-8 is the + * character set, and the PHP developers said they were not back porting the + * fix to versions other than PHP 5.x. + * + * @access public + * @param string + * @param string + * @return string + */ + public function entity_decode($str, $charset='UTF-8') + { + if (stristr($str, '&') === FALSE) return $str; + + // The reason we are not using html_entity_decode() by itself is because + // while it is not technically correct to leave out the semicolon + // at the end of an entity most browsers will still interpret the entity + // correctly. html_entity_decode() does not convert entities without + // semicolons, so we are left with our own little solution here. Bummer. + + if (function_exists('html_entity_decode') && (strtolower($charset) != 'utf-8' OR is_php('5.0.0'))) + { + $str = html_entity_decode($str, ENT_COMPAT, $charset); + $str = preg_replace('~&#x(0*[0-9a-f]{2,5})~ei', 'chr(hexdec("\\1"))', $str); + return preg_replace('~&#([0-9]{2,4})~e', 'chr(\\1)', $str); + } + + // Numeric Entities + $str = preg_replace('~&#x(0*[0-9a-f]{2,5});{0,1}~ei', 'chr(hexdec("\\1"))', $str); + $str = preg_replace('~&#([0-9]{2,4});{0,1}~e', 'chr(\\1)', $str); + + // Literal Entities - Slightly slow so we do another check + if (stristr($str, '&') === FALSE) + { + $str = strtr($str, array_flip(get_html_translation_table(HTML_ENTITIES))); + } + + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Filename Security + * + * @access public + * @param string + * @return string + */ + public function sanitize_filename($str, $relative_path = FALSE) + { + $bad = array( + "../", + "<!--", + "-->", + "<", + ">", + "'", + '"', + '&', + '$', + '#', + '{', + '}', + '[', + ']', + '=', + ';', + '?', + "%20", + "%22", + "%3c", // < + "%253c", // < + "%3e", // > + "%0e", // > + "%28", // ( + "%29", // ) + "%2528", // ( + "%26", // & + "%24", // $ + "%3f", // ? + "%3b", // ; + "%3d" // = + ); + + if ( ! $relative_path) + { + $bad[] = './'; + $bad[] = '/'; + } + + return stripslashes(str_replace($bad, '', $str)); + } + +} +// END Security Class + +/* End of file Security.php */ +/* Location: ./system/libraries/Security.php */
\ No newline at end of file diff --git a/system/libraries/Session.php b/system/libraries/Session.php index bd9426818..53ff4f5d3 100644..100755 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -30,6 +30,7 @@ class CI_Session { var $sess_use_database = FALSE; var $sess_table_name = ''; var $sess_expiration = 7200; + var $sess_expire_on_close = FALSE; var $sess_match_ip = FALSE; var $sess_match_useragent = TRUE; var $sess_cookie_name = 'ci_session'; @@ -38,7 +39,7 @@ class CI_Session { var $cookie_domain = ''; var $sess_time_to_update = 300; var $encryption_key = ''; - var $flashdata_key = 'flash'; + var $flashdata_key = 'flash'; var $time_reference = 'time'; var $gc_probability = 5; var $userdata = array(); @@ -51,7 +52,7 @@ class CI_Session { * The constructor runs the session routines automatically * whenever the class is instantiated. */ - function CI_Session($params = array()) + public function __construct($params = array()) { log_message('debug', "Session Class Initialized"); @@ -60,11 +61,16 @@ class CI_Session { // Set all the session preferences, which can either be set // manually via the $params array above or via the config file - foreach (array('sess_encrypt_cookie', 'sess_use_database', 'sess_table_name', 'sess_expiration', 'sess_match_ip', 'sess_match_useragent', 'sess_cookie_name', 'cookie_path', 'cookie_domain', 'sess_time_to_update', 'time_reference', 'cookie_prefix', 'encryption_key') as $key) + foreach (array('sess_encrypt_cookie', 'sess_use_database', 'sess_table_name', 'sess_expiration', 'sess_expire_on_close', 'sess_match_ip', 'sess_match_useragent', 'sess_cookie_name', 'cookie_path', 'cookie_domain', 'sess_time_to_update', 'time_reference', 'cookie_prefix', 'encryption_key') as $key) { $this->$key = (isset($params[$key])) ? $params[$key] : $this->CI->config->item($key); } + if ($this->encryption_key == '') + { + show_error('In order to use the Session class you are required to set an encryption key in your config file.'); + } + // Load the string helper so we can use the strip_slashes() function $this->CI->load->helper('string'); @@ -90,7 +96,7 @@ class CI_Session { { $this->sess_expiration = (60*60*24*365*2); } - + // Set the cookie name $this->sess_cookie_name = $this->cookie_prefix.$this->sess_cookie_name; @@ -106,10 +112,10 @@ class CI_Session { } // Delete 'old' flashdata (from last request) - $this->_flashdata_sweep(); + $this->_flashdata_sweep(); // Mark all new flashdata as old (data will be deleted before next request) - $this->_flashdata_mark(); + $this->_flashdata_mark(); // Delete expired sessions if necessary $this->_sess_gc(); @@ -307,9 +313,9 @@ class CI_Session { $sessid .= $this->CI->input->ip_address(); $this->userdata = array( - 'session_id' => md5(uniqid($sessid, TRUE)), - 'ip_address' => $this->CI->input->ip_address(), - 'user_agent' => substr($this->CI->input->user_agent(), 0, 50), + 'session_id' => md5(uniqid($sessid, TRUE)), + 'ip_address' => $this->CI->input->ip_address(), + 'user_agent' => substr($this->CI->input->user_agent(), 0, 50), 'last_activity' => $this->now ); @@ -651,11 +657,13 @@ class CI_Session { $cookie_data = $cookie_data.md5($cookie_data.$this->encryption_key); } + $expire = ($this->sess_expire_on_close === TRUE) ? 0 : $this->sess_expiration + time(); + // Set the cookie setcookie( $this->sess_cookie_name, $cookie_data, - $this->sess_expiration + time(), + $expire, $this->cookie_path, $this->cookie_domain, 0 @@ -680,12 +688,18 @@ class CI_Session { { foreach ($data as $key => $val) { - $data[$key] = str_replace('\\', '{{slash}}', $val); + if (is_string($val)) + { + $data[$key] = str_replace('\\', '{{slash}}', $val); + } } } else { - $data = str_replace('\\', '{{slash}}', $data); + if (is_string($data)) + { + $data = str_replace('\\', '{{slash}}', $data); + } } return serialize($data); @@ -711,13 +725,16 @@ class CI_Session { { foreach ($data as $key => $val) { - $data[$key] = str_replace('{{slash}}', '\\', $val); + if (is_string($val)) + { + $data[$key] = str_replace('{{slash}}', '\\', $val); + } } return $data; } - return str_replace('{{slash}}', '\\', $data); + return (is_string($data)) ? str_replace('{{slash}}', '\\', $data) : $data; } // -------------------------------------------------------------------- diff --git a/system/libraries/Sha1.php b/system/libraries/Sha1.php index f9611a8a5..ad747a001 100644..100755 --- a/system/libraries/Sha1.php +++ b/system/libraries/Sha1.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -44,7 +44,7 @@ */ class CI_SHA { - function CI_SHA() + public function __construct() { log_message('debug', "SHA1 Class Initialized"); } @@ -55,7 +55,7 @@ class CI_SHA { * @access public * @param string * @return string - */ + */ function generate($str) { $n = ((strlen($str) + 8) >> 6) + 1; @@ -117,7 +117,7 @@ class CI_SHA { return $this->_hex($a).$this->_hex($b).$this->_hex($c).$this->_hex($d).$this->_hex($e); } - + // -------------------------------------------------------------------- /** @@ -126,7 +126,7 @@ class CI_SHA { * @access private * @param string * @return string - */ + */ function _hex($str) { $str = dechex($str); @@ -138,7 +138,7 @@ class CI_SHA { return $str; } - + // -------------------------------------------------------------------- /** @@ -146,7 +146,7 @@ class CI_SHA { * * @access private * @return string - */ + */ function _ft($t, $b, $c, $d) { if ($t < 20) @@ -166,7 +166,7 @@ class CI_SHA { * * @access private * @return string - */ + */ function _kt($t) { if ($t < 20) @@ -186,7 +186,7 @@ class CI_SHA { return -899497514; } } - + // -------------------------------------------------------------------- /** @@ -194,7 +194,7 @@ class CI_SHA { * * @access private * @return string - */ + */ function _safe_add($x, $y) { $lsw = ($x & 0xFFFF) + ($y & 0xFFFF); @@ -202,7 +202,7 @@ class CI_SHA { return ($msw << 16) | ($lsw & 0xFFFF); } - + // -------------------------------------------------------------------- /** @@ -210,7 +210,7 @@ class CI_SHA { * * @access private * @return integer - */ + */ function _rol($num, $cnt) { return ($num << $cnt) | $this->_zero_fill($num, 32 - $cnt); @@ -223,7 +223,7 @@ class CI_SHA { * * @access private * @return string - */ + */ function _zero_fill($a, $b) { $bin = decbin($a); diff --git a/system/libraries/Table.php b/system/libraries/Table.php index a990d406c..485541630 100644..100755 --- a/system/libraries/Table.php +++ b/system/libraries/Table.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.3.1 @@ -30,14 +30,14 @@ class CI_Table { var $rows = array(); var $heading = array(); - var $auto_heading = TRUE; - var $caption = NULL; - var $template = NULL; + var $auto_heading = TRUE; + var $caption = NULL; + var $template = NULL; var $newline = "\n"; var $empty_cells = ""; - - - function CI_Table() + var $function = FALSE; + + public function __construct() { log_message('debug', "Table Class Initialized"); } @@ -57,7 +57,7 @@ class CI_Table { { return FALSE; } - + $this->template = $template; } @@ -75,7 +75,7 @@ class CI_Table { function set_heading() { $args = func_get_args(); - $this->heading = (is_array($args[0])) ? $args[0] : $args; + $this->heading = $this->_prep_args($args); } // -------------------------------------------------------------------- @@ -97,21 +97,21 @@ class CI_Table { { return FALSE; } - - // Turn off the auto-heading feature since it's doubtful we + + // Turn off the auto-heading feature since it's doubtful we // will want headings from a one-dimensional array $this->auto_heading = FALSE; - + if ($col_limit == 0) { return $array; } - + $new = array(); while(count($array) > 0) - { + { $temp = array_splice($array, 0, $col_limit); - + if (count($temp) < $col_limit) { for ($i = count($temp); $i < $col_limit; $i++) @@ -119,10 +119,10 @@ class CI_Table { $temp[] = ' '; } } - + $new[] = $temp; } - + return $new; } @@ -141,7 +141,7 @@ class CI_Table { { $this->empty_cells = $value; } - + // -------------------------------------------------------------------- /** @@ -156,7 +156,55 @@ class CI_Table { function add_row() { $args = func_get_args(); - $this->rows[] = (is_array($args[0])) ? $args[0] : $args; + $this->rows[] = $this->_prep_args($args); + } + + // -------------------------------------------------------------------- + + /** + * Prep Args + * + * Ensures a standard associative array format for all cell data + * + * @access public + * @param type + * @return type + */ + function _prep_args($args) + { + // If there is no $args[0], skip this and treat as an associative array + // This can happen if there is only a single key, for example this is passed to table->generate + // array(array('foo'=>'bar')) + if (isset($args[0]) AND (count($args) == 1 && is_array($args[0]))) + { + // args sent as indexed array + if ( ! isset($args[0]['data'])) + { + foreach ($args[0] as $key => $val) + { + if (is_array($val) && isset($val['data'])) + { + $args[$key] = $val; + } + else + { + $args[$key] = array('data' => $val); + } + } + } + } + else + { + foreach ($args as $key => $val) + { + if ( ! is_array($val)) + { + $args[$key] = array('data' => $val); + } + } + } + + return $args; } // -------------------------------------------------------------------- @@ -171,7 +219,7 @@ class CI_Table { function set_caption($caption) { $this->caption = $caption; - } + } // -------------------------------------------------------------------- @@ -198,21 +246,23 @@ class CI_Table { $this->_set_from_array($table_data, $set_heading); } } - + // Is there anything to display? No? Smite them! if (count($this->heading) == 0 AND count($this->rows) == 0) { return 'Undefined table data'; } - + // Compile and validate the template date $this->_compile_template(); - - + + // set a custom cell manipulation function to a locally scoped variable so its callable + $function = $this->function; + // Build the table! - + $out = $this->template['table_open']; - $out .= $this->newline; + $out .= $this->newline; // Add any caption here if ($this->caption) @@ -225,23 +275,40 @@ class CI_Table { // Is there a table heading to display? if (count($this->heading) > 0) { + $out .= $this->template['thead_open']; + $out .= $this->newline; $out .= $this->template['heading_row_start']; - $out .= $this->newline; + $out .= $this->newline; foreach($this->heading as $heading) { - $out .= $this->template['heading_cell_start']; - $out .= $heading; + $temp = $this->template['heading_cell_start']; + + foreach ($heading as $key => $val) + { + if ($key != 'data') + { + $temp = str_replace('<th', "<th $key='$val'", $temp); + } + } + + $out .= $temp; + $out .= isset($heading['data']) ? $heading['data'] : ''; $out .= $this->template['heading_cell_end']; } $out .= $this->template['heading_row_end']; - $out .= $this->newline; + $out .= $this->newline; + $out .= $this->template['thead_close']; + $out .= $this->newline; } // Build the table rows if (count($this->rows) > 0) { + $out .= $this->template['tbody_open']; + $out .= $this->newline; + $i = 1; foreach($this->rows as $row) { @@ -249,39 +316,60 @@ class CI_Table { { break; } - + // We use modulus to alternate the row colors $name = (fmod($i++, 2)) ? '' : 'alt_'; - + $out .= $this->template['row_'.$name.'start']; - $out .= $this->newline; - + $out .= $this->newline; + foreach($row as $cell) { - $out .= $this->template['cell_'.$name.'start']; - - if ($cell === "") + $temp = $this->template['cell_'.$name.'start']; + + foreach ($cell as $key => $val) + { + if ($key != 'data') + { + $temp = str_replace('<td', "<td $key='$val'", $temp); + } + } + + $cell = isset($cell['data']) ? $cell['data'] : ''; + $out .= $temp; + + if ($cell === "" OR $cell === NULL) { $out .= $this->empty_cells; } else { - $out .= $cell; + if ($function !== FALSE && is_callable($function)) + { + $out .= call_user_func($function, $cell); + } + else + { + $out .= $cell; + } } - + $out .= $this->template['cell_'.$name.'end']; } - + $out .= $this->template['row_'.$name.'end']; - $out .= $this->newline; + $out .= $this->newline; } + + $out .= $this->template['tbody_close']; + $out .= $this->newline; } $out .= $this->template['table_close']; - + return $out; } - + // -------------------------------------------------------------------- /** @@ -294,9 +382,9 @@ class CI_Table { { $this->rows = array(); $this->heading = array(); - $this->auto_heading = TRUE; + $this->auto_heading = TRUE; } - + // -------------------------------------------------------------------- /** @@ -312,7 +400,7 @@ class CI_Table { { return FALSE; } - + // First generate the headings from the table column names if (count($this->heading) == 0) { @@ -320,17 +408,17 @@ class CI_Table { { return FALSE; } - - $this->heading = $query->list_fields(); + + $this->heading = $this->_prep_args($query->list_fields()); } - + // Next blast through the result array and build out the rows - + if ($query->num_rows() > 0) { foreach ($query->result_array() as $row) { - $this->rows[] = $row; + $this->rows[] = $this->_prep_args($row); } } } @@ -350,26 +438,20 @@ class CI_Table { { return FALSE; } - + $i = 0; foreach ($data as $row) { - if ( ! is_array($row)) - { - $this->rows[] = $data; - break; - } - // If a heading hasn't already been set we'll use the first row of the array as the heading if ($i == 0 AND count($data) > 1 AND count($this->heading) == 0 AND $set_heading == TRUE) { - $this->heading = $row; + $this->heading = $this->_prep_args($row); } else { - $this->rows[] = $row; + $this->rows[] = $this->_prep_args($row); } - + $i++; } } @@ -382,24 +464,24 @@ class CI_Table { * @access private * @return void */ - function _compile_template() - { - if ($this->template == NULL) - { - $this->template = $this->_default_template(); - return; - } - + function _compile_template() + { + if ($this->template == NULL) + { + $this->template = $this->_default_template(); + return; + } + $this->temp = $this->_default_template(); - foreach (array('table_open','heading_row_start', 'heading_row_end', 'heading_cell_start', 'heading_cell_end', 'row_start', 'row_end', 'cell_start', 'cell_end', 'row_alt_start', 'row_alt_end', 'cell_alt_start', 'cell_alt_end', 'table_close') as $val) + foreach (array('table_open', 'thead_open', 'thead_close', 'heading_row_start', 'heading_row_end', 'heading_cell_start', 'heading_cell_end', 'tbody_open', 'tbody_close', 'row_start', 'row_end', 'cell_start', 'cell_end', 'row_alt_start', 'row_alt_end', 'cell_alt_start', 'cell_alt_end', 'table_close') as $val) { if ( ! isset($this->template[$val])) { $this->template[$val] = $this->temp[$val]; } - } - } - + } + } + // -------------------------------------------------------------------- /** @@ -411,27 +493,33 @@ class CI_Table { function _default_template() { return array ( - 'table_open' => '<table border="0" cellpadding="4" cellspacing="0">', + 'table_open' => '<table border="0" cellpadding="4" cellspacing="0">', + + 'thead_open' => '<thead>', + 'thead_close' => '</thead>', - 'heading_row_start' => '<tr>', - 'heading_row_end' => '</tr>', + 'heading_row_start' => '<tr>', + 'heading_row_end' => '</tr>', 'heading_cell_start' => '<th>', 'heading_cell_end' => '</th>', - 'row_start' => '<tr>', - 'row_end' => '</tr>', + 'tbody_open' => '<tbody>', + 'tbody_close' => '</tbody>', + + 'row_start' => '<tr>', + 'row_end' => '</tr>', 'cell_start' => '<td>', 'cell_end' => '</td>', - 'row_alt_start' => '<tr>', - 'row_alt_end' => '</tr>', + 'row_alt_start' => '<tr>', + 'row_alt_end' => '</tr>', 'cell_alt_start' => '<td>', 'cell_alt_end' => '</td>', - 'table_close' => '</table>' - ); + 'table_close' => '</table>' + ); } - + } diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php index 9b1737c5f..e29b35c7a 100644..100755 --- a/system/libraries/Trackback.php +++ b/system/libraries/Trackback.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -27,7 +27,7 @@ * @link http://codeigniter.com/user_guide/libraries/trackback.html */ class CI_Trackback { - + var $time_format = 'local'; var $charset = 'UTF-8'; var $data = array('url' => '', 'title' => '', 'excerpt' => '', 'blog_name' => '', 'charset' => ''); @@ -40,28 +40,28 @@ class CI_Trackback { * * @access public */ - function CI_Trackback() + public function __construct() { log_message('debug', "Trackback Class Initialized"); } - + // -------------------------------------------------------------------- - + /** * Send Trackback * * @access public * @param array * @return bool - */ + */ function send($tb_data) - { + { if ( ! is_array($tb_data)) { $this->set_error('The send() method must be passed an array'); return FALSE; } - + // Pre-process the Trackback Data foreach (array('url', 'title', 'excerpt', 'blog_name', 'ping_url') as $item) { @@ -70,14 +70,14 @@ class CI_Trackback { $this->set_error('Required item missing: '.$item); return FALSE; } - + switch ($item) { case 'ping_url' : $$item = $this->extract_urls($tb_data[$item]); break; case 'excerpt' : $$item = $this->limit_characters($this->convert_xml(strip_tags(stripslashes($tb_data[$item])))); break; - case 'url' : $$item = str_replace('-', '-', $this->convert_xml(strip_tags(stripslashes($tb_data[$item])))); + case 'url' : $$item = str_replace('-', '-', $this->convert_xml(strip_tags(stripslashes($tb_data[$item])))); break; default : $$item = $this->convert_xml(strip_tags(stripslashes($tb_data[$item]))); break; @@ -103,9 +103,9 @@ class CI_Trackback { // Build the Trackback data string $charset = ( ! isset($tb_data['charset'])) ? $this->charset : $tb_data['charset']; - + $data = "url=".rawurlencode($url)."&title=".rawurlencode($title)."&blog_name=".rawurlencode($blog_name)."&excerpt=".rawurlencode($excerpt)."&charset=".rawurlencode($charset); - + // Send Trackback(s) $return = TRUE; if (count($ping_url) > 0) @@ -116,27 +116,27 @@ class CI_Trackback { { $return = FALSE; } - } + } } return $return; } - + // -------------------------------------------------------------------- - + /** * Receive Trackback Data * * This function simply validates the incoming TB data. - * It returns false on failure and true on success. + * It returns FALSE on failure and TRUE on success. * If the data is valid it is set to the $this->data array * so that it can be inserted into a database. * * @access public * @return bool - */ + */ function receive() - { + { foreach (array('url', 'title', 'blog_name', 'excerpt') as $val) { if ( ! isset($_POST[$val]) OR $_POST[$val] == '') @@ -144,29 +144,29 @@ class CI_Trackback { $this->set_error('The following required POST variable is missing: '.$val); return FALSE; } - + $this->data['charset'] = ( ! isset($_POST['charset'])) ? 'auto' : strtoupper(trim($_POST['charset'])); - + if ($val != 'url' && function_exists('mb_convert_encoding')) { $_POST[$val] = mb_convert_encoding($_POST[$val], $this->charset, $this->data['charset']); } - + $_POST[$val] = ($val != 'url') ? $this->convert_xml(strip_tags($_POST[$val])) : strip_tags($_POST[$val]); - + if ($val == 'excerpt') { $_POST['excerpt'] = $this->limit_characters($_POST['excerpt']); } - + $this->data[$val] = $_POST[$val]; } return TRUE; - } - + } + // -------------------------------------------------------------------- - + /** * Send Trackback Error Message * @@ -177,15 +177,15 @@ class CI_Trackback { * @access public * @param string * @return void - */ + */ function send_error($message = 'Incomplete Information') { echo "<?xml version=\"1.0\" encoding=\"utf-8\"?".">\n<response>\n<error>1</error>\n<message>".$message."</message>\n</response>"; exit; } - + // -------------------------------------------------------------------- - + /** * Send Trackback Success Message * @@ -194,44 +194,44 @@ class CI_Trackback { * * @access public * @return void - */ + */ function send_success() { echo "<?xml version=\"1.0\" encoding=\"utf-8\"?".">\n<response>\n<error>0</error>\n</response>"; exit; } - + // -------------------------------------------------------------------- - + /** * Fetch a particular item * * @access public * @param string * @return string - */ + */ function data($item) { return ( ! isset($this->data[$item])) ? '' : $this->data[$item]; } // -------------------------------------------------------------------- - + /** * Process Trackback * * Opens a socket connection and passes the data to - * the server. Returns true on success, false on failure + * the server. Returns TRUE on success, FALSE on failure * * @access public * @param string * @param string * @return bool - */ + */ function process($url, $data) { $target = parse_url($url); - + // Open the socket if ( ! $fp = @fsockopen($target['host'], 80)) { @@ -241,7 +241,7 @@ class CI_Trackback { // Build the path $ppath = ( ! isset($target['path'])) ? $url : $target['path']; - + $path = (isset($target['query']) && $target['query'] != "") ? $ppath.'?'.$target['query'] : $ppath; // Add the Trackback ID to the data string @@ -260,31 +260,32 @@ class CI_Trackback { // Was it successful? $this->response = ""; - + while( ! feof($fp)) { $this->response .= fgets($fp, 128); } @fclose($fp); - + + if (stristr($this->response, '<error>0</error>') === FALSE) { $message = 'An unknown error was encountered'; - + if (preg_match("/<message>(.*?)<\/message>/is", $this->response, $match)) { $message = trim($match['1']); } - + $this->set_error($message); return FALSE; } return TRUE; } - + // -------------------------------------------------------------------- - + /** * Extract Trackback URLs * @@ -295,34 +296,34 @@ class CI_Trackback { * @access public * @param string * @return string - */ + */ function extract_urls($urls) - { + { // Remove the pesky white space and replace with a comma. $urls = preg_replace("/\s*(\S+)\s*/", "\\1,", $urls); - + // If they use commas get rid of the doubles. $urls = str_replace(",,", ",", $urls); - + // Remove any comma that might be at the end if (substr($urls, -1) == ",") { $urls = substr($urls, 0, -1); } - + // Break into an array via commas $urls = preg_split('/[,]/', $urls); - + // Removes duplicates $urls = array_unique($urls); - + array_walk($urls, array($this, 'validate_url')); - + return $urls; } - + // -------------------------------------------------------------------- - + /** * Validate URL * @@ -331,7 +332,7 @@ class CI_Trackback { * @access public * @param string * @return string - */ + */ function validate_url($url) { $url = trim($url); @@ -341,58 +342,58 @@ class CI_Trackback { $url = "http://".$url; } } - + // -------------------------------------------------------------------- - + /** * Find the Trackback URL's ID * * @access public * @param string * @return string - */ + */ function get_id($url) - { + { $tb_id = ""; - - if (strstr($url, '?')) + + if (strpos($url, '?') !== FALSE) { $tb_array = explode('/', $url); $tb_end = $tb_array[count($tb_array)-1]; - + if ( ! is_numeric($tb_end)) { $tb_end = $tb_array[count($tb_array)-2]; } - + $tb_array = explode('=', $tb_end); $tb_id = $tb_array[count($tb_array)-1]; } else { $url = rtrim($url, '/'); - + $tb_array = explode('/', $url); $tb_id = $tb_array[count($tb_array)-1]; - + if ( ! is_numeric($tb_id)) { $tb_id = $tb_array[count($tb_array)-2]; } - } - + } + if ( ! preg_match ("/^([0-9]+)$/", $tb_id)) { - return false; + return FALSE; } else { return $tb_id; - } + } } - + // -------------------------------------------------------------------- - + /** * Convert Reserved XML characters to Entities * @@ -403,22 +404,22 @@ class CI_Trackback { function convert_xml($str) { $temp = '__TEMP_AMPERSANDS__'; - + $str = preg_replace("/&#(\d+);/", "$temp\\1;", $str); $str = preg_replace("/&(\w+);/", "$temp\\1;", $str); - + $str = str_replace(array("&","<",">","\"", "'", "-"), - array("&", "<", ">", """, "'", "-"), - $str); - + array("&", "<", ">", """, "'", "-"), + $str); + $str = preg_replace("/$temp(\d+);/","&#\\1;",$str); $str = preg_replace("/$temp(\w+);/","&\\1;", $str); - + return $str; - } - + } + // -------------------------------------------------------------------- - + /** * Character limiter * @@ -438,25 +439,25 @@ class CI_Trackback { } $str = preg_replace("/\s+/", ' ', str_replace(array("\r\n", "\r", "\n"), ' ', $str)); - + if (strlen($str) <= $n) { return $str; } - + $out = ""; foreach (explode(' ', trim($str)) as $val) { - $out .= $val.' '; + $out .= $val.' '; if (strlen($out) >= $n) { return trim($out).$end_char; - } + } } } - + // -------------------------------------------------------------------- - + /** * High ASCII to Entities * @@ -469,58 +470,58 @@ class CI_Trackback { */ function convert_ascii($str) { - $count = 1; - $out = ''; - $temp = array(); - - for ($i = 0, $s = strlen($str); $i < $s; $i++) - { - $ordinal = ord($str[$i]); - - if ($ordinal < 128) - { - $out .= $str[$i]; - } - else - { - if (count($temp) == 0) - { - $count = ($ordinal < 224) ? 2 : 3; - } - - $temp[] = $ordinal; - - if (count($temp) == $count) - { - $number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64); - - $out .= '&#'.$number.';'; - $count = 1; - $temp = array(); - } - } - } - - return $out; + $count = 1; + $out = ''; + $temp = array(); + + for ($i = 0, $s = strlen($str); $i < $s; $i++) + { + $ordinal = ord($str[$i]); + + if ($ordinal < 128) + { + $out .= $str[$i]; + } + else + { + if (count($temp) == 0) + { + $count = ($ordinal < 224) ? 2 : 3; + } + + $temp[] = $ordinal; + + if (count($temp) == $count) + { + $number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64); + + $out .= '&#'.$number.';'; + $count = 1; + $temp = array(); + } + } + } + + return $out; } - + // -------------------------------------------------------------------- - + /** * Set error message * * @access public * @param string * @return void - */ + */ function set_error($msg) { log_message('error', $msg); $this->error_msg[] = $msg; } - + // -------------------------------------------------------------------- - + /** * Show error messages * @@ -528,15 +529,15 @@ class CI_Trackback { * @param string * @param string * @return string - */ + */ function display_errors($open = '<p>', $close = '</p>') - { + { $str = ''; foreach ($this->error_msg as $val) { $str .= $open.$val.$close; } - + return $str; } diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php index 0f0a8b7a2..734cec104 100644..100755 --- a/system/libraries/Typography.php +++ b/system/libraries/Typography.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -28,39 +28,31 @@ class CI_Typography { // Block level elements that should not be wrapped inside <p> tags var $block_elements = 'address|blockquote|div|dl|fieldset|form|h\d|hr|noscript|object|ol|p|pre|script|table|ul'; - + // Elements that should not have <p> and <br /> tags within them. var $skip_elements = 'p|pre|ol|ul|dl|object|table|h\d'; - + // Tags we want the parser to completely ignore when splitting the string. var $inline_elements = 'a|abbr|acronym|b|bdo|big|br|button|cite|code|del|dfn|em|i|img|ins|input|label|map|kbd|q|samp|select|small|span|strong|sub|sup|textarea|tt|var'; - + // array of block level elements that require inner content to be within another block level element var $inner_block_required = array('blockquote'); - + // the last block element parsed var $last_block_element = ''; - + // whether or not to protect quotes within { curly braces } var $protect_braced_quotes = FALSE; - - /** - * Nothing to do here... - * - */ - function CI_Typography() - { - } /** * Auto Typography * * This function converts text, making it typographically correct: - * - Converts double spaces into paragraphs. - * - Converts single line breaks into <br /> tags - * - Converts single and double quotes into correctly facing curly quote entities. - * - Converts three dots into ellipsis. - * - Converts double dashes into em-dashes. + * - Converts double spaces into paragraphs. + * - Converts single line breaks into <br /> tags + * - Converts single and double quotes into correctly facing curly quote entities. + * - Converts three dots into ellipsis. + * - Converts double dashes into em-dashes. * - Converts two spaces into entities * * @access public @@ -78,15 +70,15 @@ class CI_Typography { // Standardize Newlines to make matching easier if (strpos($str, "\r") !== FALSE) { - $str = str_replace(array("\r\n", "\r"), "\n", $str); + $str = str_replace(array("\r\n", "\r"), "\n", $str); } - + // Reduce line breaks. If there are more than two consecutive linebreaks // we'll compress them down to a maximum of two since there's no benefit to more. if ($reduce_linebreaks === TRUE) { $str = preg_replace("/\n\n+/", "\n\n", $str); - } + } // HTML comment tags don't conform to patterns of normal tags, so pull them out separately, only if needed $html_comments = array(); @@ -101,50 +93,50 @@ class CI_Typography { } } } - + // match and yank <pre> tags if they exist. It's cheaper to do this separately since most content will // not contain <pre> tags, and it keeps the PCRE patterns below simpler and faster if (strpos($str, '<pre') !== FALSE) { $str = preg_replace_callback("#<pre.*?>.*?</pre>#si", array($this, '_protect_characters'), $str); } - + // Convert quotes within tags to temporary markers. $str = preg_replace_callback("#<.+?>#si", array($this, '_protect_characters'), $str); // Do the same with braces if necessary if ($this->protect_braced_quotes === TRUE) { - $str = preg_replace_callback("#\{.+?\}#si", array($this, '_protect_characters'), $str); + $str = preg_replace_callback("#\{.+?\}#si", array($this, '_protect_characters'), $str); } - - // Convert "ignore" tags to temporary marker. The parser splits out the string at every tag - // it encounters. Certain inline tags, like image tags, links, span tags, etc. will be + + // Convert "ignore" tags to temporary marker. The parser splits out the string at every tag + // it encounters. Certain inline tags, like image tags, links, span tags, etc. will be // adversely affected if they are split out so we'll convert the opening bracket < temporarily to: {@TAG} $str = preg_replace("#<(/*)(".$this->inline_elements.")([ >])#i", "{@TAG}\\1\\2\\3", $str); // Split the string at every tag. This expression creates an array with this prototype: - // - // [array] - // { - // [0] = <opening tag> - // [1] = Content... - // [2] = <closing tag> - // Etc... - // } + // + // [array] + // { + // [0] = <opening tag> + // [1] = Content... + // [2] = <closing tag> + // Etc... + // } $chunks = preg_split('/(<(?:[^<>]+(?:"[^"]*"|\'[^\']*\')?)+>)/', $str, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY); - - // Build our finalized string. We cycle through the array, skipping tags, and processing the contained text + + // Build our finalized string. We cycle through the array, skipping tags, and processing the contained text $str = ''; $process = TRUE; $paragraph = FALSE; $current_chunk = 0; $total_chunks = count($chunks); - + foreach ($chunks as $chunk) - { + { $current_chunk++; - + // Are we dealing with a tag? If so, we'll skip the processing for this cycle. // Well also set the "process" flag which allows us to skip <pre> tags and a few other things. if (preg_match("#<(/*)(".$this->block_elements.").*?>#", $chunk, $match)) @@ -153,7 +145,7 @@ class CI_Typography { { $process = ($match[1] == '/') ? TRUE : FALSE; } - + if ($match[1] == '') { $this->last_block_element = $match[2]; @@ -162,32 +154,32 @@ class CI_Typography { $str .= $chunk; continue; } - + if ($process == FALSE) { $str .= $chunk; continue; } - + // Force a newline to make sure end tags get processed by _format_newlines() if ($current_chunk == $total_chunks) { - $chunk .= "\n"; + $chunk .= "\n"; } - + // Convert Newlines into <p> and <br /> tags $str .= $this->_format_newlines($chunk); } - + // No opening block level tag? Add it if needed. if ( ! preg_match("/^\s*<(?:".$this->block_elements.")/i", $str)) { $str = preg_replace("/^(.*?)<(".$this->block_elements.")/i", '<p>$1</p><$2', $str); } - + // Convert quotes, elipsis, em-dashes, non-breaking spaces, and ampersands $str = $this->format_characters($str); - + // restore HTML comments for ($i = 0, $total = count($html_comments); $i < $total; $i++) { @@ -196,18 +188,18 @@ class CI_Typography { // if '<p>{@HC1}' then replace <p>{@HC1}</p> with the comment, else replace only {@HC1} with the comment $str = preg_replace('#(?(?=<p>\{@HC'.$i.'\})<p>\{@HC'.$i.'\}(\s*</p>)|\{@HC'.$i.'\})#s', $html_comments[$i], $str); } - + // Final clean up $table = array( - + // If the user submitted their own paragraph tags within the text // we will retain them instead of using our tags. - '/(<p[^>*?]>)<p>/' => '$1', // <?php BBEdit syntax coloring bug fix - + '/(<p[^>*?]>)<p>/' => '$1', // <?php BBEdit syntax coloring bug fix + // Reduce multiple instances of opening/closing paragraph tags to a single one '#(</p>)+#' => '</p>', '/(<p>\W*<p>)+/' => '<p>', - + // Clean up stray paragraph tags that appear before block level elements '#<p></p><('.$this->block_elements.')#' => '<$1', @@ -219,10 +211,19 @@ class CI_Typography { '/\{@DQ\}/' => '"', '/\{@SQ\}/' => "'", '/\{@DD\}/' => '--', - '/\{@NBS\}/' => ' ' + '/\{@NBS\}/' => ' ', + // An unintended consequence of the _format_newlines function is that + // some of the newlines get truncated, resulting in <p> tags + // starting immediately after <block> tags on the same line. + // This forces a newline after such occurrences, which looks much nicer. + "/><p>\n/" => ">\n<p>", + + // Similarly, there might be cases where a closing </block> will follow + // a closing </p> tag, so we'll correct it by adding a newline in between + "#</p></#" => "</p>\n</" ); - + // Do we need to reduce empty lines? if ($reduce_linebreaks === TRUE) { @@ -234,13 +235,13 @@ class CI_Typography { // otherwise most browsers won't treat them as true paragraphs $table['#<p></p>#'] = '<p> </p>'; } - + return preg_replace(array_keys($table), $table, $str); } - + // -------------------------------------------------------------------- - + /** * Format Characters * @@ -255,10 +256,10 @@ class CI_Typography { function format_characters($str) { static $table; - + if ( ! isset($table)) { - $table = array( + $table = array( // nested smart quotes, opening and closing // note that rules for grammar (English) allow only for two levels deep // and that single quotes are _supposed_ to always be on the outside @@ -304,7 +305,7 @@ class CI_Typography { return preg_replace(array_keys($table), $table, $str); } - + // -------------------------------------------------------------------- /** @@ -315,47 +316,50 @@ class CI_Typography { * @access public * @param string * @return string - */ + */ function _format_newlines($str) { if ($str == '') { return $str; } - + if (strpos($str, "\n") === FALSE && ! in_array($this->last_block_element, $this->inner_block_required)) { return $str; } - + // Convert two consecutive newlines to paragraphs $str = str_replace("\n\n", "</p>\n\n<p>", $str); - + // Convert single spaces to <br /> tags $str = preg_replace("/([^\n])(\n)([^\n])/", "\\1<br />\\2\\3", $str); - + // Wrap the whole enchilada in enclosing paragraphs if ($str != "\n") { - $str = '<p>'.$str.'</p>'; + // We trim off the right-side new line so that the closing </p> tag + // will be positioned immediately following the string, matching + // the behavior of the opening <p> tag + $str = '<p>'.rtrim($str).'</p>'; } // Remove empty paragraphs if they are on the first line, as this // is a potential unintended consequence of the previous code $str = preg_replace("/<p><\/p>(.*)/", "\\1", $str, 1); - + return $str; } - + // ------------------------------------------------------------------------ - + /** * Protect Characters * * Protects special characters from being formatted later * We don't want quotes converted within tags so we'll temporarily convert them to {@DQ} and {@SQ} - * and we don't want double dashes converted to emdash entities, so they are marked with {@DD} - * likewise double spaces are converted to {@NBS} to prevent entity conversion + * and we don't want double dashes converted to emdash entities, so they are marked with {@DD} + * likewise double spaces are converted to {@NBS} to prevent entity conversion * * @access public * @param array @@ -367,19 +371,19 @@ class CI_Typography { } // -------------------------------------------------------------------- - + /** * Convert newlines to HTML line breaks except within PRE tags * * @access public * @param string * @return string - */ + */ function nl2br_except_pre($str) { $ex = explode("pre>",$str); $ct = count($ex); - + $newstr = ""; for ($i = 0; $i < $ct; $i++) { @@ -391,14 +395,14 @@ class CI_Typography { { $newstr .= $ex[$i]; } - + if ($ct - 1 != $i) $newstr .= "pre>"; } - + return $newstr; } - + } // END Typography Class diff --git a/system/libraries/Unit_test.php b/system/libraries/Unit_test.php index 29aeaae90..5bd7e801a 100644..100755 --- a/system/libraries/Unit_test.php +++ b/system/libraries/Unit_test.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.3.1 @@ -28,19 +28,50 @@ */ class CI_Unit_test { - var $active = TRUE; - var $results = array(); - var $strict = FALSE; - var $_template = NULL; - var $_template_rows = NULL; + var $active = TRUE; + var $results = array(); + var $strict = FALSE; + var $_template = NULL; + var $_template_rows = NULL; + var $_test_items_visible = array(); - function CI_Unit_test() + public function __construct() { + // These are the default items visible when a test is run. + $this->_test_items_visible = array ( + 'test_name', + 'test_datatype', + 'res_datatype', + 'result', + 'file', + 'line', + 'notes' + ); + log_message('debug', "Unit Testing Class Initialized"); - } + } // -------------------------------------------------------------------- - + + /** + * Run the tests + * + * Runs the supplied tests + * + * @access public + * @param array + * @return void + */ + function set_test_items($items = array()) + { + if ( ! empty($items) AND is_array($items)) + { + $this->_test_items_visible = $items; + } + } + + // -------------------------------------------------------------------- + /** * Run the tests * @@ -51,48 +82,49 @@ class CI_Unit_test { * @param mixed * @param string * @return string - */ - function run($test, $expected = TRUE, $test_name = 'undefined') + */ + function run($test, $expected = TRUE, $test_name = 'undefined', $notes = '') { if ($this->active == FALSE) { return FALSE; } - - if (in_array($expected, array('is_string', 'is_bool', 'is_true', 'is_false', 'is_int', 'is_numeric', 'is_float', 'is_double', 'is_array', 'is_null'), TRUE)) + + if (in_array($expected, array('is_object', 'is_string', 'is_bool', 'is_true', 'is_false', 'is_int', 'is_numeric', 'is_float', 'is_double', 'is_array', 'is_null'), TRUE)) { $expected = str_replace('is_float', 'is_double', $expected); - $result = ($expected($test)) ? TRUE : FALSE; + $result = ($expected($test)) ? TRUE : FALSE; $extype = str_replace(array('true', 'false'), 'bool', str_replace('is_', '', $expected)); } else { if ($this->strict == TRUE) - $result = ($test === $expected) ? TRUE : FALSE; + $result = ($test === $expected) ? TRUE : FALSE; else - $result = ($test == $expected) ? TRUE : FALSE; - + $result = ($test == $expected) ? TRUE : FALSE; + $extype = gettype($expected); } - + $back = $this->_backtrace(); - + $report[] = array ( 'test_name' => $test_name, 'test_datatype' => gettype($test), 'res_datatype' => $extype, 'result' => ($result === TRUE) ? 'passed' : 'failed', 'file' => $back['file'], - 'line' => $back['line'] + 'line' => $back['line'], + 'notes' => $notes ); - $this->results[] = $report; - + $this->results[] = $report; + return($this->report($this->result($report))); } // -------------------------------------------------------------------- - + /** * Generate a report * @@ -120,7 +152,6 @@ class CI_Unit_test { foreach ($res as $key => $val) { - if ($key == $CI->lang->line('ut_result')) { if ($val == $CI->lang->line('ut_passed')) @@ -144,9 +175,9 @@ class CI_Unit_test { return $r; } - + // -------------------------------------------------------------------- - + /** * Use strict comparison * @@ -160,9 +191,9 @@ class CI_Unit_test { { $this->strict = ($state == FALSE) ? FALSE : TRUE; } - + // -------------------------------------------------------------------- - + /** * Make Unit testing active * @@ -176,9 +207,9 @@ class CI_Unit_test { { $this->active = ($state == FALSE) ? FALSE : TRUE; } - + // -------------------------------------------------------------------- - + /** * Result Array * @@ -188,21 +219,26 @@ class CI_Unit_test { * @return array */ function result($results = array()) - { + { $CI =& get_instance(); $CI->load->language('unit_test'); - + if (count($results) == 0) { $results = $this->results; } - + $retval = array(); foreach ($results as $result) { $temp = array(); foreach ($result as $key => $val) { + if ( ! in_array($key, $this->_test_items_visible)) + { + continue; + } + if (is_array($val)) { foreach ($val as $k => $v) @@ -210,8 +246,8 @@ class CI_Unit_test { if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$v)))) { $v = $line; - } - $temp[$CI->lang->line('ut_'.$k)] = $v; + } + $temp[$CI->lang->line('ut_'.$k)] = $v; } } else @@ -219,19 +255,19 @@ class CI_Unit_test { if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$val)))) { $val = $line; - } + } $temp[$CI->lang->line('ut_'.$key)] = $val; } } - + $retval[] = $temp; } - + return $retval; } - + // -------------------------------------------------------------------- - + /** * Set the template * @@ -240,14 +276,14 @@ class CI_Unit_test { * @access public * @param string * @return void - */ + */ function set_template($template) { $this->_template = $template; } - + // -------------------------------------------------------------------- - + /** * Generate a backtrace * @@ -261,17 +297,17 @@ class CI_Unit_test { if (function_exists('debug_backtrace')) { $back = debug_backtrace(); - + $file = ( ! isset($back['1']['file'])) ? '' : $back['1']['file']; $line = ( ! isset($back['1']['line'])) ? '' : $back['1']['line']; - + return array('file' => $file, 'line' => $line); } return array('file' => 'Unknown', 'line' => 'Unknown'); } // -------------------------------------------------------------------- - + /** * Get Default Template * @@ -279,17 +315,17 @@ class CI_Unit_test { * @return string */ function _default_template() - { + { $this->_template = "\n".'<table style="width:100%; font-size:small; margin:10px 0; border-collapse:collapse; border:1px solid #CCC;">'; $this->_template .= '{rows}'; $this->_template .= "\n".'</table>'; - + $this->_template_rows = "\n\t".'<tr>'; $this->_template_rows .= "\n\t\t".'<th style="text-align: left; border-bottom:1px solid #CCC;">{item}</th>'; $this->_template_rows .= "\n\t\t".'<td style="border-bottom:1px solid #CCC;">{result}</td>'; - $this->_template_rows .= "\n\t".'</tr>'; + $this->_template_rows .= "\n\t".'</tr>'; } - + // -------------------------------------------------------------------- /** @@ -300,29 +336,29 @@ class CI_Unit_test { * @access private * @return void */ - function _parse_template() - { - if ( ! is_null($this->_template_rows)) - { - return; - } - - if (is_null($this->_template)) - { - $this->_default_template(); - return; - } - + function _parse_template() + { + if ( ! is_null($this->_template_rows)) + { + return; + } + + if (is_null($this->_template)) + { + $this->_default_template(); + return; + } + if ( ! preg_match("/\{rows\}(.*?)\{\/rows\}/si", $this->_template, $match)) { - $this->_default_template(); - return; + $this->_default_template(); + return; } $this->_template_rows = $match['1']; - $this->_template = str_replace($match['0'], '{rows}', $this->_template); - } - + $this->_template = str_replace($match['0'], '{rows}', $this->_template); + } + } // END Unit_test Class diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index a97b7bdfb..8f84ffd7e 100644..100755 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -25,59 +25,59 @@ * @link http://codeigniter.com/user_guide/libraries/file_uploading.html */ class CI_Upload { - - var $max_size = 0; - var $max_width = 0; - var $max_height = 0; - var $max_filename = 0; - var $allowed_types = ""; - var $file_temp = ""; - var $file_name = ""; - var $orig_name = ""; - var $file_type = ""; - var $file_size = ""; - var $file_ext = ""; - var $upload_path = ""; - var $overwrite = FALSE; - var $encrypt_name = FALSE; - var $is_image = FALSE; - var $image_width = ''; - var $image_height = ''; - var $image_type = ''; - var $image_size_str = ''; - var $error_msg = array(); - var $mimes = array(); - var $remove_spaces = TRUE; - var $xss_clean = FALSE; - var $temp_prefix = "temp_file_"; - var $client_name = ''; - - var $_file_name_override = ''; + + public $max_size = 0; + public $max_width = 0; + public $max_height = 0; + public $max_filename = 0; + public $allowed_types = ""; + public $file_temp = ""; + public $file_name = ""; + public $orig_name = ""; + public $file_type = ""; + public $file_size = ""; + public $file_ext = ""; + public $upload_path = ""; + public $overwrite = FALSE; + public $encrypt_name = FALSE; + public $is_image = FALSE; + public $image_width = ''; + public $image_height = ''; + public $image_type = ''; + public $image_size_str = ''; + public $error_msg = array(); + public $mimes = array(); + public $remove_spaces = TRUE; + public $xss_clean = FALSE; + public $temp_prefix = "temp_file_"; + public $client_name = ''; + + protected $_file_name_override = ''; + /** * Constructor * * @access public */ - function CI_Upload($props = array()) + public function __construct($props = array()) { if (count($props) > 0) { $this->initialize($props); } - + log_message('debug', "Upload Class Initialized"); } - + // -------------------------------------------------------------------- - + /** * Initialize preferences * - * @access public * @param array * @return void - */ - function initialize($config = array()) + */ + public function initialize($config = array()) { $defaults = array( 'max_size' => 0, @@ -105,9 +105,9 @@ class CI_Upload { 'xss_clean' => FALSE, 'temp_prefix' => "temp_file_", 'client_name' => '' - ); - - + ); + + foreach ($defaults as $key => $val) { if (isset($config[$key])) @@ -120,28 +120,27 @@ class CI_Upload { else { $this->$key = $config[$key]; - } + } } else { $this->$key = $val; } } - + // if a file_name was provided in the config, use it instead of the user input // supplied file name for all uploads until initialized again $this->_file_name_override = $this->file_name; } - + // -------------------------------------------------------------------- - + /** * Perform the file upload * - * @access public * @return bool - */ - function do_upload($field = 'userfile') + */ + public function do_upload($field = 'userfile') { // Is $_FILES[$field] set? If not, no reason to continue. if ( ! isset($_FILES[$field])) @@ -149,7 +148,7 @@ class CI_Upload { $this->set_error('upload_no_file_selected'); return FALSE; } - + // Is the upload path valid? if ( ! $this->validate_upload_path()) { @@ -171,10 +170,10 @@ class CI_Upload { $this->set_error('upload_file_exceeds_form_limit'); break; case 3: // UPLOAD_ERR_PARTIAL - $this->set_error('upload_file_partial'); + $this->set_error('upload_file_partial'); break; case 4: // UPLOAD_ERR_NO_FILE - $this->set_error('upload_no_file_selected'); + $this->set_error('upload_no_file_selected'); break; case 6: // UPLOAD_ERR_NO_TMP_DIR $this->set_error('upload_no_temp_directory'); @@ -192,9 +191,10 @@ class CI_Upload { return FALSE; } + // Set the uploaded data as class variables - $this->file_temp = $_FILES[$field]['tmp_name']; - $this->file_size = $_FILES[$field]['size']; + $this->file_temp = $_FILES[$field]['tmp_name']; + $this->file_size = $_FILES[$field]['size']; $this->file_type = preg_replace("/^(.+?);.*$/", "\\1", $_FILES[$field]['type']); $this->file_type = strtolower(trim(stripslashes($this->file_type), '"')); $this->file_name = $this->_prep_filename($_FILES[$field]['name']); @@ -207,20 +207,31 @@ class CI_Upload { $this->set_error('upload_invalid_filetype'); return FALSE; } - + // if we're overriding, let's now make sure the new name and type is allowed if ($this->_file_name_override != '') { $this->file_name = $this->_prep_filename($this->_file_name_override); - $this->file_ext = $this->get_extension($this->file_name); + + // If no extension was provided in the file_name config item, use the uploaded one + if(strpos($this->_file_name_override, '.') === FALSE) + { + $this->file_name .= $this->file_ext; + } + + // An extension was provided, lets have it! + else + { + $this->file_ext = $this->get_extension($this->_file_name_override); + } if ( ! $this->is_allowed_filetype(TRUE)) { $this->set_error('upload_invalid_filetype'); - return FALSE; + return FALSE; } } - + // Convert the file size to kilobytes if ($this->file_size > 0) { @@ -244,7 +255,7 @@ class CI_Upload { // Sanitize the file name for security $this->file_name = $this->clean_file_name($this->file_name); - + // Truncate the file name if it's too long if ($this->max_filename > 0) { @@ -268,7 +279,7 @@ class CI_Upload { if ($this->overwrite == FALSE) { $this->file_name = $this->set_filename($this->upload_path, $this->file_name); - + if ($this->file_name === FALSE) { return FALSE; @@ -276,6 +287,21 @@ class CI_Upload { } /* + * Run the file through the XSS hacking filter + * This helps prevent malicious code from being + * embedded within a file. Scripts can easily + * be disguised as images or other file types. + */ + if ($this->xss_clean) + { + if ($this->do_xss_clean() === FALSE) + { + $this->set_error('upload_unable_to_write_file'); + return FALSE; + } + } + + /* * Move the file to the final destination * To deal with different server configurations * we'll attempt to use copy() first. If that fails @@ -286,21 +312,10 @@ class CI_Upload { { if ( ! @move_uploaded_file($this->file_temp, $this->upload_path.$this->file_name)) { - $this->set_error('upload_destination_error'); - return FALSE; + $this->set_error('upload_destination_error'); + return FALSE; } } - - /* - * Run the file through the XSS hacking filter - * This helps prevent malicious code from being - * embedded within a file. Scripts can easily - * be disguised as images or other file types. - */ - if ($this->xss_clean == TRUE) - { - $this->do_xss_clean(); - } /* * Set the finalized image dimensions @@ -312,19 +327,18 @@ class CI_Upload { return TRUE; } - + // -------------------------------------------------------------------- - + /** * Finalized Data Array - * + * * Returns an associative array containing all of the information * related to the upload, allowing the developer easy access in one array. * - * @access public * @return array - */ - function data() + */ + public function data() { return array ( 'file_name' => $this->file_name, @@ -343,24 +357,23 @@ class CI_Upload { 'image_size_str' => $this->image_size_str, ); } - + // -------------------------------------------------------------------- - + /** * Set Upload Path * - * @access public * @param string * @return void - */ - function set_upload_path($path) + */ + public function set_upload_path($path) { // Make sure it has a trailing slash $this->upload_path = rtrim($path, '/').'/'; } - + // -------------------------------------------------------------------- - + /** * Set the file name * @@ -368,29 +381,28 @@ class CI_Upload { * existence of a file with the same name. If found, it will append a * number to the end of the filename to avoid overwriting a pre-existing file. * - * @access public * @param string * @param string * @return string - */ - function set_filename($path, $filename) + */ + public function set_filename($path, $filename) { if ($this->encrypt_name == TRUE) - { + { mt_srand(); - $filename = md5(uniqid(mt_rand())).$this->file_ext; + $filename = md5(uniqid(mt_rand())).$this->file_ext; } - + if ( ! file_exists($path.$filename)) { return $filename; } - + $filename = str_replace($this->file_ext, '', $filename); - + $new_filename = ''; for ($i = 1; $i < 100; $i++) - { + { if ( ! file_exists($path.$filename.$i.$this->file_ext)) { $new_filename = $filename.$i.$this->file_ext; @@ -408,89 +420,88 @@ class CI_Upload { return $new_filename; } } - + // -------------------------------------------------------------------- - + /** * Set Maximum File Size * - * @access public * @param integer * @return void - */ - function set_max_filesize($n) + */ + public function set_max_filesize($n) { $this->max_size = ((int) $n < 0) ? 0: (int) $n; } - + // -------------------------------------------------------------------- - + /** * Set Maximum File Name Length * - * @access public * @param integer * @return void - */ - function set_max_filename($n) + */ + public function set_max_filename($n) { $this->max_filename = ((int) $n < 0) ? 0: (int) $n; } // -------------------------------------------------------------------- - + /** * Set Maximum Image Width * - * @access public * @param integer * @return void - */ - function set_max_width($n) + */ + public function set_max_width($n) { $this->max_width = ((int) $n < 0) ? 0: (int) $n; } - + // -------------------------------------------------------------------- - + /** * Set Maximum Image Height * - * @access public * @param integer * @return void - */ - function set_max_height($n) + */ + public function set_max_height($n) { $this->max_height = ((int) $n < 0) ? 0: (int) $n; } - + // -------------------------------------------------------------------- - + /** * Set Allowed File Types * - * @access public * @param string * @return void - */ - function set_allowed_types($types) + */ + public function set_allowed_types($types) { + if ( ! is_array($types) && $types == '*') + { + $this->allowed_types = '*'; + return; + } $this->allowed_types = explode('|', $types); } - + // -------------------------------------------------------------------- - + /** * Set Image Properties * * Uses GD to determine the width/height/type of image * - * @access public * @param string * @return void - */ - function set_image_properties($path = '') + */ + public function set_image_properties($path = '') { if ( ! $this->is_image()) { @@ -500,7 +511,7 @@ class CI_Upload { if (function_exists('getimagesize')) { if (FALSE !== ($D = @getimagesize($path))) - { + { $types = array(1 => 'gif', 2 => 'jpeg', 3 => 'png'); $this->image_width = $D['0']; @@ -510,45 +521,43 @@ class CI_Upload { } } } - + // -------------------------------------------------------------------- - + /** * Set XSS Clean * * Enables the XSS flag so that the file that was uploaded * will be run through the XSS filter. * - * @access public * @param bool * @return void */ - function set_xss_clean($flag = FALSE) + public function set_xss_clean($flag = FALSE) { $this->xss_clean = ($flag == TRUE) ? TRUE : FALSE; } - + // -------------------------------------------------------------------- - + /** * Validate the image * - * @access public * @return bool - */ - function is_image() + */ + public function is_image() { // IE will sometimes return odd mime-types during upload, so here we just standardize all // jpegs or pngs to the same file type. $png_mimes = array('image/x-png'); $jpeg_mimes = array('image/jpg', 'image/jpe', 'image/jpeg', 'image/pjpeg'); - + if (in_array($this->file_type, $png_mimes)) { $this->file_type = 'image/png'; } - + if (in_array($this->file_type, $jpeg_mimes)) { $this->file_type = 'image/jpeg'; @@ -558,29 +567,33 @@ class CI_Upload { 'image/gif', 'image/jpeg', 'image/png', - ); + ); return (in_array($this->file_type, $img_mimes, TRUE)) ? TRUE : FALSE; } - + // -------------------------------------------------------------------- - + /** * Verify that the filetype is allowed * - * @access public * @return bool - */ - function is_allowed_filetype($ignore_mime = FALSE) + */ + public function is_allowed_filetype($ignore_mime = FALSE) { + if ($this->allowed_types == '*') + { + return TRUE; + } + if (count($this->allowed_types) == 0 OR ! is_array($this->allowed_types)) { $this->set_error('upload_no_file_types'); return FALSE; } - + $ext = strtolower(ltrim($this->file_ext, '.')); - + if ( ! in_array($ext, $this->allowed_types)) { return FALSE; @@ -594,40 +607,39 @@ class CI_Upload { if (getimagesize($this->file_temp) === FALSE) { return FALSE; - } + } } if ($ignore_mime === TRUE) { return TRUE; } - + $mime = $this->mimes_types($ext); - + if (is_array($mime)) { if (in_array($this->file_type, $mime, TRUE)) { return TRUE; - } + } } elseif ($mime == $this->file_type) { return TRUE; } - + return FALSE; } - + // -------------------------------------------------------------------- - + /** * Verify that the file is within the allowed size * - * @access public * @return bool - */ - function is_allowed_filesize() + */ + public function is_allowed_filesize() { if ($this->max_size != 0 AND $this->file_size > $this->max_size) { @@ -638,16 +650,15 @@ class CI_Upload { return TRUE; } } - + // -------------------------------------------------------------------- - + /** * Verify that the image is within the allowed width/height * - * @access public * @return bool - */ - function is_allowed_dimensions() + */ + public function is_allowed_dimensions() { if ( ! $this->is_image()) { @@ -673,26 +684,25 @@ class CI_Upload { return TRUE; } - + // -------------------------------------------------------------------- - + /** * Validate Upload Path * * Verifies that it is a valid upload path with proper permissions. * * - * @access public * @return bool - */ - function validate_upload_path() + */ + public function validate_upload_path() { if ($this->upload_path == '') { $this->set_error('upload_no_filepath'); return FALSE; } - + if (function_exists('realpath') AND @realpath($this->upload_path) !== FALSE) { $this->upload_path = str_replace("\\", "/", realpath($this->upload_path)); @@ -713,32 +723,30 @@ class CI_Upload { $this->upload_path = preg_replace("/(.+?)\/*$/", "\\1/", $this->upload_path); return TRUE; } - + // -------------------------------------------------------------------- - + /** * Extract the file extension * - * @access public * @param string * @return string - */ - function get_extension($filename) + */ + public function get_extension($filename) { $x = explode('.', $filename); return '.'.end($x); - } - + } + // -------------------------------------------------------------------- - + /** * Clean the file name for security * - * @access public * @param string * @return string - */ - function clean_file_name($filename) + */ + public function clean_file_name($filename) { $bad = array( "<!--", @@ -756,40 +764,39 @@ class CI_Upload { "%20", "%22", "%3c", // < - "%253c", // < - "%3e", // > - "%0e", // > - "%28", // ( - "%29", // ) - "%2528", // ( - "%26", // & - "%24", // $ - "%3f", // ? - "%3b", // ; + "%253c", // < + "%3e", // > + "%0e", // > + "%28", // ( + "%29", // ) + "%2528", // ( + "%26", // & + "%24", // $ + "%3f", // ? + "%3b", // ; "%3d" // = ); - + $filename = str_replace($bad, '', $filename); return stripslashes($filename); } // -------------------------------------------------------------------- - + /** * Limit the File Name Length * - * @access public * @param string * @return string - */ - function limit_filename_length($filename, $length) + */ + public function limit_filename_length($filename, $length) { if (strlen($filename) < $length) { return $filename; } - + $ext = ''; if (strpos($filename, '.') !== FALSE) { @@ -797,12 +804,12 @@ class CI_Upload { $ext = '.'.array_pop($parts); $filename = implode('.', $parts); } - + return substr($filename, 0, ($length - strlen($ext))).$ext; } // -------------------------------------------------------------------- - + /** * Runs the file through the XSS clean function * @@ -810,59 +817,93 @@ class CI_Upload { * I'm not sure that it won't negatively affect certain files in unexpected ways, * but so far I haven't found that it causes trouble. * - * @access public * @return void - */ - function do_xss_clean() - { - $file = $this->upload_path.$this->file_name; - + */ + public function do_xss_clean() + { + $file = $this->file_temp; + if (filesize($file) == 0) { return FALSE; } + if (function_exists('memory_get_usage') && memory_get_usage() && ini_get('memory_limit') != '') + { + $current = ini_get('memory_limit') * 1024 * 1024; + + // There was a bug/behavioural change in PHP 5.2, where numbers over one million get output + // into scientific notation. number_format() ensures this number is an integer + // http://bugs.php.net/bug.php?id=43053 + + $new_memory = number_format(ceil(filesize($file) + $current), 0, '.', ''); + + ini_set('memory_limit', $new_memory); // When an integer is used, the value is measured in bytes. - PHP.net + } + + // If the file being uploaded is an image, then we should have no problem with XSS attacks (in theory), but + // IE can be fooled into mime-type detecting a malformed image as an html file, thus executing an XSS attack on anyone + // using IE who looks at the image. It does this by inspecting the first 255 bytes of an image. To get around this + // CI will itself look at the first 255 bytes of an image to determine its relative safety. This can save a lot of + // processor power and time if it is actually a clean image, as it will be in nearly all instances _except_ an + // attempted XSS attack. + + if (function_exists('getimagesize') && @getimagesize($file) !== FALSE) + { + if (($file = @fopen($file, 'rb')) === FALSE) // "b" to force binary + { + return FALSE; // Couldn't open the file, return FALSE + } + + $opening_bytes = fread($file, 256); + fclose($file); + + // These are known to throw IE into mime-type detection chaos + // <a, <body, <head, <html, <img, <plaintext, <pre, <script, <table, <title + // title is basically just in SVG, but we filter it anyhow + + if ( ! preg_match('/<(a|body|head|html|img|plaintext|pre|script|table|title)[\s>]/i', $opening_bytes)) + { + return TRUE; // its an image, no "triggers" detected in the first 256 bytes, we're good + } + } + if (($data = @file_get_contents($file)) === FALSE) { return FALSE; } - - if ( ! $fp = @fopen($file, FOPEN_READ_WRITE)) + + $CI =& get_instance(); + + if ( ! isset($CI->security)) { - return FALSE; + $CI->load->library('security'); } - $CI =& get_instance(); - $data = $CI->input->xss_clean($data); - - flock($fp, LOCK_EX); - fwrite($fp, $data); - flock($fp, LOCK_UN); - fclose($fp); + return $CI->security->xss_clean($data, TRUE); } - + // -------------------------------------------------------------------- - + /** * Set an error message * - * @access public * @param string * @return void - */ - function set_error($msg) + */ + public function set_error($msg) { - $CI =& get_instance(); + $CI =& get_instance(); $CI->lang->load('upload'); - + if (is_array($msg)) { foreach ($msg as $val) { - $msg = ($CI->lang->line($val) == FALSE) ? $val : $CI->lang->line($val); + $msg = ($CI->lang->line($val) == FALSE) ? $val : $CI->lang->line($val); $this->error_msg[] = $msg; log_message('error', $msg); - } + } } else { @@ -871,44 +912,42 @@ class CI_Upload { log_message('error', $msg); } } - + // -------------------------------------------------------------------- - + /** * Display the error message * - * @access public * @param string * @param string * @return string - */ - function display_errors($open = '<p>', $close = '</p>') + */ + public function display_errors($open = '<p>', $close = '</p>') { $str = ''; foreach ($this->error_msg as $val) { $str .= $open.$val.$close; } - + return $str; } - + // -------------------------------------------------------------------- - + /** * List of Mime Types * * This is a list of mime types. We use it to validate * the "allowed types" set by the developer * - * @access public * @param string * @return string - */ - function mimes_types($mime) + */ + public function mimes_types($mime) { global $mimes; - + if (count($this->mimes) == 0) { if (@require_once(APPPATH.'config/mimes'.EXT)) @@ -917,25 +956,24 @@ class CI_Upload { unset($mimes); } } - + return ( ! isset($this->mimes[$mime])) ? FALSE : $this->mimes[$mime]; } // -------------------------------------------------------------------- - + /** * Prep Filename * * Prevents possible script execution from Apache's handling of files multiple extensions * http://httpd.apache.org/docs/1.3/mod/mod_mime.html#multipleext * - * @access private * @param string * @return string */ - function _prep_filename($filename) + protected function _prep_filename($filename) { - if (strpos($filename, '.') === FALSE) + if (strpos($filename, '.') === FALSE OR $this->allowed_types == '*') { return $filename; } @@ -957,7 +995,7 @@ class CI_Upload { } $filename .= '.'.$ext; - + return $filename; } diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php index a7c7a7609..c62174836 100644..100755 --- a/system/libraries/User_agent.php +++ b/system/libraries/User_agent.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -29,25 +29,25 @@ class CI_User_agent { var $agent = NULL; - + var $is_browser = FALSE; var $is_robot = FALSE; var $is_mobile = FALSE; var $languages = array(); var $charsets = array(); - + var $platforms = array(); var $browsers = array(); var $mobiles = array(); var $robots = array(); - + var $platform = ''; var $browser = ''; var $version = ''; var $mobile = ''; var $robot = ''; - + /** * Constructor * @@ -55,14 +55,14 @@ class CI_User_agent { * * @access public * @return void - */ - function CI_User_agent() + */ + public function __construct() { if (isset($_SERVER['HTTP_USER_AGENT'])) { $this->agent = trim($_SERVER['HTTP_USER_AGENT']); } - + if ( ! is_null($this->agent)) { if ($this->_load_agent_file()) @@ -70,27 +70,27 @@ class CI_User_agent { $this->_compile_data(); } } - + log_message('debug', "User Agent Class Initialized"); } - + // -------------------------------------------------------------------- - + /** * Compile the User Agent Data * * @access private * @return bool - */ - function _load_agent_file() + */ + private function _load_agent_file() { if ( ! @include(APPPATH.'config/user_agents'.EXT)) { return FALSE; } - + $return = FALSE; - + if (isset($platforms)) { $this->platforms = $platforms; @@ -111,7 +111,7 @@ class CI_User_agent { unset($mobiles); $return = TRUE; } - + if (isset($robots)) { $this->robots = $robots; @@ -121,37 +121,37 @@ class CI_User_agent { return $return; } - + // -------------------------------------------------------------------- - + /** * Compile the User Agent Data * * @access private * @return bool - */ - function _compile_data() + */ + private function _compile_data() { $this->_set_platform(); - + foreach (array('_set_browser', '_set_robot', '_set_mobile') as $function) { if ($this->$function() === TRUE) { break; } - } + } } - + // -------------------------------------------------------------------- - + /** * Set the Platform * * @access private * @return mixed - */ - function _set_platform() + */ + private function _set_platform() { if (is_array($this->platforms) AND count($this->platforms) > 0) { @@ -168,19 +168,19 @@ class CI_User_agent { } // -------------------------------------------------------------------- - + /** * Set the Browser * * @access private * @return bool - */ - function _set_browser() + */ + private function _set_browser() { if (is_array($this->browsers) AND count($this->browsers) > 0) { foreach ($this->browsers as $key => $val) - { + { if (preg_match("|".preg_quote($key).".*?([0-9\.]+)|i", $this->agent, $match)) { $this->is_browser = TRUE; @@ -193,19 +193,19 @@ class CI_User_agent { } return FALSE; } - + // -------------------------------------------------------------------- - + /** * Set the Robot * * @access private * @return bool - */ - function _set_robot() + */ + private function _set_robot() { if (is_array($this->robots) AND count($this->robots) > 0) - { + { foreach ($this->robots as $key => $val) { if (preg_match("|".preg_quote($key)."|i", $this->agent)) @@ -220,17 +220,17 @@ class CI_User_agent { } // -------------------------------------------------------------------- - + /** * Set the Mobile Device * * @access private * @return bool - */ - function _set_mobile() + */ + private function _set_mobile() { if (is_array($this->mobiles) AND count($this->mobiles) > 0) - { + { foreach ($this->mobiles as $key => $val) { if (FALSE !== (strpos(strtolower($this->agent), $key))) @@ -240,261 +240,296 @@ class CI_User_agent { return TRUE; } } - } + } return FALSE; } - + // -------------------------------------------------------------------- - + /** * Set the accepted languages * * @access private * @return void - */ - function _set_languages() + */ + private function _set_languages() { if ((count($this->languages) == 0) AND isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) AND $_SERVER['HTTP_ACCEPT_LANGUAGE'] != '') { $languages = preg_replace('/(;q=[0-9\.]+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_LANGUAGE']))); - + $this->languages = explode(',', $languages); } - + if (count($this->languages) == 0) { $this->languages = array('Undefined'); - } + } } - + // -------------------------------------------------------------------- - + /** * Set the accepted character sets * * @access private * @return void - */ - function _set_charsets() - { + */ + private function _set_charsets() + { if ((count($this->charsets) == 0) AND isset($_SERVER['HTTP_ACCEPT_CHARSET']) AND $_SERVER['HTTP_ACCEPT_CHARSET'] != '') { $charsets = preg_replace('/(;q=.+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_CHARSET']))); - + $this->charsets = explode(',', $charsets); } - + if (count($this->charsets) == 0) { $this->charsets = array('Undefined'); - } + } } // -------------------------------------------------------------------- - + /** * Is Browser * * @access public * @return bool - */ - function is_browser() + */ + public function is_browser($key = NULL) { - return $this->is_browser; + if ( ! $this->is_browser) + { + return FALSE; + } + + // No need to be specific, it's a browser + if ($key === NULL) + { + return TRUE; + } + + // Check for a specific browser + return array_key_exists($key, $this->browsers) AND $this->browser === $this->browsers[$key]; } // -------------------------------------------------------------------- - + /** * Is Robot * * @access public * @return bool - */ - function is_robot() + */ + public function is_robot($key = NULL) { - return $this->is_robot; + if ( ! $this->is_robot) + { + return FALSE; + } + + // No need to be specific, it's a robot + if ($key === NULL) + { + return TRUE; + } + + // Check for a specific robot + return array_key_exists($key, $this->robots) AND $this->robot === $this->robots[$key]; } // -------------------------------------------------------------------- - + /** * Is Mobile * * @access public * @return bool - */ - function is_mobile() + */ + public function is_mobile($key = NULL) { - return $this->is_mobile; - } + if ( ! $this->is_mobile) + { + return FALSE; + } + + // No need to be specific, it's a mobile + if ($key === NULL) + { + return TRUE; + } + + // Check for a specific robot + return array_key_exists($key, $this->mobiles) AND $this->mobile === $this->mobiles[$key]; + } // -------------------------------------------------------------------- - + /** * Is this a referral from another site? * * @access public * @return bool - */ - function is_referral() + */ + public function is_referral() { - return ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '') ? FALSE : TRUE; + return ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == ''); } // -------------------------------------------------------------------- - + /** * Agent String * * @access public * @return string - */ - function agent_string() + */ + public function agent_string() { return $this->agent; } // -------------------------------------------------------------------- - + /** * Get Platform * * @access public * @return string - */ - function platform() + */ + public function platform() { return $this->platform; } // -------------------------------------------------------------------- - + /** * Get Browser Name * * @access public * @return string - */ - function browser() + */ + public function browser() { return $this->browser; } // -------------------------------------------------------------------- - + /** * Get the Browser Version * * @access public * @return string - */ - function version() + */ + public function version() { return $this->version; } // -------------------------------------------------------------------- - + /** * Get The Robot Name * * @access public * @return string - */ - function robot() + */ + public function robot() { return $this->robot; } // -------------------------------------------------------------------- - + /** * Get the Mobile Device * * @access public * @return string - */ - function mobile() + */ + public function mobile() { return $this->mobile; } - + // -------------------------------------------------------------------- - + /** * Get the referrer * * @access public * @return bool - */ - function referrer() + */ + public function referrer() { return ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '') ? '' : trim($_SERVER['HTTP_REFERER']); } // -------------------------------------------------------------------- - + /** * Get the accepted languages * * @access public * @return array - */ - function languages() + */ + public function languages() { if (count($this->languages) == 0) { $this->_set_languages(); } - + return $this->languages; } // -------------------------------------------------------------------- - + /** * Get the accepted Character Sets * * @access public * @return array - */ - function charsets() + */ + public function charsets() { if (count($this->charsets) == 0) { $this->_set_charsets(); } - + return $this->charsets; } - + // -------------------------------------------------------------------- - + /** * Test for a particular language * * @access public * @return bool - */ - function accept_lang($lang = 'en') + */ + public function accept_lang($lang = 'en') { - return (in_array(strtolower($lang), $this->languages(), TRUE)) ? TRUE : FALSE; + return (in_array(strtolower($lang), $this->languages(), TRUE)); } - + // -------------------------------------------------------------------- - + /** * Test for a particular character set * * @access public * @return bool - */ - function accept_charset($charset = 'utf-8') + */ + public function accept_charset($charset = 'utf-8') { - return (in_array(strtolower($charset), $this->charsets(), TRUE)) ? TRUE : FALSE; + return (in_array(strtolower($charset), $this->charsets(), TRUE)); } - - + } diff --git a/system/libraries/Validation.php b/system/libraries/Validation.php deleted file mode 100644 index a42b7760b..000000000 --- a/system/libraries/Validation.php +++ /dev/null @@ -1,875 +0,0 @@ -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); -/** - * CodeIgniter - * - * An open source application development framework for PHP 4.3.2 or newer - * - * @package CodeIgniter - * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. - * @license http://codeigniter.com/user_guide/license.html - * @link http://codeigniter.com - * @since Version 1.0 - * @filesource - */ - -// ------------------------------------------------------------------------ - -/** - * Validation Class - * - * @package CodeIgniter - * @subpackage Libraries - * @category Validation - * @author ExpressionEngine Dev Team - * @link http://codeigniter.com/user_guide/libraries/validation.html - */ -class CI_Validation { - - var $CI; - var $error_string = ''; - var $_error_array = array(); - var $_rules = array(); - var $_fields = array(); - var $_error_messages = array(); - var $_current_field = ''; - var $_safe_form_data = FALSE; - var $_error_prefix = '<p>'; - var $_error_suffix = '</p>'; - - - - /** - * Constructor - * - */ - function CI_Validation() - { - $this->CI =& get_instance(); - - if (function_exists('mb_internal_encoding')) - { - mb_internal_encoding($this->CI->config->item('charset')); - } - - log_message('debug', "Validation Class Initialized"); - } - - // -------------------------------------------------------------------- - - /** - * Set Fields - * - * This function takes an array of field names as input - * and generates class variables with the same name, which will - * either be blank or contain the $_POST value corresponding to it - * - * @access public - * @param string - * @param string - * @return void - */ - function set_fields($data = '', $field = '') - { - if ($data == '') - { - if (count($this->_fields) == 0) - { - return FALSE; - } - } - else - { - if ( ! is_array($data)) - { - $data = array($data => $field); - } - - if (count($data) > 0) - { - $this->_fields = $data; - } - } - - foreach($this->_fields as $key => $val) - { - $this->$key = ( ! isset($_POST[$key])) ? '' : $this->prep_for_form($_POST[$key]); - - $error = $key.'_error'; - if ( ! isset($this->$error)) - { - $this->$error = ''; - } - } - } - - // -------------------------------------------------------------------- - - /** - * Set Rules - * - * This function takes an array of field names and validation - * rules as input ad simply stores is for use later. - * - * @access public - * @param mixed - * @param string - * @return void - */ - function set_rules($data, $rules = '') - { - if ( ! is_array($data)) - { - if ($rules == '') - return; - - $data = array($data => $rules); - } - - foreach ($data as $key => $val) - { - $this->_rules[$key] = $val; - } - } - - // -------------------------------------------------------------------- - - /** - * Set Error Message - * - * Lets users set their own error messages on the fly. Note: The key - * name has to match the function name that it corresponds to. - * - * @access public - * @param string - * @param string - * @return string - */ - function set_message($lang, $val = '') - { - if ( ! is_array($lang)) - { - $lang = array($lang => $val); - } - - $this->_error_messages = array_merge($this->_error_messages, $lang); - } - - // -------------------------------------------------------------------- - - /** - * Set The Error Delimiter - * - * Permits a prefix/suffix to be added to each error message - * - * @access public - * @param string - * @param string - * @return void - */ - function set_error_delimiters($prefix = '<p>', $suffix = '</p>') - { - $this->_error_prefix = $prefix; - $this->_error_suffix = $suffix; - } - - // -------------------------------------------------------------------- - - /** - * Run the Validator - * - * This function does all the work. - * - * @access public - * @return bool - */ - function run() - { - // Do we even have any data to process? Mm? - if (count($_POST) == 0 OR count($this->_rules) == 0) - { - return FALSE; - } - - // Load the language file containing error messages - $this->CI->lang->load('validation'); - - // Cycle through the rules and test for errors - foreach ($this->_rules as $field => $rules) - { - //Explode out the rules! - $ex = explode('|', $rules); - - // Is the field required? If not, if the field is blank we'll move on to the next test - if ( ! in_array('required', $ex, TRUE)) - { - if ( ! isset($_POST[$field]) OR $_POST[$field] == '') - { - continue; - } - } - - /* - * Are we dealing with an "isset" rule? - * - * Before going further, we'll see if one of the rules - * is to check whether the item is set (typically this - * applies only to checkboxes). If so, we'll - * test for it here since there's not reason to go - * further - */ - if ( ! isset($_POST[$field])) - { - if (in_array('isset', $ex, TRUE) OR in_array('required', $ex)) - { - if ( ! isset($this->_error_messages['isset'])) - { - if (FALSE === ($line = $this->CI->lang->line('isset'))) - { - $line = 'The field was not set'; - } - } - else - { - $line = $this->_error_messages['isset']; - } - - // Build the error message - $mfield = ( ! isset($this->_fields[$field])) ? $field : $this->_fields[$field]; - $message = sprintf($line, $mfield); - - // Set the error variable. Example: $this->username_error - $error = $field.'_error'; - $this->$error = $this->_error_prefix.$message.$this->_error_suffix; - $this->_error_array[] = $message; - } - - continue; - } - - /* - * Set the current field - * - * The various prepping functions need to know the - * current field name so they can do this: - * - * $_POST[$this->_current_field] == 'bla bla'; - */ - $this->_current_field = $field; - - // Cycle through the rules! - foreach ($ex As $rule) - { - // Is the rule a callback? - $callback = FALSE; - if (substr($rule, 0, 9) == 'callback_') - { - $rule = substr($rule, 9); - $callback = TRUE; - } - - // Strip the parameter (if exists) from the rule - // Rules can contain a parameter: max_length[5] - $param = FALSE; - if (preg_match("/(.*?)\[(.*?)\]/", $rule, $match)) - { - $rule = $match[1]; - $param = $match[2]; - } - - // Call the function that corresponds to the rule - if ($callback === TRUE) - { - if ( ! method_exists($this->CI, $rule)) - { - continue; - } - - $result = $this->CI->$rule($_POST[$field], $param); - - // If the field isn't required and we just processed a callback we'll move on... - if ( ! in_array('required', $ex, TRUE) AND $result !== FALSE) - { - continue 2; - } - - } - else - { - if ( ! method_exists($this, $rule)) - { - /* - * Run the native PHP function if called for - * - * If our own wrapper function doesn't exist we see - * if a native PHP function does. Users can use - * any native PHP function call that has one param. - */ - if (function_exists($rule)) - { - $_POST[$field] = $rule($_POST[$field]); - $this->$field = $_POST[$field]; - } - - continue; - } - - $result = $this->$rule($_POST[$field], $param); - } - - // Did the rule test negatively? If so, grab the error. - if ($result === FALSE) - { - if ( ! isset($this->_error_messages[$rule])) - { - if (FALSE === ($line = $this->CI->lang->line($rule))) - { - $line = 'Unable to access an error message corresponding to your field name.'; - } - } - else - { - $line = $this->_error_messages[$rule]; - } - - // Build the error message - $mfield = ( ! isset($this->_fields[$field])) ? $field : $this->_fields[$field]; - $mparam = ( ! isset($this->_fields[$param])) ? $param : $this->_fields[$param]; - $message = sprintf($line, $mfield, $mparam); - - // Set the error variable. Example: $this->username_error - $error = $field.'_error'; - $this->$error = $this->_error_prefix.$message.$this->_error_suffix; - - // Add the error to the error array - $this->_error_array[] = $message; - continue 2; - } - } - - } - - $total_errors = count($this->_error_array); - - /* - * Recompile the class variables - * - * If any prepping functions were called the $_POST data - * might now be different then the corresponding class - * variables so we'll set them anew. - */ - if ($total_errors > 0) - { - $this->_safe_form_data = TRUE; - } - - $this->set_fields(); - - // Did we end up with any errors? - if ($total_errors == 0) - { - return TRUE; - } - - // Generate the error string - foreach ($this->_error_array as $val) - { - $this->error_string .= $this->_error_prefix.$val.$this->_error_suffix."\n"; - } - - return FALSE; - } - - // -------------------------------------------------------------------- - - /** - * Required - * - * @access public - * @param string - * @return bool - */ - function required($str) - { - if ( ! is_array($str)) - { - return (trim($str) == '') ? FALSE : TRUE; - } - else - { - return ( ! empty($str)); - } - } - - // -------------------------------------------------------------------- - - /** - * Match one field to another - * - * @access public - * @param string - * @param field - * @return bool - */ - function matches($str, $field) - { - if ( ! isset($_POST[$field])) - { - return FALSE; - } - - return ($str !== $_POST[$field]) ? FALSE : TRUE; - } - - // -------------------------------------------------------------------- - - /** - * Minimum Length - * - * @access public - * @param string - * @param value - * @return bool - */ - function min_length($str, $val) - { - if (preg_match("/[^0-9]/", $val)) - { - return FALSE; - } - - if (function_exists('mb_strlen')) - { - return (mb_strlen($str) < $val) ? FALSE : TRUE; - } - - return (strlen($str) < $val) ? FALSE : TRUE; - } - - // -------------------------------------------------------------------- - - /** - * Max Length - * - * @access public - * @param string - * @param value - * @return bool - */ - function max_length($str, $val) - { - if (preg_match("/[^0-9]/", $val)) - { - return FALSE; - } - - if (function_exists('mb_strlen')) - { - return (mb_strlen($str) > $val) ? FALSE : TRUE; - } - - return (strlen($str) > $val) ? FALSE : TRUE; - } - - // -------------------------------------------------------------------- - - /** - * Exact Length - * - * @access public - * @param string - * @param value - * @return bool - */ - function exact_length($str, $val) - { - if (preg_match("/[^0-9]/", $val)) - { - return FALSE; - } - - if (function_exists('mb_strlen')) - { - return (mb_strlen($str) != $val) ? FALSE : TRUE; - } - - return (strlen($str) != $val) ? FALSE : TRUE; - } - - // -------------------------------------------------------------------- - - /** - * Valid Email - * - * @access public - * @param string - * @return bool - */ - function valid_email($str) - { - return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE; - } - - // -------------------------------------------------------------------- - - /** - * Valid Emails - * - * @access public - * @param string - * @return bool - */ - function valid_emails($str) - { - if (strpos($str, ',') === FALSE) - { - return $this->valid_email(trim($str)); - } - - foreach(explode(',', $str) as $email) - { - if (trim($email) != '' && $this->valid_email(trim($email)) === FALSE) - { - return FALSE; - } - } - - return TRUE; - } - - // -------------------------------------------------------------------- - - /** - * Validate IP Address - * - * @access public - * @param string - * @return string - */ - function valid_ip($ip) - { - return $this->CI->input->valid_ip($ip); - } - - // -------------------------------------------------------------------- - - /** - * Alpha - * - * @access public - * @param string - * @return bool - */ - function alpha($str) - { - return ( ! preg_match("/^([a-z])+$/i", $str)) ? FALSE : TRUE; - } - - // -------------------------------------------------------------------- - - /** - * Alpha-numeric - * - * @access public - * @param string - * @return bool - */ - function alpha_numeric($str) - { - return ( ! preg_match("/^([a-z0-9])+$/i", $str)) ? FALSE : TRUE; - } - - // -------------------------------------------------------------------- - - /** - * Alpha-numeric with underscores and dashes - * - * @access public - * @param string - * @return bool - */ - function alpha_dash($str) - { - return ( ! preg_match("/^([-a-z0-9_-])+$/i", $str)) ? FALSE : TRUE; - } - - // -------------------------------------------------------------------- - - /** - * Numeric - * - * @access public - * @param string - * @return bool - */ - function numeric($str) - { - return (bool)preg_match( '/^[\-+]?[0-9]*\.?[0-9]+$/', $str); - - } - - // -------------------------------------------------------------------- - - /** - * Is Numeric - * - * @access public - * @param string - * @return bool - */ - function is_numeric($str) - { - return ( ! is_numeric($str)) ? FALSE : TRUE; - } - - // -------------------------------------------------------------------- - - /** - * Integer - * - * @access public - * @param string - * @return bool - */ - function integer($str) - { - return (bool)preg_match( '/^[\-+]?[0-9]+$/', $str); - } - - // -------------------------------------------------------------------- - - /** - * Is a Natural number (0,1,2,3, etc.) - * - * @access public - * @param string - * @return bool - */ - function is_natural($str) - { - return (bool)preg_match( '/^[0-9]+$/', $str); - } - - // -------------------------------------------------------------------- - - /** - * Is a Natural number, but not a zero (1,2,3, etc.) - * - * @access public - * @param string - * @return bool - */ - function is_natural_no_zero($str) - { - if ( ! preg_match( '/^[0-9]+$/', $str)) - { - return FALSE; - } - - if ($str == 0) - { - return FALSE; - } - - return TRUE; - } - - // -------------------------------------------------------------------- - - /** - * Valid Base64 - * - * Tests a string for characters outside of the Base64 alphabet - * as defined by RFC 2045 http://www.faqs.org/rfcs/rfc2045 - * - * @access public - * @param string - * @return bool - */ - function valid_base64($str) - { - return (bool) ! preg_match('/[^a-zA-Z0-9\/\+=]/', $str); - } - - // -------------------------------------------------------------------- - - /** - * Set Select - * - * Enables pull-down lists to be set to the value the user - * selected in the event of an error - * - * @access public - * @param string - * @param string - * @return string - */ - function set_select($field = '', $value = '') - { - if ($field == '' OR $value == '' OR ! isset($_POST[$field])) - { - return ''; - } - - if ($_POST[$field] == $value) - { - return ' selected="selected"'; - } - } - - // -------------------------------------------------------------------- - - /** - * Set Radio - * - * Enables radio buttons to be set to the value the user - * selected in the event of an error - * - * @access public - * @param string - * @param string - * @return string - */ - function set_radio($field = '', $value = '') - { - if ($field == '' OR $value == '' OR ! isset($_POST[$field])) - { - return ''; - } - - if ($_POST[$field] == $value) - { - return ' checked="checked"'; - } - } - - // -------------------------------------------------------------------- - - /** - * Set Checkbox - * - * Enables checkboxes to be set to the value the user - * selected in the event of an error - * - * @access public - * @param string - * @param string - * @return string - */ - function set_checkbox($field = '', $value = '') - { - if ($field == '' OR $value == '' OR ! isset($_POST[$field])) - { - return ''; - } - - if ($_POST[$field] == $value) - { - return ' checked="checked"'; - } - } - - // -------------------------------------------------------------------- - - /** - * Prep data for form - * - * This function allows HTML to be safely shown in a form. - * Special characters are converted. - * - * @access public - * @param string - * @return string - */ - function prep_for_form($data = '') - { - if (is_array($data)) - { - foreach ($data as $key => $val) - { - $data[$key] = $this->prep_for_form($val); - } - - return $data; - } - - if ($this->_safe_form_data == FALSE OR $data == '') - { - return $data; - } - - return str_replace(array("'", '"', '<', '>'), array("'", """, '<', '>'), stripslashes($data)); - } - - // -------------------------------------------------------------------- - - /** - * Prep URL - * - * @access public - * @param string - * @return string - */ - function prep_url($str = '') - { - if ($str == 'http://' OR $str == '') - { - $_POST[$this->_current_field] = ''; - return; - } - - if (substr($str, 0, 7) != 'http://' && substr($str, 0, 8) != 'https://') - { - $str = 'http://'.$str; - } - - $_POST[$this->_current_field] = $str; - } - - // -------------------------------------------------------------------- - - /** - * Strip Image Tags - * - * @access public - * @param string - * @return string - */ - function strip_image_tags($str) - { - $_POST[$this->_current_field] = $this->CI->input->strip_image_tags($str); - } - - // -------------------------------------------------------------------- - - /** - * XSS Clean - * - * @access public - * @param string - * @return string - */ - function xss_clean($str) - { - $_POST[$this->_current_field] = $this->CI->input->xss_clean($str); - } - - // -------------------------------------------------------------------- - - /** - * Convert PHP tags to entities - * - * @access public - * @param string - * @return string - */ - function encode_php_tags($str) - { - $_POST[$this->_current_field] = str_replace(array('<?php', '<?PHP', '<?', '?>'), array('<?php', '<?PHP', '<?', '?>'), $str); - } - -} -// END Validation Class - -/* End of file Validation.php */ -/* Location: ./system/libraries/Validation.php */
\ No newline at end of file diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index fe5562fef..9cf307cc0 100644..100755 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -14,7 +14,7 @@ */ if ( ! function_exists('xml_parser_create')) -{ +{ show_error('Your PHP installation does not support XML'); } @@ -32,60 +32,61 @@ if ( ! function_exists('xml_parser_create')) */ class CI_Xmlrpc { - var $debug = FALSE; // Debugging on or off + var $debug = FALSE; // Debugging on or off var $xmlrpcI4 = 'i4'; var $xmlrpcInt = 'int'; var $xmlrpcBoolean = 'boolean'; - var $xmlrpcDouble = 'double'; + var $xmlrpcDouble = 'double'; var $xmlrpcString = 'string'; var $xmlrpcDateTime = 'dateTime.iso8601'; var $xmlrpcBase64 = 'base64'; var $xmlrpcArray = 'array'; var $xmlrpcStruct = 'struct'; - + var $xmlrpcTypes = array(); var $valid_parents = array(); var $xmlrpcerr = array(); // Response numbers var $xmlrpcstr = array(); // Response strings - + var $xmlrpc_defencoding = 'UTF-8'; var $xmlrpcName = 'XML-RPC for CodeIgniter'; var $xmlrpcVersion = '1.1'; var $xmlrpcerruser = 800; // Start of user errors var $xmlrpcerrxml = 100; // Start of XML Parse errors var $xmlrpc_backslash = ''; // formulate backslashes for escaping regexp - + var $client; var $method; var $data; var $message = ''; - var $error = ''; // Error string for request + var $error = ''; // Error string for request var $result; var $response = array(); // Response from remote server + var $xss_clean = TRUE; //------------------------------------- // VALUES THAT MULTIPLE CLASSES NEED //------------------------------------- - function CI_Xmlrpc ($config = array()) + public function __construct($config = array()) { - $this->xmlrpcName = $this->xmlrpcName; + $this->xmlrpcName = $this->xmlrpcName; $this->xmlrpc_backslash = chr(92).chr(92); - + // Types for info sent back and forth $this->xmlrpcTypes = array( - $this->xmlrpcI4 => '1', - $this->xmlrpcInt => '1', - $this->xmlrpcBoolean => '1', - $this->xmlrpcString => '1', - $this->xmlrpcDouble => '1', - $this->xmlrpcDateTime => '1', - $this->xmlrpcBase64 => '1', - $this->xmlrpcArray => '2', - $this->xmlrpcStruct => '3' + $this->xmlrpcI4 => '1', + $this->xmlrpcInt => '1', + $this->xmlrpcBoolean => '1', + $this->xmlrpcString => '1', + $this->xmlrpcDouble => '1', + $this->xmlrpcDateTime => '1', + $this->xmlrpcBase64 => '1', + $this->xmlrpcArray => '2', + $this->xmlrpcStruct => '3' ); - + // Array of Valid Parents for Various XML-RPC elements $this->valid_parents = array('BOOLEAN' => array('VALUE'), 'I4' => array('VALUE'), @@ -105,13 +106,13 @@ class CI_Xmlrpc { 'FAULT' => array('METHODRESPONSE'), 'VALUE' => array('MEMBER', 'DATA', 'PARAM', 'FAULT') ); - - + + // XML-RPC Responses $this->xmlrpcerr['unknown_method'] = '1'; $this->xmlrpcstr['unknown_method'] = 'This is not a known method for this XML-RPC Server'; $this->xmlrpcerr['invalid_return'] = '2'; - $this->xmlrpcstr['invalid_return'] = 'The XML data receieved was either invalid or not in the correct form for XML-RPC. Turn on debugging to examine the XML data further.'; + $this->xmlrpcstr['invalid_return'] = 'The XML data received was either invalid or not in the correct form for XML-RPC. Turn on debugging to examine the XML data further.'; $this->xmlrpcerr['incorrect_params'] = '3'; $this->xmlrpcstr['incorrect_params'] = 'Incorrect parameters were passed to method'; $this->xmlrpcerr['introspect_unknown'] = '4'; @@ -120,13 +121,13 @@ class CI_Xmlrpc { $this->xmlrpcstr['http_error'] = "Did not receive a '200 OK' response from remote server."; $this->xmlrpcerr['no_data'] = '6'; $this->xmlrpcstr['no_data'] ='No data received from server.'; - + $this->initialize($config); - + log_message('debug', "XML-RPC Class Initialized"); } - - + + //------------------------------------- // Initialize Prefs //------------------------------------- @@ -139,13 +140,13 @@ class CI_Xmlrpc { { if (isset($this->$key)) { - $this->$key = $val; + $this->$key = $val; } } } } // END - + //------------------------------------- // Take URL and parse it //------------------------------------- @@ -156,20 +157,20 @@ class CI_Xmlrpc { { $url = "http://".$url; } - + $parts = parse_url($url); - + $path = ( ! isset($parts['path'])) ? '/' : $parts['path']; - + if (isset($parts['query']) && $parts['query'] != '') { $path .= '?'.$parts['query']; - } - + } + $this->client = new XML_RPC_Client($path, $parts['host'], $port); } // END - + //------------------------------------- // Set Timeout //------------------------------------- @@ -182,7 +183,7 @@ class CI_Xmlrpc { } } // END - + //------------------------------------- // Set Methods //------------------------------------- @@ -192,7 +193,7 @@ class CI_Xmlrpc { $this->method = $function; } // END - + //------------------------------------- // Take Array of Data and Create Objects //------------------------------------- @@ -203,17 +204,17 @@ class CI_Xmlrpc { { // Send Error } - + $this->data = array(); - + foreach($incoming as $key => $value) { $this->data[$key] = $this->values_parsing($value); } } // END - - + + //------------------------------------- // Set Debug //------------------------------------- @@ -222,14 +223,14 @@ class CI_Xmlrpc { { $this->debug = ($flag == TRUE) ? TRUE : FALSE; } - + //------------------------------------- // Values Parsing //------------------------------------- function values_parsing($value, $return = FALSE) { - if (is_array($value) && isset($value['0'])) + if (is_array($value) && array_key_exists(0, $value)) { if ( ! isset($value['1']) OR (! isset($this->xmlrpcTypes[$value['1']]))) { @@ -248,7 +249,7 @@ class CI_Xmlrpc { { $value['0'][$k] = $this->values_parsing($value['0'][$k], TRUE); } - + $temp = new XML_RPC_Values($value['0'], $value['1']); } else @@ -274,7 +275,7 @@ class CI_Xmlrpc { { $this->message = new XML_RPC_Message($this->method,$this->data); $this->message->debug = $this->debug; - + if ( ! $this->result = $this->client->send($this->message)) { $this->error = $this->result->errstr; @@ -285,13 +286,13 @@ class CI_Xmlrpc { $this->error = $this->result->errstr; return FALSE; } - + $this->response = $this->result->decode(); - + return TRUE; } // END - + //------------------------------------- // Returns Error //------------------------------------- @@ -301,7 +302,7 @@ class CI_Xmlrpc { return $this->error; } // END - + //------------------------------------- // Returns Remote Server Response //------------------------------------- @@ -311,37 +312,37 @@ class CI_Xmlrpc { return $this->response; } // END - + //------------------------------------- // Sends an Error Message for Server Request //------------------------------------- - + function send_error_message($number, $message) { return new XML_RPC_Response('0',$number, $message); } // END - - + + //------------------------------------- // Send Response for Server Request //------------------------------------- - + function send_response($response) { // $response should be array of values, which will be parsed // based on their data and type into a valid group of XML-RPC values - + $response = $this->values_parsing($response); - + return new XML_RPC_Response($response); } // END - + } // END XML_RPC Class - - + + /** * XML-RPC Client class * @@ -359,15 +360,15 @@ class XML_RPC_Client extends CI_Xmlrpc var $timeout = 5; var $no_multicall = false; - function XML_RPC_Client($path, $server, $port=80) + public function __construct($path, $server, $port=80) { - parent::CI_Xmlrpc(); - + parent::__construct(); + $this->port = $port; $this->server = $server; $this->path = $path; } - + function send($msg) { if (is_array($msg)) @@ -381,22 +382,22 @@ class XML_RPC_Client extends CI_Xmlrpc } function sendPayload($msg) - { + { $fp = @fsockopen($this->server, $this->port,$this->errno, $this->errstr, $this->timeout); - + if ( ! is_resource($fp)) { error_log($this->xmlrpcstr['http_error']); $r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'],$this->xmlrpcstr['http_error']); return $r; } - + if(empty($msg->payload)) { // $msg = XML_RPC_Messages $msg->createPayload(); } - + $r = "\r\n"; $op = "POST {$this->path} HTTP/1.0$r"; $op .= "Host: {$this->server}$r"; @@ -404,7 +405,7 @@ class XML_RPC_Client extends CI_Xmlrpc $op .= "User-Agent: {$this->xmlrpcName}$r"; $op .= "Content-Length: ".strlen($msg->payload). "$r$r"; $op .= $msg->payload; - + if ( ! fputs($fp, $op, strlen($op))) { @@ -433,9 +434,10 @@ class XML_RPC_Response var $errno = 0; var $errstr = ''; var $headers = array(); + var $xss_clean = TRUE; - function XML_RPC_Response($val, $code = 0, $fstr = '') - { + public function __construct($val, $code = 0, $fstr = '') + { if ($code != 0) { // error @@ -468,7 +470,7 @@ class XML_RPC_Response { return $this->val; } - + function prepare_response() { $result = "<methodResponse>\n"; @@ -498,11 +500,16 @@ class XML_RPC_Response $result .= "\n</methodResponse>"; return $result; } - + function decode($array=FALSE) { $CI =& get_instance(); + if ($this->xss_clean && ! isset($CI->security)) + { + $CI->load->library('security'); + } + if ($array !== FALSE && is_array($array)) { while (list($key) = each($array)) @@ -513,31 +520,31 @@ class XML_RPC_Response } else { - $array[$key] = $CI->input->xss_clean($array[$key]); + $array[$key] = ($this->xss_clean) ? $CI->security->xss_clean($array[$key]) : $array[$key]; } } - + $result = $array; } else { $result = $this->xmlrpc_decoder($this->val); - + if (is_array($result)) { $result = $this->decode($result); } else { - $result = $CI->input->xss_clean($result); + $result = ($this->xss_clean) ? $CI->security->xss_clean($result) : $result; } } - + return $result; } - - + + //------------------------------------- // XML-RPC Object to PHP Types //------------------------------------- @@ -555,7 +562,7 @@ class XML_RPC_Response reset($xmlrpc_val->me); list($a,$b) = each($xmlrpc_val->me); $size = count($b); - + $arr = array(); for($i = 0; $i < $size; $i++) @@ -576,8 +583,8 @@ class XML_RPC_Response return $arr; } } - - + + //------------------------------------- // ISO-8601 time to server or UTC time //------------------------------------- @@ -595,7 +602,7 @@ class XML_RPC_Response } return $t; } - + } // End Response Class @@ -612,12 +619,12 @@ class XML_RPC_Message extends CI_Xmlrpc var $payload; var $method_name; var $params = array(); - var $xh = array(); + var $xh = array(); - function XML_RPC_Message($method, $pars=0) + public function __construct($method, $pars=0) { - parent::CI_Xmlrpc(); - + parent::__construct(); + $this->method_name = $method; if (is_array($pars) && count($pars) > 0) { @@ -628,51 +635,51 @@ class XML_RPC_Message extends CI_Xmlrpc } } } - + //------------------------------------- // Create Payload to Send //------------------------------------- - + function createPayload() { $this->payload = "<?xml version=\"1.0\"?".">\r\n<methodCall>\r\n"; $this->payload .= '<methodName>' . $this->method_name . "</methodName>\r\n"; $this->payload .= "<params>\r\n"; - + for($i=0; $i<count($this->params); $i++) { // $p = XML_RPC_Values $p = $this->params[$i]; $this->payload .= "<param>\r\n".$p->serialize_class()."</param>\r\n"; } - + $this->payload .= "</params>\r\n</methodCall>\r\n"; } - + //------------------------------------- // Parse External XML-RPC Server's Response //------------------------------------- - + function parseResponse($fp) { $data = ''; - + while($datum = fread($fp, 4096)) { $data .= $datum; } - + //------------------------------------- // DISPLAY HTTP CONTENT for DEBUGGING //------------------------------------- - + if ($this->debug === TRUE) { echo "<pre>"; echo "---DATA---\n" . htmlspecialchars($data) . "\n---END DATA---\n\n"; echo "</pre>"; } - + //------------------------------------- // Check for data //------------------------------------- @@ -683,32 +690,32 @@ class XML_RPC_Message extends CI_Xmlrpc $r = new XML_RPC_Response(0, $this->xmlrpcerr['no_data'], $this->xmlrpcstr['no_data']); return $r; } - - + + //------------------------------------- // Check for HTTP 200 Response //------------------------------------- - + if (strncmp($data, 'HTTP', 4) == 0 && ! preg_match('/^HTTP\/[0-9\.]+ 200 /', $data)) { $errstr= substr($data, 0, strpos($data, "\n")-1); $r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error']. ' (' . $errstr . ')'); return $r; } - + //------------------------------------- // Create and Set Up XML Parser //------------------------------------- - + $parser = xml_parser_create($this->xmlrpc_defencoding); - $this->xh[$parser] = array(); - $this->xh[$parser]['isf'] = 0; - $this->xh[$parser]['ac'] = ''; - $this->xh[$parser]['headers'] = array(); - $this->xh[$parser]['stack'] = array(); - $this->xh[$parser]['valuestack'] = array(); - $this->xh[$parser]['isf_reason'] = 0; + $this->xh[$parser] = array(); + $this->xh[$parser]['isf'] = 0; + $this->xh[$parser]['ac'] = ''; + $this->xh[$parser]['headers'] = array(); + $this->xh[$parser]['stack'] = array(); + $this->xh[$parser]['valuestack'] = array(); + $this->xh[$parser]['isf_reason'] = 0; xml_set_object($parser, $this); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true); @@ -720,7 +727,7 @@ class XML_RPC_Message extends CI_Xmlrpc //------------------------------------- // GET HEADERS //------------------------------------- - + $lines = explode("\r\n", $data); while (($line = array_shift($lines))) { @@ -731,11 +738,11 @@ class XML_RPC_Message extends CI_Xmlrpc $this->xh[$parser]['headers'][] = $line; } $data = implode("\r\n", $lines); - - + + //------------------------------------- // PARSE XML DATA - //------------------------------------- + //------------------------------------- if ( ! xml_parse($parser, $data, count($data))) { @@ -748,11 +755,11 @@ class XML_RPC_Message extends CI_Xmlrpc return $r; } xml_parser_free($parser); - + // --------------------------------------- // Got Ourselves Some Badness, It Seems // --------------------------------------- - + if ($this->xh[$parser]['isf'] > 1) { if ($this->debug === TRUE) @@ -761,7 +768,7 @@ class XML_RPC_Message extends CI_Xmlrpc echo $this->xh[$parser]['isf_reason']; echo "---Invalid Return---\n\n"; } - + $r = new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'],$this->xmlrpcstr['invalid_return'].' '.$this->xh[$parser]['isf_reason']); return $r; } @@ -770,15 +777,15 @@ class XML_RPC_Message extends CI_Xmlrpc $r = new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'],$this->xmlrpcstr['invalid_return'].' '.$this->xh[$parser]['isf_reason']); return $r; } - + //------------------------------------- // DISPLAY XML CONTENT for DEBUGGING - //------------------------------------- - + //------------------------------------- + if ($this->debug === TRUE) { echo "<pre>"; - + if (count($this->xh[$parser]['headers'] > 0)) { echo "---HEADERS---\n"; @@ -788,20 +795,20 @@ class XML_RPC_Message extends CI_Xmlrpc } echo "---END HEADERS---\n\n"; } - + echo "---DATA---\n" . htmlspecialchars($data) . "\n---END DATA---\n\n"; - + echo "---PARSED---\n" ; var_dump($this->xh[$parser]['value']); echo "\n---END PARSED---</pre>"; } - + //------------------------------------- // SEND RESPONSE //------------------------------------- - + $v = $this->xh[$parser]['value']; - + if ($this->xh[$parser]['isf']) { $errno_v = $v->me['struct']['faultCode']; @@ -824,11 +831,11 @@ class XML_RPC_Message extends CI_Xmlrpc $r->headers = $this->xh[$parser]['headers']; return $r; } - + // ------------------------------------ // Begin Return Message Parsing section // ------------------------------------ - + // quick explanation of components: // ac - used to accumulate values // isf - used to indicate a fault @@ -847,9 +854,9 @@ class XML_RPC_Message extends CI_Xmlrpc { // If invalid nesting, then return if ($this->xh[$the_parser]['isf'] > 1) return; - + // Evaluate and check for correct nesting of XML elements - + if (count($this->xh[$the_parser]['stack']) == 0) { if ($name != 'METHODRESPONSE' && $name != 'METHODCALL') @@ -869,16 +876,16 @@ class XML_RPC_Message extends CI_Xmlrpc return; } } - + switch($name) { case 'STRUCT': case 'ARRAY': // Creates array for child elements - + $cur_val = array('value' => array(), 'type' => $name); - + array_unshift($this->xh[$the_parser]['valuestack'], $cur_val); break; case 'METHODNAME': @@ -910,13 +917,13 @@ class XML_RPC_Message extends CI_Xmlrpc $this->xh[$the_parser]['isf_reason'] = "'Twas a $name element following a ".$this->xh[$the_parser]['vt']." element inside a single value"; return; } - + $this->xh[$the_parser]['ac'] = ''; break; case 'MEMBER': // Set name of <member> to nothing to prevent errors later if no <name> is found $this->xh[$the_parser]['valuestack'][0]['name'] = ''; - + // Set NULL value to check to see if value passed for this param/member $this->xh[$the_parser]['value'] = null; break; @@ -932,7 +939,7 @@ class XML_RPC_Message extends CI_Xmlrpc $this->xh[$the_parser]['isf_reason'] = "Invalid XML-RPC element found: $name"; break; } - + // Add current element name to stack, to allow validation of nesting array_unshift($this->xh[$the_parser]['stack'], $name); @@ -948,14 +955,14 @@ class XML_RPC_Message extends CI_Xmlrpc function closing_tag($the_parser, $name) { if ($this->xh[$the_parser]['isf'] > 1) return; - + // Remove current element from stack and set variable // NOTE: If the XML validates, then we do not have to worry about // the opening and closing of elements. Nesting is checked on the opening // tag so we be safe there as well. - + $curr_elem = array_shift($this->xh[$the_parser]['stack']); - + switch($name) { case 'STRUCT': @@ -975,7 +982,7 @@ class XML_RPC_Message extends CI_Xmlrpc case 'DATETIME.ISO8601': case 'BASE64': $this->xh[$the_parser]['vt'] = strtolower($name); - + if ($name == 'STRING') { $this->xh[$the_parser]['value'] = $this->xh[$the_parser]['ac']; @@ -1037,10 +1044,10 @@ class XML_RPC_Message extends CI_Xmlrpc $this->xh[$the_parser]['value'] = $this->xh[$the_parser]['ac']; $this->xh[$the_parser]['vt'] = $this->xmlrpcString; } - + // build the XML-RPC value out of the data received, and substitute it $temp = new XML_RPC_Values($this->xh[$the_parser]['value'], $this->xh[$the_parser]['vt']); - + if (count($this->xh[$the_parser]['valuestack']) && $this->xh[$the_parser]['valuestack'][0]['type'] == 'ARRAY') { // Array @@ -1054,7 +1061,7 @@ class XML_RPC_Message extends CI_Xmlrpc break; case 'MEMBER': $this->xh[$the_parser]['ac']=''; - + // If value add to array in the stack for the last element built if ($this->xh[$the_parser]['value']) { @@ -1092,7 +1099,7 @@ class XML_RPC_Message extends CI_Xmlrpc function character_data($the_parser, $data) { if ($this->xh[$the_parser]['isf'] > 1) return; // XML Fault found already - + // If a value has not been found if ($this->xh[$the_parser]['lv'] != 3) { @@ -1100,22 +1107,27 @@ class XML_RPC_Message extends CI_Xmlrpc { $this->xh[$the_parser]['lv'] = 2; // Found a value } - + if( ! @isset($this->xh[$the_parser]['ac'])) { $this->xh[$the_parser]['ac'] = ''; } - + $this->xh[$the_parser]['ac'] .= $data; } } - - + + function addParam($par) { $this->params[]=$par; } - + function output_parameters($array=FALSE) { - $CI =& get_instance(); + $CI =& get_instance(); + + if ($this->xss_clean && ! isset($CI->security)) + { + $CI->load->library('security'); + } if ($array !== FALSE && is_array($array)) { @@ -1127,35 +1139,37 @@ class XML_RPC_Message extends CI_Xmlrpc } else { - $array[$key] = $CI->input->xss_clean($array[$key]); + // 'bits' is for the MetaWeblog API image bits + // @todo - this needs to be made more general purpose + $array[$key] = ($key == 'bits' OR $this->xss_clean == FALSE) ? $array[$key] : $CI->security->xss_clean($array[$key]); } } - + $parameters = $array; } else { $parameters = array(); - + for ($i = 0; $i < count($this->params); $i++) { $a_param = $this->decode_message($this->params[$i]); - + if (is_array($a_param)) { $parameters[] = $this->output_parameters($a_param); } else { - $parameters[] = $CI->input->xss_clean($a_param); + $parameters[] = ($this->xss_clean) ? $CI->security->xss_clean($a_param) : $a_param; } - } + } } - + return $parameters; } - - + + function decode_message($param) { $kind = $param->kindOf(); @@ -1168,31 +1182,31 @@ class XML_RPC_Message extends CI_Xmlrpc { reset($param->me); list($a,$b) = each($param->me); - + $arr = array(); for($i = 0; $i < count($b); $i++) { $arr[] = $this->decode_message($param->me['array'][$i]); } - + return $arr; } elseif($kind == 'struct') { reset($param->me['struct']); - + $arr = array(); while(list($key,$value) = each($param->me['struct'])) { $arr[$key] = $this->decode_message($value); } - + return $arr; } } - + } // End XML_RPC_Messages class @@ -1206,17 +1220,17 @@ class XML_RPC_Message extends CI_Xmlrpc */ class XML_RPC_Values extends CI_Xmlrpc { - var $me = array(); + var $me = array(); var $mytype = 0; - function XML_RPC_Values($val=-1, $type='') - { - parent::CI_Xmlrpc(); - + public function __construct($val=-1, $type='') + { + parent::__construct(); + if ($val != -1 OR $type != '') { $type = $type == '' ? 'string' : $type; - + if ($this->xmlrpcTypes[$type] == 1) { $this->addScalar($val,$type); @@ -1235,13 +1249,13 @@ class XML_RPC_Values extends CI_Xmlrpc function addScalar($val, $type='string') { $typeof = $this->xmlrpcTypes[$type]; - + if ($this->mytype==1) { echo '<strong>XML_RPC_Values</strong>: scalar can have only one value<br />'; return 0; } - + if ($typeof != 1) { echo '<strong>XML_RPC_Values</strong>: not a scalar type (${typeof})<br />'; @@ -1322,7 +1336,7 @@ class XML_RPC_Values extends CI_Xmlrpc function serializedata($typ, $val) { $rs = ''; - + switch($this->xmlrpcTypes[$typ]) { case 3: @@ -1378,12 +1392,12 @@ class XML_RPC_Values extends CI_Xmlrpc { $ar = $o->me; reset($ar); - + list($typ, $val) = each($ar); $rs = "<value>\n".$this->serializedata($typ, $val)."</value>\n"; return $rs; } - + function scalarval() { reset($this->me); @@ -1395,11 +1409,11 @@ class XML_RPC_Values extends CI_Xmlrpc //------------------------------------- // Encode time in ISO-8601 form. //------------------------------------- - + // Useful for sending time in XML-RPC function iso8601_encode($time, $utc=0) - { + { if ($utc == 1) { $t = strftime("%Y%m%dT%H:%M:%S", $time); @@ -1413,7 +1427,7 @@ class XML_RPC_Values extends CI_Xmlrpc } return $t; } - + } // END XML_RPC_Values Class diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php index 429ab8472..6bedfe324 100644..100755 --- a/system/libraries/Xmlrpcs.php +++ b/system/libraries/Xmlrpcs.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -14,7 +14,7 @@ */ if ( ! function_exists('xml_parser_create')) -{ +{ show_error('Your PHP installation does not support XML'); } @@ -36,57 +36,60 @@ if ( ! class_exists('CI_Xmlrpc')) */ class CI_Xmlrpcs extends CI_Xmlrpc { - var $methods = array(); //array of methods mapped to function names and signatures + var $methods = array(); //array of methods mapped to function names and signatures var $debug_msg = ''; // Debug Message - var $system_methods = array(); // XML RPC Server methods + var $system_methods = array(); // XML RPC Server methods var $controller_obj; var $object = FALSE; - - - //------------------------------------- - // Constructor, more or less - //------------------------------------- - function CI_Xmlrpcs($config=array()) - { - parent::CI_Xmlrpc(); + /** + * Constructor + */ + public function __construct($config=array()) + { + parent::__construct(); $this->set_system_methods(); - + if (isset($config['functions']) && is_array($config['functions'])) { $this->methods = array_merge($this->methods, $config['functions']); } - + log_message('debug', "XML-RPC Server Class Initialized"); } - + //------------------------------------- // Initialize Prefs and Serve //------------------------------------- - + function initialize($config=array()) - { + { if (isset($config['functions']) && is_array($config['functions'])) { $this->methods = array_merge($this->methods, $config['functions']); } - + if (isset($config['debug'])) { $this->debug = $config['debug']; } - + if (isset($config['object']) && is_object($config['object'])) { $this->object = $config['object']; } + + if (isset($config['xss_clean'])) + { + $this->xss_clean = $config['xss_clean']; + } } - + //------------------------------------- // Setting of System Methods //------------------------------------- - + function set_system_methods () { $this->methods = array( @@ -113,14 +116,14 @@ class CI_Xmlrpcs extends CI_Xmlrpc //------------------------------------- // Main Server Function //------------------------------------- - + function serve() { $r = $this->parseRequest(); $payload = '<?xml version="1.0" encoding="'.$this->xmlrpc_defencoding.'"?'.'>'."\n"; $payload .= $this->debug_msg; $payload .= $r->prepare_response(); - + header("Content-Type: text/xml"); header("Content-Length: ".strlen($payload)); exit($payload); @@ -129,7 +132,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc //------------------------------------- // Add Method to Class //------------------------------------- - + function add_to_map($methodname,$function,$sig,$doc) { $this->methods[$methodname] = array( @@ -143,11 +146,11 @@ class CI_Xmlrpcs extends CI_Xmlrpc //------------------------------------- // Parse Server Request //------------------------------------- - + function parseRequest($data='') { global $HTTP_RAW_POST_DATA; - + //------------------------------------- // Get Data //------------------------------------- @@ -160,10 +163,10 @@ class CI_Xmlrpcs extends CI_Xmlrpc //------------------------------------- // Set up XML Parser //------------------------------------- - + $parser = xml_parser_create($this->xmlrpc_defencoding); $parser_object = new XML_RPC_Message("filler"); - + $parser_object->xh[$parser] = array(); $parser_object->xh[$parser]['isf'] = 0; $parser_object->xh[$parser]['isf_reason'] = ''; @@ -177,12 +180,12 @@ class CI_Xmlrpcs extends CI_Xmlrpc xml_set_element_handler($parser, 'open_tag', 'closing_tag'); xml_set_character_data_handler($parser, 'character_data'); //xml_set_default_handler($parser, 'default_handler'); - - + + //------------------------------------- // PARSE + PROCESS XML DATA - //------------------------------------- - + //------------------------------------- + if ( ! xml_parse($parser, $data, 1)) { // return XML error as a faultCode @@ -200,69 +203,74 @@ class CI_Xmlrpcs extends CI_Xmlrpc else { xml_parser_free($parser); - + $m = new XML_RPC_Message($parser_object->xh[$parser]['method']); $plist=''; - + for($i=0; $i < count($parser_object->xh[$parser]['params']); $i++) { if ($this->debug === TRUE) { $plist .= "$i - " . print_r(get_object_vars($parser_object->xh[$parser]['params'][$i]), TRUE). ";\n"; } - + $m->addParam($parser_object->xh[$parser]['params'][$i]); } - + if ($this->debug === TRUE) { echo "<pre>"; echo "---PLIST---\n" . $plist . "\n---PLIST END---\n\n"; echo "</pre>"; } - + $r = $this->_execute($m); } - + //------------------------------------- // SET DEBUGGING MESSAGE - //------------------------------------- - + //------------------------------------- + if ($this->debug === TRUE) { $this->debug_msg = "<!-- DEBUG INFO:\n\n".$plist."\n END DEBUG-->\n"; } - + return $r; } //------------------------------------- // Executes the Method //------------------------------------- - + function _execute($m) { $methName = $m->method_name; - + // Check to see if it is a system call $system_call = (strncmp($methName, 'system', 5) == 0) ? TRUE : FALSE; - + + if ($this->xss_clean == FALSE) + { + $m->xss_clean = FALSE; + } + //------------------------------------- // Valid Method //------------------------------------- - + if ( ! isset($this->methods[$methName]['function'])) { return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']); } - + //------------------------------------- // Check for Method (and Object) //------------------------------------- - + $method_parts = explode(".", $this->methods[$methName]['function']); $objectCall = (isset($method_parts['1']) && $method_parts['1'] != "") ? TRUE : FALSE; - + if ($system_call === TRUE) { if ( ! is_callable(array($this,$method_parts['1']))) @@ -281,30 +289,30 @@ class CI_Xmlrpcs extends CI_Xmlrpc return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']); } } - + //------------------------------------- // Checking Methods Signature //------------------------------------- - + if (isset($this->methods[$methName]['signature'])) { $sig = $this->methods[$methName]['signature']; for($i=0; $i<count($sig); $i++) { $current_sig = $sig[$i]; - + if (count($current_sig) == count($m->params)+1) { for($n=0; $n < count($m->params); $n++) { $p = $m->params[$n]; $pt = ($p->kindOf() == 'scalar') ? $p->scalarval() : $p->kindOf(); - + if ($pt != $current_sig[$n+1]) { $pno = $n+1; $wanted = $current_sig[$n+1]; - + return new XML_RPC_Response(0, $this->xmlrpcerr['incorrect_params'], $this->xmlrpcstr['incorrect_params'] . @@ -344,22 +352,22 @@ class CI_Xmlrpcs extends CI_Xmlrpc return call_user_func($this->methods[$methName]['function'], $m); } } - - + + //------------------------------------- // Server Function: List Methods //------------------------------------- - + function listMethods($m) { $v = new XML_RPC_Values(); $output = array(); - + foreach($this->methods as $key => $value) { $output[] = new XML_RPC_Values($key, 'string'); } - + foreach($this->system_methods as $key => $value) { $output[]= new XML_RPC_Values($key, 'string'); @@ -368,23 +376,23 @@ class CI_Xmlrpcs extends CI_Xmlrpc $v->addArray($output); return new XML_RPC_Response($v); } - + //------------------------------------- // Server Function: Return Signature for Method //------------------------------------- - + function methodSignature($m) { $parameters = $m->output_parameters(); $method_name = $parameters[0]; - + if (isset($this->methods[$method_name])) { if ($this->methods[$method_name]['signature']) { $sigs = array(); $signature = $this->methods[$method_name]['signature']; - + for($i=0; $i < count($signature); $i++) { $cursig = array(); @@ -408,20 +416,20 @@ class CI_Xmlrpcs extends CI_Xmlrpc } return $r; } - + //------------------------------------- // Server Function: Doc String for Method //------------------------------------- - + function methodHelp($m) { $parameters = $m->output_parameters(); $method_name = $parameters[0]; - + if (isset($this->methods[$method_name])) { $docstring = isset($this->methods[$method_name]['docstring']) ? $this->methods[$method_name]['docstring'] : ''; - + return new XML_RPC_Response(new XML_RPC_Values($docstring, 'string')); } else @@ -438,7 +446,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc { // Disabled return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']); - + $parameters = $m->output_parameters(); $calls = $parameters[0]; @@ -447,15 +455,15 @@ class CI_Xmlrpcs extends CI_Xmlrpc foreach ($calls as $value) { //$attempt = $this->_execute(new XML_RPC_Message($value[0], $value[1])); - + $m = new XML_RPC_Message($value[0]); $plist=''; - + for($i=0; $i < count($value[1]); $i++) { $m->addParam(new XML_RPC_Values($value[1][$i], 'string')); } - + $attempt = $this->_execute($m); if ($attempt->faultCode() != 0) @@ -468,8 +476,8 @@ class CI_Xmlrpcs extends CI_Xmlrpc return new XML_RPC_Response(new XML_RPC_Values($result, 'array')); } - - + + //------------------------------------- // Multi-call Function: Error Handling //------------------------------------- @@ -478,28 +486,28 @@ class CI_Xmlrpcs extends CI_Xmlrpc { $str = is_string($err) ? $this->xmlrpcstr["multicall_${err}"] : $err->faultString(); $code = is_string($err) ? $this->xmlrpcerr["multicall_${err}"] : $err->faultCode(); - + $struct['faultCode'] = new XML_RPC_Values($code, 'int'); $struct['faultString'] = new XML_RPC_Values($str, 'string'); - + return new XML_RPC_Values($struct, 'struct'); } - - + + //------------------------------------- // Multi-call Function: Processes method //------------------------------------- - + function do_multicall($call) { if ($call->kindOf() != 'struct') return $this->multicall_error('notstruct'); elseif ( ! $methName = $call->me['struct']['methodName']) return $this->multicall_error('nomethod'); - + list($scalar_type,$scalar_value)=each($methName->me); $scalar_type = $scalar_type == $this->xmlrpcI4 ? $this->xmlrpcInt : $scalar_type; - + if ($methName->kindOf() != 'scalar' OR $scalar_type != 'string') return $this->multicall_error('notstring'); elseif ($scalar_value == 'system.multicall') @@ -508,7 +516,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc return $this->multicall_error('noparams'); elseif ($params->kindOf() != 'array') return $this->multicall_error('notarray'); - + list($a,$b)=each($params->me); $numParams = count($b); @@ -526,8 +534,8 @@ class CI_Xmlrpcs extends CI_Xmlrpc } return new XML_RPC_Values(array($result->value()), 'array'); - } - + } + } // END XML_RPC_Server class diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index af50ca1cb..80633c708 100644..100755 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -32,15 +32,21 @@ */ class CI_Zip { - var $zipdata = ''; - var $directory = ''; - var $entries = 0; - var $file_num = 0; + var $zipdata = ''; + var $directory = ''; + var $entries = 0; + var $file_num = 0; var $offset = 0; + var $now; - function CI_Zip() + /** + * Constructor + */ + public function __construct() { log_message('debug', "Zip Compression Class Initialized"); + + $this->now = time(); } // -------------------------------------------------------------------- @@ -63,25 +69,50 @@ class CI_Zip { $dir .= '/'; } - $this->_add_dir($dir); + $dir_time = $this->_get_mod_time($dir); + + $this->_add_dir($dir, $dir_time['file_mtime'], $dir_time['file_mdate']); } } // -------------------------------------------------------------------- /** + * Get file/directory modification time + * + * If this is a newly created file/dir, we will set the time to 'now' + * + * @param string path to file + * @return array filemtime/filemdate + */ + function _get_mod_time($dir) + { + // filemtime() will return false, but it does raise an error. + $date = (@filemtime($dir)) ? filemtime($dir) : getdate($this->now); + + $time['file_mtime'] = ($date['hours'] << 11) + ($date['minutes'] << 5) + $date['seconds'] / 2; + $time['file_mdate'] = (($date['year'] - 1980) << 9) + ($date['mon'] << 5) + $date['mday']; + + return $time; + } + + // -------------------------------------------------------------------- + + /** * Add Directory * * @access private * @param string the directory name * @return void */ - function _add_dir($dir) + function _add_dir($dir, $file_mtime, $file_mdate) { $dir = str_replace("\\", "/", $dir); $this->zipdata .= - "\x50\x4b\x03\x04\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00" + "\x50\x4b\x03\x04\x0a\x00\x00\x00\x00\x00" + .pack('v', $file_mtime) + .pack('v', $file_mdate) .pack('V', 0) // crc32 .pack('V', 0) // compressed filesize .pack('V', 0) // uncompressed filesize @@ -94,7 +125,9 @@ class CI_Zip { .pack('V', 0); // uncompressed filesize $this->directory .= - "\x50\x4b\x01\x02\x00\x00\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00" + "\x50\x4b\x01\x02\x00\x00\x0a\x00\x00\x00\x00\x00" + .pack('v', $file_mtime) + .pack('v', $file_mdate) .pack('V',0) // crc32 .pack('V',0) // compressed filesize .pack('V',0) // uncompressed filesize @@ -110,7 +143,7 @@ class CI_Zip { $this->offset = strlen($this->zipdata); $this->entries++; } - + // -------------------------------------------------------------------- /** @@ -124,19 +157,23 @@ class CI_Zip { * @param mixed * @param string * @return void - */ + */ function add_data($filepath, $data = NULL) { if (is_array($filepath)) { foreach ($filepath as $path => $data) { - $this->_add_data($path, $data); + $file_data = $this->_get_mod_time($path); + + $this->_add_data($path, $data, $file_data['file_mtime'], $file_data['file_mdate']); } } else { - $this->_add_data($filepath, $data); + $file_data = $this->_get_mod_time($filepath); + + $this->_add_data($filepath, $data, $file_data['file_mtime'], $file_data['file_mdate']); } } @@ -149,8 +186,8 @@ class CI_Zip { * @param string the file name/path * @param string the data to be encoded * @return void - */ - function _add_data($filepath, $data) + */ + function _add_data($filepath, $data, $file_mtime, $file_mdate) { $filepath = str_replace("\\", "/", $filepath); @@ -162,7 +199,9 @@ class CI_Zip { $compressed_size = strlen($gzdata); $this->zipdata .= - "\x50\x4b\x03\x04\x14\x00\x00\x00\x08\x00\x00\x00\x00\x00" + "\x50\x4b\x03\x04\x14\x00\x00\x00\x08\x00" + .pack('v', $file_mtime) + .pack('v', $file_mdate) .pack('V', $crc32) .pack('V', $compressed_size) .pack('V', $uncompressed_size) @@ -172,7 +211,9 @@ class CI_Zip { .$gzdata; // "file data" segment $this->directory .= - "\x50\x4b\x01\x02\x00\x00\x14\x00\x00\x00\x08\x00\x00\x00\x00\x00" + "\x50\x4b\x01\x02\x00\x00\x14\x00\x00\x00\x08\x00" + .pack('v', $file_mtime) + .pack('v', $file_mdate) .pack('V', $crc32) .pack('V', $compressed_size) .pack('V', $uncompressed_size) @@ -189,7 +230,7 @@ class CI_Zip { $this->entries++; $this->file_num++; } - + // -------------------------------------------------------------------- /** @@ -197,7 +238,7 @@ class CI_Zip { * * @access public * @return bool - */ + */ function read_file($path, $preserve_filepath = FALSE) { if ( ! file_exists($path)) @@ -208,7 +249,7 @@ class CI_Zip { if (FALSE !== ($data = file_get_contents($path))) { $name = str_replace("\\", "/", $path); - + if ($preserve_filepath === FALSE) { $name = preg_replace("|.*/(.+)|", "\\1", $name); @@ -221,7 +262,7 @@ class CI_Zip { } // ------------------------------------------------------------------------ - + /** * Read a directory and add it to the zip. * @@ -232,27 +273,48 @@ class CI_Zip { * @access public * @param string path to source * @return bool - */ - function read_dir($path) - { - if ($fp = @opendir($path)) + */ + function read_dir($path, $preserve_filepath = TRUE, $root_path = NULL) + { + if ( ! $fp = @opendir($path)) { - while (FALSE !== ($file = readdir($fp))) + return FALSE; + } + + // Set the original directory root for child dir's to use as relative + if ($root_path === NULL) + { + $root_path = dirname($path).'/'; + } + + while (FALSE !== ($file = readdir($fp))) + { + if(substr($file, 0, 1) == '.') { - if (@is_dir($path.$file) && substr($file, 0, 1) != '.') - { - $this->read_dir($path.$file."/"); - } - elseif (substr($file, 0, 1) != ".") + continue; + } + + if (@is_dir($path.$file)) + { + $this->read_dir($path.$file."/", $preserve_filepath, $root_path); + } + else + { + if (FALSE !== ($data = file_get_contents($path.$file))) { - if (FALSE !== ($data = file_get_contents($path.$file))) - { - $this->add_data(str_replace("\\", "/", $path).$file, $data); + $name = str_replace("\\", "/", $path); + + if ($preserve_filepath === FALSE) + { + $name = str_replace($root_path, '', $name); } + + $this->add_data($name.$file, $data); } } - return TRUE; } + + return TRUE; } // -------------------------------------------------------------------- @@ -262,7 +324,7 @@ class CI_Zip { * * @access public * @return binary string - */ + */ function get_zip() { // Is there any data to return? @@ -281,7 +343,7 @@ class CI_Zip { return $zip_data; } - + // -------------------------------------------------------------------- /** @@ -292,7 +354,7 @@ class CI_Zip { * @access public * @param string the file name * @return bool - */ + */ function archive($filepath) { if ( ! ($fp = @fopen($filepath, FOPEN_WRITE_CREATE_DESTRUCTIVE))) @@ -300,12 +362,12 @@ class CI_Zip { return FALSE; } - flock($fp, LOCK_EX); + flock($fp, LOCK_EX); fwrite($fp, $this->get_zip()); flock($fp, LOCK_UN); fclose($fp); - return TRUE; + return TRUE; } // -------------------------------------------------------------------- @@ -325,11 +387,13 @@ class CI_Zip { $filename .= '.zip'; } - $zip_content =& $this->get_zip(); - $CI =& get_instance(); $CI->load->helper('download'); + $get_zip = $this->get_zip(); + + $zip_content =& $get_zip; + force_download($filename, $zip_content); } @@ -343,7 +407,7 @@ class CI_Zip { * * @access public * @return void - */ + */ function clear_data() { $this->zipdata = ''; @@ -352,7 +416,7 @@ class CI_Zip { $this->file_num = 0; $this->offset = 0; } - + } /* End of file Zip.php */ diff --git a/system/libraries/index.html b/system/libraries/index.html index c942a79ce..c942a79ce 100644..100755 --- a/system/libraries/index.html +++ b/system/libraries/index.html diff --git a/system/libraries/javascript/Jquery.php b/system/libraries/javascript/Jquery.php new file mode 100755 index 000000000..baab83d25 --- /dev/null +++ b/system/libraries/javascript/Jquery.php @@ -0,0 +1,1071 @@ +<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); + +/** + * CodeIgniter + * + * An open source application development framework for PHP 4.3.2 or newer + * + * @package CodeIgniter + * @author ExpressionEngine Dev Team + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. + * @license http://www.codeigniter.com/user_guide/license.html + * @link http://www.codeigniter.com + * @since Version 1.0 + * @filesource + */ + +/** + * Jquery Class + * + * @package CodeIgniter + * @subpackage Libraries + * @author ExpressionEngine Dev Team + * @category Loader + * @link http://www.codeigniter.com/user_guide/libraries/javascript.html + */ + +class CI_Jquery extends CI_Javascript { + + var $_javascript_folder = 'js'; + var $jquery_code_for_load = array(); + var $jquery_code_for_compile = array(); + var $jquery_corner_active = FALSE; + var $jquery_table_sorter_active = FALSE; + var $jquery_table_sorter_pager_active = FALSE; + var $jquery_ajax_img = ''; + + public function __construct($params) + { + $this->CI =& get_instance(); + extract($params); + + if ($autoload === TRUE) + { + $this->script(); + } + + log_message('debug', "Jquery Class Initialized"); + } + + // -------------------------------------------------------------------- + // Event Code + // -------------------------------------------------------------------- + + /** + * Blur + * + * Outputs a jQuery blur event + * + * @access private + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function _blur($element = 'this', $js = '') + { + return $this->_add_event($element, $js, 'blur'); + } + + // -------------------------------------------------------------------- + + /** + * Change + * + * Outputs a jQuery change event + * + * @access private + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function _change($element = 'this', $js = '') + { + return $this->_add_event($element, $js, 'change'); + } + + // -------------------------------------------------------------------- + + /** + * Click + * + * Outputs a jQuery click event + * + * @access private + * @param string The element to attach the event to + * @param string The code to execute + * @param boolean whether or not to return false + * @return string + */ + function _click($element = 'this', $js = '', $ret_false = TRUE) + { + if ( ! is_array($js)) + { + $js = array($js); + } + + if ($ret_false) + { + $js[] = "return false;"; + } + + return $this->_add_event($element, $js, 'click'); + } + + // -------------------------------------------------------------------- + + /** + * Double Click + * + * Outputs a jQuery dblclick event + * + * @access private + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function _dblclick($element = 'this', $js = '') + { + return $this->_add_event($element, $js, 'dblclick'); + } + + // -------------------------------------------------------------------- + + /** + * Error + * + * Outputs a jQuery error event + * + * @access private + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function _error($element = 'this', $js = '') + { + return $this->_add_event($element, $js, 'error'); + } + + // -------------------------------------------------------------------- + + /** + * Focus + * + * Outputs a jQuery focus event + * + * @access private + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function _focus($element = 'this', $js = '') + { + return $this->_add_event($element, $js, 'focus'); + } + + // -------------------------------------------------------------------- + + /** + * Hover + * + * Outputs a jQuery hover event + * + * @access private + * @param string - element + * @param string - Javascript code for mouse over + * @param string - Javascript code for mouse out + * @return string + */ + function _hover($element = 'this', $over, $out) + { + $event = "\n\t$(" . $this->_prep_element($element) . ").hover(\n\t\tfunction()\n\t\t{\n\t\t\t{$over}\n\t\t}, \n\t\tfunction()\n\t\t{\n\t\t\t{$out}\n\t\t});\n"; + + $this->jquery_code_for_compile[] = $event; + + return $event; + } + + // -------------------------------------------------------------------- + + /** + * Keydown + * + * Outputs a jQuery keydown event + * + * @access private + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function _keydown($element = 'this', $js = '') + { + return $this->_add_event($element, $js, 'keydown'); + } + + // -------------------------------------------------------------------- + + /** + * Keyup + * + * Outputs a jQuery keydown event + * + * @access private + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function _keyup($element = 'this', $js = '') + { + return $this->_add_event($element, $js, 'keyup'); + } + + // -------------------------------------------------------------------- + + /** + * Load + * + * Outputs a jQuery load event + * + * @access private + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function _load($element = 'this', $js = '') + { + return $this->_add_event($element, $js, 'load'); + } + + // -------------------------------------------------------------------- + + /** + * Mousedown + * + * Outputs a jQuery mousedown event + * + * @access private + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function _mousedown($element = 'this', $js = '') + { + return $this->_add_event($element, $js, 'mousedown'); + } + + // -------------------------------------------------------------------- + + /** + * Mouse Out + * + * Outputs a jQuery mouseout event + * + * @access private + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function _mouseout($element = 'this', $js = '') + { + return $this->_add_event($element, $js, 'mouseout'); + } + + // -------------------------------------------------------------------- + + /** + * Mouse Over + * + * Outputs a jQuery mouseover event + * + * @access private + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function _mouseover($element = 'this', $js = '') + { + return $this->_add_event($element, $js, 'mouseover'); + } + + // -------------------------------------------------------------------- + + /** + * Mouseup + * + * Outputs a jQuery mouseup event + * + * @access private + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function _mouseup($element = 'this', $js = '') + { + return $this->_add_event($element, $js, 'mouseup'); + } + + // -------------------------------------------------------------------- + + /** + * Output + * + * Outputs script directly + * + * @access private + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function _output($array_js = '') + { + if ( ! is_array($array_js)) + { + $array_js = array($array_js); + } + + foreach ($array_js as $js) + { + $this->jquery_code_for_compile[] = "\t$js\n"; + } + } + + // -------------------------------------------------------------------- + + /** + * Resize + * + * Outputs a jQuery resize event + * + * @access private + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function _resize($element = 'this', $js = '') + { + return $this->_add_event($element, $js, 'resize'); + } + + // -------------------------------------------------------------------- + + /** + * Scroll + * + * Outputs a jQuery scroll event + * + * @access private + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function _scroll($element = 'this', $js = '') + { + return $this->_add_event($element, $js, 'scroll'); + } + + // -------------------------------------------------------------------- + + /** + * Unload + * + * Outputs a jQuery unload event + * + * @access private + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + function _unload($element = 'this', $js = '') + { + return $this->_add_event($element, $js, 'unload'); + } + + // -------------------------------------------------------------------- + // Effects + // -------------------------------------------------------------------- + + /** + * Add Class + * + * Outputs a jQuery addClass event + * + * @access private + * @param string - element + * @return string + */ + function _addClass($element = 'this', $class='') + { + $element = $this->_prep_element($element); + $str = "$({$element}).addClass(\"$class\");"; + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Animate + * + * Outputs a jQuery animate event + * + * @access private + * @param string - element + * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds + * @param string - Javascript callback function + * @return string + */ + function _animate($element = 'this', $params = array(), $speed = '', $extra = '') + { + $element = $this->_prep_element($element); + $speed = $this->_validate_speed($speed); + + $animations = "\t\t\t"; + + foreach ($params as $param=>$value) + { + $animations .= $param.': \''.$value.'\', '; + } + + $animations = substr($animations, 0, -2); // remove the last ", " + + if ($speed != '') + { + $speed = ', '.$speed; + } + + if ($extra != '') + { + $extra = ', '.$extra; + } + + $str = "$({$element}).animate({\n$animations\n\t\t}".$speed.$extra.");"; + + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Fade In + * + * Outputs a jQuery hide event + * + * @access private + * @param string - element + * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds + * @param string - Javascript callback function + * @return string + */ + function _fadeIn($element = 'this', $speed = '', $callback = '') + { + $element = $this->_prep_element($element); + $speed = $this->_validate_speed($speed); + + if ($callback != '') + { + $callback = ", function(){\n{$callback}\n}"; + } + + $str = "$({$element}).fadeIn({$speed}{$callback});"; + + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Fade Out + * + * Outputs a jQuery hide event + * + * @access private + * @param string - element + * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds + * @param string - Javascript callback function + * @return string + */ + function _fadeOut($element = 'this', $speed = '', $callback = '') + { + $element = $this->_prep_element($element); + $speed = $this->_validate_speed($speed); + + if ($callback != '') + { + $callback = ", function(){\n{$callback}\n}"; + } + + $str = "$({$element}).fadeOut({$speed}{$callback});"; + + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Hide + * + * Outputs a jQuery hide action + * + * @access private + * @param string - element + * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds + * @param string - Javascript callback function + * @return string + */ + function _hide($element = 'this', $speed = '', $callback = '') + { + $element = $this->_prep_element($element); + $speed = $this->_validate_speed($speed); + + if ($callback != '') + { + $callback = ", function(){\n{$callback}\n}"; + } + + $str = "$({$element}).hide({$speed}{$callback});"; + + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Remove Class + * + * Outputs a jQuery remove class event + * + * @access private + * @param string - element + * @return string + */ + function _removeClass($element = 'this', $class='') + { + $element = $this->_prep_element($element); + $str = "$({$element}).removeClass(\"$class\");"; + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Slide Up + * + * Outputs a jQuery slideUp event + * + * @access private + * @param string - element + * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds + * @param string - Javascript callback function + * @return string + */ + function _slideUp($element = 'this', $speed = '', $callback = '') + { + $element = $this->_prep_element($element); + $speed = $this->_validate_speed($speed); + + if ($callback != '') + { + $callback = ", function(){\n{$callback}\n}"; + } + + $str = "$({$element}).slideUp({$speed}{$callback});"; + + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Slide Down + * + * Outputs a jQuery slideDown event + * + * @access private + * @param string - element + * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds + * @param string - Javascript callback function + * @return string + */ + function _slideDown($element = 'this', $speed = '', $callback = '') + { + $element = $this->_prep_element($element); + $speed = $this->_validate_speed($speed); + + if ($callback != '') + { + $callback = ", function(){\n{$callback}\n}"; + } + + $str = "$({$element}).slideDown({$speed}{$callback});"; + + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Slide Toggle + * + * Outputs a jQuery slideToggle event + * + * @access public + * @param string - element + * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds + * @param string - Javascript callback function + * @return string + */ + function _slideToggle($element = 'this', $speed = '', $callback = '') + { + $element = $this->_prep_element($element); + $speed = $this->_validate_speed($speed); + + if ($callback != '') + { + $callback = ", function(){\n{$callback}\n}"; + } + + $str = "$({$element}).slideToggle({$speed}{$callback});"; + + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Toggle + * + * Outputs a jQuery toggle event + * + * @access private + * @param string - element + * @return string + */ + function _toggle($element = 'this') + { + $element = $this->_prep_element($element); + $str = "$({$element}).toggle();"; + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Toggle Class + * + * Outputs a jQuery toggle class event + * + * @access private + * @param string - element + * @return string + */ + function _toggleClass($element = 'this', $class='') + { + $element = $this->_prep_element($element); + $str = "$({$element}).toggleClass(\"$class\");"; + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Show + * + * Outputs a jQuery show event + * + * @access private + * @param string - element + * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds + * @param string - Javascript callback function + * @return string + */ + function _show($element = 'this', $speed = '', $callback = '') + { + $element = $this->_prep_element($element); + $speed = $this->_validate_speed($speed); + + if ($callback != '') + { + $callback = ", function(){\n{$callback}\n}"; + } + + $str = "$({$element}).show({$speed}{$callback});"; + + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Updater + * + * An Ajax call that populates the designated DOM node with + * returned content + * + * @access private + * @param string The element to attach the event to + * @param string the controller to run the call against + * @param string optional parameters + * @return string + */ + + function _updater($container = 'this', $controller, $options = '') + { + $container = $this->_prep_element($container); + + $controller = (strpos('://', $controller) === FALSE) ? $controller : $this->CI->config->site_url($controller); + + // ajaxStart and ajaxStop are better choices here... but this is a stop gap + if ($this->CI->config->item('javascript_ajax_img') == '') + { + $loading_notifier = "Loading..."; + } + else + { + $loading_notifier = '<img src=\'' . $this->CI->config->slash_item('base_url') . $this->CI->config->item('javascript_ajax_img') . '\' alt=\'Loading\' />'; + } + + $updater = "$($container).empty();\n"; // anything that was in... get it out + $updater .= "\t\t$($container).prepend(\"$loading_notifier\");\n"; // to replace with an image + + $request_options = ''; + if ($options != '') + { + $request_options .= ", {"; + $request_options .= (is_array($options)) ? "'".implode("', '", $options)."'" : "'".str_replace(":", "':'", $options)."'"; + $request_options .= "}"; + } + + $updater .= "\t\t$($container).load('$controller'$request_options);"; + return $updater; + } + + + // -------------------------------------------------------------------- + // Pre-written handy stuff + // -------------------------------------------------------------------- + + /** + * Zebra tables + * + * @access private + * @param string table name + * @param string plugin location + * @return string + */ + function _zebraTables($class = '', $odd = 'odd', $hover = '') + { + $class = ($class != '') ? '.'.$class : ''; + + $zebra = "\t\$(\"table{$class} tbody tr:nth-child(even)\").addClass(\"{$odd}\");"; + + $this->jquery_code_for_compile[] = $zebra; + + if ($hover != '') + { + $hover = $this->hover("table{$class} tbody tr", "$(this).addClass('hover');", "$(this).removeClass('hover');"); + } + + return $zebra; + } + + + + // -------------------------------------------------------------------- + // Plugins + // -------------------------------------------------------------------- + + /** + * Corner Plugin + * + * http://www.malsup.com/jquery/corner/ + * + * @access public + * @param string target + * @return string + */ + function corner($element = '', $corner_style = '') + { + // may want to make this configurable down the road + $corner_location = '/plugins/jquery.corner.js'; + + if ($corner_style != '') + { + $corner_style = '"'.$corner_style.'"'; + } + + return "$(" . $this->_prep_element($element) . ").corner(".$corner_style.");"; + } + + // -------------------------------------------------------------------- + + /** + * modal window + * + * Load a thickbox modal window + * + * @access public + * @return void + */ + function modal($src, $relative = FALSE) + { + $this->jquery_code_for_load[] = $this->external($src, $relative); + } + + // -------------------------------------------------------------------- + + /** + * Effect + * + * Load an Effect library + * + * @access public + * @return void + */ + function effect($src, $relative = FALSE) + { + $this->jquery_code_for_load[] = $this->external($src, $relative); + } + + // -------------------------------------------------------------------- + + /** + * Plugin + * + * Load a plugin library + * + * @access public + * @return void + */ + function plugin($src, $relative = FALSE) + { + $this->jquery_code_for_load[] = $this->external($src, $relative); + } + + // -------------------------------------------------------------------- + + /** + * UI + * + * Load a user interface library + * + * @access public + * @return void + */ + function ui($src, $relative = FALSE) + { + $this->jquery_code_for_load[] = $this->external($src, $relative); + } + // -------------------------------------------------------------------- + + /** + * Sortable + * + * Creates a jQuery sortable + * + * @access public + * @return void + */ + function sortable($element, $options = array()) + { + + if (count($options) > 0) + { + $sort_options = array(); + foreach ($options as $k=>$v) + { + $sort_options[] = "\n\t\t".$k.': '.$v.""; + } + $sort_options = implode(",", $sort_options); + } + else + { + $sort_options = ''; + } + + return "$(" . $this->_prep_element($element) . ").sortable({".$sort_options."\n\t});"; + } + + // -------------------------------------------------------------------- + + /** + * Table Sorter Plugin + * + * @access public + * @param string table name + * @param string plugin location + * @return string + */ + function tablesorter($table = '', $options = '') + { + $this->jquery_code_for_compile[] = "\t$(" . $this->_prep_element($table) . ").tablesorter($options);\n"; + } + + // -------------------------------------------------------------------- + // Class functions + // -------------------------------------------------------------------- + + /** + * Add Event + * + * Constructs the syntax for an event, and adds to into the array for compilation + * + * @access private + * @param string The element to attach the event to + * @param string The code to execute + * @param string The event to pass + * @return string + */ + function _add_event($element, $js, $event) + { + if (is_array($js)) + { + $js = implode("\n\t\t", $js); + + } + + $event = "\n\t$(" . $this->_prep_element($element) . ").{$event}(function(){\n\t\t{$js}\n\t});\n"; + $this->jquery_code_for_compile[] = $event; + return $event; + } + + // -------------------------------------------------------------------- + + /** + * Compile + * + * As events are specified, they are stored in an array + * This funciton compiles them all for output on a page + * + * @access private + * @return string + */ + function _compile($view_var = 'script_foot', $script_tags = TRUE) + { + // External references + $external_scripts = implode('', $this->jquery_code_for_load); + $this->CI->load->vars(array('library_src' => $external_scripts)); + + if (count($this->jquery_code_for_compile) == 0 ) + { + // no inline references, let's just return + return; + } + + // Inline references + $script = '$(document).ready(function() {' . "\n"; + $script .= implode('', $this->jquery_code_for_compile); + $script .= '});'; + + $output = ($script_tags === FALSE) ? $script : $this->inline($script); + + $this->CI->load->vars(array($view_var => $output)); + + } + + // -------------------------------------------------------------------- + + /** + * Clear Compile + * + * Clears the array of script events collected for output + * + * @access public + * @return void + */ + function _clear_compile() + { + $this->jquery_code_for_compile = array(); + } + + // -------------------------------------------------------------------- + + /** + * Document Ready + * + * A wrapper for writing document.ready() + * + * @access private + * @return string + */ + function _document_ready($js) + { + if ( ! is_array($js)) + { + $js = array ($js); + + } + + foreach ($js as $script) + { + $this->jquery_code_for_compile[] = $script; + } + } + + // -------------------------------------------------------------------- + + /** + * Script Tag + * + * Outputs the script tag that loads the jquery.js file into an HTML document + * + * @access public + * @param string + * @return string + */ + function script($library_src = '', $relative = FALSE) + { + $library_src = $this->external($library_src, $relative); + $this->jquery_code_for_load[] = $library_src; + return $library_src; + } + + // -------------------------------------------------------------------- + + /** + * Prep Element + * + * Puts HTML element in quotes for use in jQuery code + * unless the supplied element is the Javascript 'this' + * object, in which case no quotes are added + * + * @access public + * @param string + * @return string + */ + function _prep_element($element) + { + if ($element != 'this') + { + $element = '"'.$element.'"'; + } + + return $element; + } + + // -------------------------------------------------------------------- + + /** + * Validate Speed + * + * Ensures the speed parameter is valid for jQuery + * + * @access private + * @param string + * @return string + */ + function _validate_speed($speed) + { + if (in_array($speed, array('slow', 'normal', 'fast'))) + { + $speed = '"'.$speed.'"'; + } + elseif (preg_match("/[^0-9]/", $speed)) + { + $speed = ''; + } + + return $speed; + } + +} + +/* End of file Jquery.php */ +/* Location: ./system/libraries/Jquery.php */
\ No newline at end of file diff --git a/system/plugins/captcha_pi.php b/system/plugins/captcha_pi.php deleted file mode 100644 index 77f29f8b9..000000000 --- a/system/plugins/captcha_pi.php +++ /dev/null @@ -1,356 +0,0 @@ -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); -/** - * CodeIgniter - * - * An open source application development framework for PHP 4.3.2 or newer - * - * @package CodeIgniter - * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. - * @license http://codeigniter.com/user_guide/license.html - * @link http://codeigniter.com - * @since Version 1.0 - * @filesource - */ - -// ------------------------------------------------------------------------ - -/* -Instructions: - -Load the plugin using: - - $this->load->plugin('captcha'); - -Once loaded you can generate a captcha like this: - - $vals = array( - 'word' => 'Random word', - 'img_path' => './captcha/', - 'img_url' => 'http://example.com/captcha/', - 'font_path' => './system/fonts/texb.ttf', - 'img_width' => '150', - 'img_height' => 30, - 'expiration' => 7200 - ); - - $cap = create_captcha($vals); - echo $cap['image']; - - -NOTES: - - The captcha function requires the GD image library. - - Only the img_path and img_url are required. - - If a "word" is not supplied, the function will generate a random - ASCII string. You might put together your own word library that - you can draw randomly from. - - If you do not specify a path to a TRUE TYPE font, the native ugly GD - font will be used. - - The "captcha" folder must be writable (666, or 777) - - The "expiration" (in seconds) signifies how long an image will - remain in the captcha folder before it will be deleted. The default - is two hours. - -RETURNED DATA - -The create_captcha() function returns an associative array with this data: - - [array] - ( - 'image' => IMAGE TAG - 'time' => TIMESTAMP (in microtime) - 'word' => CAPTCHA WORD - ) - -The "image" is the actual image tag: -<img src="http://example.com/captcha/12345.jpg" width="140" height="50" /> - -The "time" is the micro timestamp used as the image name without the file -extension. It will be a number like this: 1139612155.3422 - -The "word" is the word that appears in the captcha image, which if not -supplied to the function, will be a random string. - - -ADDING A DATABASE - -In order for the captcha function to prevent someone from posting, you will need -to add the information returned from create_captcha() function to your database. -Then, when the data from the form is submitted by the user you will need to verify -that the data exists in the database and has not expired. - -Here is a table prototype: - - CREATE TABLE captcha ( - captcha_id bigint(13) unsigned NOT NULL auto_increment, - captcha_time int(10) unsigned NOT NULL, - ip_address varchar(16) default '0' NOT NULL, - word varchar(20) NOT NULL, - PRIMARY KEY `captcha_id` (`captcha_id`), - KEY `word` (`word`) - ) - - -Here is an example of usage with a DB. - -On the page where the captcha will be shown you'll have something like this: - - $this->load->plugin('captcha'); - $vals = array( - 'img_path' => './captcha/', - 'img_url' => 'http://example.com/captcha/' - ); - - $cap = create_captcha($vals); - - $data = array( - 'captcha_id' => '', - 'captcha_time' => $cap['time'], - 'ip_address' => $this->input->ip_address(), - 'word' => $cap['word'] - ); - - $query = $this->db->insert_string('captcha', $data); - $this->db->query($query); - - echo 'Submit the word you see below:'; - echo $cap['image']; - echo '<input type="text" name="captcha" value="" />'; - - -Then, on the page that accepts the submission you'll have something like this: - - // First, delete old captchas - $expiration = time()-7200; // Two hour limit - $DB->query("DELETE FROM captcha WHERE captcha_time < ".$expiration); - - // Then see if a captcha exists: - $sql = "SELECT COUNT(*) AS count FROM captcha WHERE word = ? AND ip_address = ? AND date > ?"; - $binds = array($_POST['captcha'], $this->input->ip_address(), $expiration); - $query = $this->db->query($sql, $binds); - $row = $query->row(); - - if ($row->count == 0) - { - echo "You must submit the word that appears in the image"; - } - -*/ - - - -/** -|========================================================== -| Create Captcha -|========================================================== -| -*/ -function create_captcha($data = '', $img_path = '', $img_url = '', $font_path = '') -{ - $defaults = array('word' => '', 'img_path' => '', 'img_url' => '', 'img_width' => '150', 'img_height' => '30', 'font_path' => '', 'expiration' => 7200); - - foreach ($defaults as $key => $val) - { - if ( ! is_array($data)) - { - if ( ! isset($$key) OR $$key == '') - { - $$key = $val; - } - } - else - { - $$key = ( ! isset($data[$key])) ? $val : $data[$key]; - } - } - - if ($img_path == '' OR $img_url == '') - { - return FALSE; - } - - if ( ! @is_dir($img_path)) - { - return FALSE; - } - - if ( ! is_really_writable($img_path)) - { - return FALSE; - } - - if ( ! extension_loaded('gd')) - { - return FALSE; - } - - // ----------------------------------- - // Remove old images - // ----------------------------------- - - list($usec, $sec) = explode(" ", microtime()); - $now = ((float)$usec + (float)$sec); - - $current_dir = @opendir($img_path); - - while($filename = @readdir($current_dir)) - { - if ($filename != "." and $filename != ".." and $filename != "index.html") - { - $name = str_replace(".jpg", "", $filename); - - if (($name + $expiration) < $now) - { - @unlink($img_path.$filename); - } - } - } - - @closedir($current_dir); - - // ----------------------------------- - // Do we have a "word" yet? - // ----------------------------------- - - if ($word == '') - { - $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; - - $str = ''; - for ($i = 0; $i < 8; $i++) - { - $str .= substr($pool, mt_rand(0, strlen($pool) -1), 1); - } - - $word = $str; - } - - // ----------------------------------- - // Determine angle and position - // ----------------------------------- - - $length = strlen($word); - $angle = ($length >= 6) ? rand(-($length-6), ($length-6)) : 0; - $x_axis = rand(6, (360/$length)-16); - $y_axis = ($angle >= 0 ) ? rand($img_height, $img_width) : rand(6, $img_height); - - // ----------------------------------- - // Create image - // ----------------------------------- - - // PHP.net recommends imagecreatetruecolor(), but it isn't always available - if (function_exists('imagecreatetruecolor')) - { - $im = imagecreatetruecolor($img_width, $img_height); - } - else - { - $im = imagecreate($img_width, $img_height); - } - - // ----------------------------------- - // Assign colors - // ----------------------------------- - - $bg_color = imagecolorallocate ($im, 255, 255, 255); - $border_color = imagecolorallocate ($im, 153, 102, 102); - $text_color = imagecolorallocate ($im, 204, 153, 153); - $grid_color = imagecolorallocate($im, 255, 182, 182); - $shadow_color = imagecolorallocate($im, 255, 240, 240); - - // ----------------------------------- - // Create the rectangle - // ----------------------------------- - - ImageFilledRectangle($im, 0, 0, $img_width, $img_height, $bg_color); - - // ----------------------------------- - // Create the spiral pattern - // ----------------------------------- - - $theta = 1; - $thetac = 7; - $radius = 16; - $circles = 20; - $points = 32; - - for ($i = 0; $i < ($circles * $points) - 1; $i++) - { - $theta = $theta + $thetac; - $rad = $radius * ($i / $points ); - $x = ($rad * cos($theta)) + $x_axis; - $y = ($rad * sin($theta)) + $y_axis; - $theta = $theta + $thetac; - $rad1 = $radius * (($i + 1) / $points); - $x1 = ($rad1 * cos($theta)) + $x_axis; - $y1 = ($rad1 * sin($theta )) + $y_axis; - imageline($im, $x, $y, $x1, $y1, $grid_color); - $theta = $theta - $thetac; - } - - // ----------------------------------- - // Write the text - // ----------------------------------- - - $use_font = ($font_path != '' AND file_exists($font_path) AND function_exists('imagettftext')) ? TRUE : FALSE; - - if ($use_font == FALSE) - { - $font_size = 5; - $x = rand(0, $img_width/($length/3)); - $y = 0; - } - else - { - $font_size = 16; - $x = rand(0, $img_width/($length/1.5)); - $y = $font_size+2; - } - - for ($i = 0; $i < strlen($word); $i++) - { - if ($use_font == FALSE) - { - $y = rand(0 , $img_height/2); - imagestring($im, $font_size, $x, $y, substr($word, $i, 1), $text_color); - $x += ($font_size*2); - } - else - { - $y = rand($img_height/2, $img_height-3); - imagettftext($im, $font_size, $angle, $x, $y, $text_color, $font_path, substr($word, $i, 1)); - $x += $font_size; - } - } - - - // ----------------------------------- - // Create the border - // ----------------------------------- - - imagerectangle($im, 0, 0, $img_width-1, $img_height-1, $border_color); - - // ----------------------------------- - // Generate the image - // ----------------------------------- - - $img_name = $now.'.jpg'; - - ImageJPEG($im, $img_path.$img_name); - - $img = "<img src=\"$img_url$img_name\" width=\"$img_width\" height=\"$img_height\" style=\"border:0;\" alt=\" \" />"; - - ImageDestroy($im); - - return array('word' => $word, 'time' => $now, 'image' => $img); -} - - -/* End of file captcha_pi.php */ -/* Location: ./system/plugins/captcha_pi.php */
\ No newline at end of file diff --git a/system/plugins/js_calendar_pi.php b/system/plugins/js_calendar_pi.php deleted file mode 100644 index 3c304fd17..000000000 --- a/system/plugins/js_calendar_pi.php +++ /dev/null @@ -1,629 +0,0 @@ -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); -/** - * CodeIgniter - * - * An open source application development framework for PHP 4.3.2 or newer - * - * @package CodeIgniter - * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. - * @license http://codeigniter.com/user_guide/license.html - * @link http://codeigniter.com - * @since Version 1.0 - * @filesource - */ - -// ------------------------------------------------------------------------ - -/* -Instructions: - -Load the plugin using: - - $this->load->plugin('js_calendar'); - -Once loaded you'll add the calendar script to the <head> of your page like this: - -<?php echo js_calendar_script('my_form'); ?> - -The above function will be passed the name of your form. - -Then to show the actual calendar you'll do this: - -<?php echo js_calendar_write('entry_date', time(), true);?> -<form name="my_form"> -<input type="text" name="entry_date" value="" onblur="update_calendar(this.name, this.value);" /> -<p><a href="javascript:void(0);" onClick="set_to_time('entry_date', '<?php echo time();?>')" >Today</a></p> -</form> - - -Note: The first parameter is the name of the field containing your date, the second parameter contains the "now" time, -and the third tells the calendar whether to highlight the current day or not. - -Lastly, you'll need some CSS for your calendar: - -.calendar { - border: 1px #6975A3 solid; - background-color: transparent; -} -.calheading { - background-color: #7C8BC0; - color: #fff; - font-family: Lucida Grande, Verdana, Geneva, Sans-serif; - font-size: 11px; - font-weight: bold; - text-align: center; -} -.calnavleft { - background-color: #7C8BC0; - font-family: Lucida Grande, Verdana, Geneva, Sans-serif; - font-size: 10px; - font-weight: bold; - color: #fff; - padding: 4px; - cursor: pointer; -} -.calnavright { - background-color: #7C8BC0; - font-family: Lucida Grande, Verdana, Geneva, Sans-serif; - font-size: 10px; - font-weight: bold; - color: #fff; - text-align: right; - padding: 4px; - cursor: pointer; -} -.caldayheading { - background-color: #000; - color: #fff; - font-family: Lucida Grande, Verdana, Geneva, Sans-serif; - font-size: 10px; - text-align: center; - padding: 6px 2px 6px 2px; -} -.caldaycells{ - color: #000; - background-color: #D1D7E6; - font-family: Lucida Grande, Verdana, Geneva, Sans-serif; - font-size: 11px; - text-align: center; - padding: 4px; - border: 1px #E0E5F1 solid; - cursor: pointer; -} -.caldaycellhover{ - color: #fff; - background-color: #B3BCD4; - font-family: Lucida Grande, Verdana, Geneva, Sans-serif; - font-size: 11px; - text-align: center; - padding: 4px; - border: 1px #B3BCD4 solid; - cursor: pointer; -} -.caldayselected{ - background-color: #737FAC; - color: #fff; - font-family: Lucida Grande, Verdana, Geneva, Sans-serif; - font-size: 11px; - font-weight: bold; - text-align: center; - border: 1px #566188 solid; - padding: 3px; - cursor: pointer; -} -.calblanktop { - background-color: #fff; - padding: 4px; -} -.calblankbot { - background-color: #fff; - padding: 4px; -} - - -*/ - -function js_calendar_script($form_name = 'entryform') -{ -$CI =& get_instance(); -$CI->load->language('calendar'); -ob_start(); -?> -<script type="text/javascript"> -<!-- -var form_name = "<?php echo $form_name; ?>"; -var format = 'us'; // eu or us -var days = new Array( - '<?php echo $CI->lang->line('cal_su');?>', // Sunday, short name - '<?php echo $CI->lang->line('cal_mo');?>', // Monday, short name - '<?php echo $CI->lang->line('cal_tu');?>', // Tuesday, short name - '<?php echo $CI->lang->line('cal_wed');?>', // Wednesday, short name - '<?php echo $CI->lang->line('cal_thu');?>', // Thursday, short name - '<?php echo $CI->lang->line('cal_fri');?>', // Friday, short name - '<?php echo $CI->lang->line('cal_sat');?>' // Saturday, short name - ); -var months = new Array( - '<?php echo $CI->lang->line('cal_january');?>', - '<?php echo $CI->lang->line('cal_february');?>', - '<?php echo $CI->lang->line('cal_march');?>', - '<?php echo $CI->lang->line('cal_april');?>', - '<?php echo $CI->lang->line('cal_mayl');?>', - '<?php echo $CI->lang->line('cal_june');?>', - '<?php echo $CI->lang->line('cal_july');?>', - '<?php echo $CI->lang->line('cal_august');?>', - '<?php echo $CI->lang->line('cal_september');?>', - '<?php echo $CI->lang->line('cal_october');?>', - '<?php echo $CI->lang->line('cal_november');?>', - '<?php echo $CI->lang->line('cal_december');?>' - ); -var last_click = new Array(); -var current_month = ''; -var current_year = ''; -var last_date = ''; - -function calendar(id, d, highlight, adjusted) -{ - if (adjusted == undefined) - { - var d = new Date(d * 1000); - } - - this.id = id; - this.highlight = highlight; - this.date_obj = d; - this.write = build_calendar; - this.total_days = total_days; - this.month = d.getMonth(); - this.date = d.getDate(); - this.day = d.getDay(); - this.year = d.getFullYear(); - this.hours = d.getHours(); - this.minutes = d.getMinutes(); - this.seconds = d.getSeconds(); - this.date_str = date_str; - - if (highlight == false) - { - this.selected_date = ''; - } - else - { - this.selected_date = this.year + '' + this.month + '' + this.date; - } - - // Set the "selected date" - d.setDate(1); - this.firstDay = d.getDay(); - - //then reset the date object to the correct date - d.setDate(this.date); -} - -// Build the body of the calendar -function build_calendar() -{ - var str = ''; - - // Calendar Heading - - str += '<div id="cal' + this.id + '">'; - str += '<table class="calendar" cellspacing="0" cellpadding="0" border="0" >'; - str += '<tr>'; - str += '<td class="calnavleft" onClick="change_month(-1, \'' + this.id + '\')"><<<\/td>'; - str += '<td colspan="5" class="calheading">' + months[this.month] + ' ' + this.year + '<\/td>'; - str += '<td class="calnavright" onClick="change_month(1, \'' + this.id + '\')">>><\/td>'; - str += '<\/tr>'; - - // Day Names - - str += '<tr>'; - - for (i = 0; i < 7; i++) - { - str += '<td class="caldayheading">' + days[i] + '<\/td>'; - } - - str += '<\/tr>'; - - // Day Cells - - str += '<tr>'; - - selDate = (last_date != '') ? last_date : this.date; - - for (j = 0; j < 42; j++) - { - var displayNum = (j - this.firstDay + 1); - - if (j < this.firstDay) // leading empty cells - { - str += '<td class="calblanktop"> <\/td>'; - } - else if (displayNum == selDate && this.highlight == true) // Selected date - { - str += '<td id="' + this.id +'selected" class="caldayselected" onClick="set_date(this,\'' + this.id + '\')">' + displayNum + '<\/td>'; - } - else if (displayNum > this.total_days()) - { - str += '<td class="calblankbot"> <\/td>'; // trailing empty cells - } - else // Unselected days - { - str += '<td id="" class="caldaycells" onClick="set_date(this,\'' + this.id + '\'); return false;" onMouseOver="javascript:cell_highlight(this,\'' + displayNum + '\',\'' + this.id + '\');" onMouseOut="javascript:cell_reset(this,\'' + displayNum + '\',\'' + this.id + '\');" >' + displayNum + '<\/td>'; - } - - if (j % 7 == 6) - { - str += '<\/tr><tr>'; - } - } - - str += '<\/tr>'; - str += '<\/table>'; - str += '<\/div>'; - - return str; -} - -// Total number of days in a month -function total_days() -{ - switch(this.month) - { - case 1: // Check for leap year - if (( this.date_obj.getFullYear() % 4 == 0 - && this.date_obj.getFullYear() % 100 != 0) - || this.date_obj.getFullYear() % 400 == 0) - return 29; - else - return 28; - case 3: - return 30; - case 5: - return 30; - case 8: - return 30; - case 10: - return 30 - default: - return 31; - } -} - -// Highlight Cell on Mouseover -function cell_highlight(td, num, cal) -{ - cal = eval(cal); - - if (last_click[cal.id] != num) - { - td.className = "caldaycellhover"; - } -} - -// Reset Cell on MouseOut -function cell_reset(td, num, cal) -{ - cal = eval(cal); - - if (last_click[cal.id] == num) - { - td.className = "caldayselected"; - } - else - { - td.className = "caldaycells"; - } -} - -// Clear Field -function clear_field(id) -{ - eval("document." + form_name + "." + id + ".value = ''"); - - document.getElementById(id + "selected").className = "caldaycells"; - document.getElementById(id + "selected").id = ""; - - cal = eval(id); - cal.selected_date = ''; -} - - -// Set date to specified time -function set_to_time(id, raw) -{ - if (document.getElementById(id + "selected")) - { - document.getElementById(id + "selected").className = "caldaycells"; - document.getElementById(id + "selected").id = ""; - } - - document.getElementById('cal' + id).innerHTML = '<div id="tempcal'+id+'"> <'+'/div>'; - - var nowDate = new Date(); - nowDate.setTime = raw * 1000; - - current_month = nowDate.getMonth(); - current_year = nowDate.getFullYear(); - current_date = nowDate.getDate(); - - oldcal = eval(id); - oldcal.selected_date = current_year + '' + current_month + '' + current_date; - - cal = new calendar(id, nowDate, true, true); - cal.selected_date = current_year + '' + current_month + '' + current_date; - - last_date = cal.date; - - document.getElementById('tempcal'+id).innerHTML = cal.write(); - - insert_date(cal); -} - -// Set date to what is in the field -var lastDates = new Array(); - -function update_calendar(id, dateValue) -{ - if (lastDates[id] == dateValue) return; - - lastDates[id] = dateValue; - - var fieldString = dateValue.replace(/\s+/g, ' '); - - while (fieldString.substring(0,1) == ' ') - { - fieldString = fieldString.substring(1, fieldString.length); - } - - var dateString = fieldString.split(' '); - var dateParts = dateString[0].split('-') - - if (dateParts.length < 3) return; - var newYear = dateParts[0]; - var newMonth = dateParts[1]; - var newDay = dateParts[2]; - - if (isNaN(newDay) || newDay < 1 || (newDay.length != 1 && newDay.length != 2)) return; - if (isNaN(newYear) || newYear < 1 || newYear.length != 4) return; - if (isNaN(newMonth) || newMonth < 1 || (newMonth.length != 1 && newMonth.length != 2)) return; - - if (newMonth > 12) newMonth = 12; - - if (newDay > 28) - { - switch(newMonth - 1) - { - case 1: // Check for leap year - if ((newYear % 4 == 0 && newYear % 100 != 0) || newYear % 400 == 0) - { - if (newDay > 29) newDay = 29; - } - else - { - if (newDay > 28) newDay = 28; - } - case 3: - if (newDay > 30) newDay = 30; - case 5: - if (newDay > 30) newDay = 30; - case 8: - if (newDay > 30) newDay = 30; - case 10: - if (newDay > 30) newDay = 30; - default: - if (newDay > 31) newDay = 31; - } - } - - if (document.getElementById(id + "selected")) - { - document.getElementById(id + "selected").className = "caldaycells"; - document.getElementById(id + "selected").id = ""; - } - - document.getElementById('cal' + id).innerHTML = '<div id="tempcal'+id+'"> <'+'/div>'; - - var nowDate = new Date(); - nowDate.setDate(newDay); - nowDate.setMonth(newMonth - 1); - nowDate.setYear(newYear); - nowDate.setHours(12); - - current_month = nowDate.getMonth(); - current_year = nowDate.getFullYear(); - - cal = new calendar(id, nowDate, true, true); - document.getElementById('tempcal'+id).innerHTML = cal.write(); -} - -// Set the date -function set_date(td, cal) -{ - - cal = eval(cal); - - // If the user is clicking a cell that is already - // selected we'll de-select it and clear the form field - - if (last_click[cal.id] == td.firstChild.nodeValue) - { - td.className = "caldaycells"; - last_click[cal.id] = ''; - remove_date(cal); - cal.selected_date = ''; - return; - } - - // Onward! - if (document.getElementById(cal.id + "selected")) - { - document.getElementById(cal.id + "selected").className = "caldaycells"; - document.getElementById(cal.id + "selected").id = ""; - } - - td.className = "caldayselected"; - td.id = cal.id + "selected"; - - cal.selected_date = cal.date_obj.getFullYear() + '' + cal.date_obj.getMonth() + '' + cal.date; - cal.date_obj.setDate(td.firstChild.nodeValue); - cal = new calendar(cal.id, cal.date_obj, true, true); - cal.selected_date = cal.date_obj.getFullYear() + '' + cal.date_obj.getMonth() + '' + cal.date; - - last_date = cal.date; - - //cal.date - last_click[cal.id] = cal.date; - - // Insert the date into the form - insert_date(cal); -} -/* -// Insert the date into the form field -function insert_date(cal) -{ - cal = eval(cal); - fval = eval("document." + form_name + "." + cal.id); - - if (fval.value == '') - { - fval.value = cal.date_str('y'); - } - else - { - time = fval.value.substring(10); - new_date = cal.date_str('n') + time; - fval.value = new_date; - } -} -*/ -// Remove the date from the form field -function remove_date(cal) -{ - cal = eval(cal); - fval = eval("document." + form_name + "." + cal.id); - fval.value = ''; -} - -// Change to a new month -function change_month(mo, cal) -{ - cal = eval(cal); - - if (current_month != '') - { - cal.date_obj.setMonth(current_month); - cal.date_obj.setYear(current_year); - - current_month = ''; - current_year = ''; - } - - var newMonth = cal.date_obj.getMonth() + mo; - var newDate = cal.date_obj.getDate(); - - if (newMonth == 12) - { - cal.date_obj.setYear(cal.date_obj.getFullYear() + 1) - newMonth = 0; - } - else if (newMonth == -1) - { - cal.date_obj.setYear(cal.date_obj.getFullYear() - 1) - newMonth = 11; - } - - if (newDate > 28) - { - var newYear = cal.date_obj.getFullYear(); - - switch(newMonth) - { - case 1: // Check for leap year - if ((newYear % 4 == 0 && newYear % 100 != 0) || newYear % 400 == 0) - { - if (newDate > 29) newDate = 29; - } - else - { - if (newDate > 28) newDate = 28; - } - case 3: - if (newDate > 30) newDate = 30; - case 5: - if (newDate > 30) newDate = 30; - case 8: - if (newDate > 30) newDate = 30; - case 10: - if (newDate > 30) newDate = 30; - default: - if (newDate > 31) newDate = 31; - } - } - - cal.date_obj.setDate(newDate); - cal.date_obj.setMonth(newMonth); - new_mdy = cal.date_obj.getFullYear() + '' + cal.date_obj.getMonth() + '' + cal.date; - - highlight = (cal.selected_date == new_mdy) ? true : false; - cal = new calendar(cal.id, cal.date_obj, highlight, true); - document.getElementById('cal' + cal.id).innerHTML = cal.write(); -} - -// Finalize the date string -function date_str(time) -{ - var month = this.month + 1; - if (month < 10) - month = '0' + month; - - var day = (this.date < 10) ? '0' + this.date : this.date; - var minutes = (this.minutes < 10) ? '0' + this.minutes : this.minutes; - - if (format == 'us') - { - var hours = (this.hours > 12) ? this.hours - 12 : this.hours; - var ampm = (this.hours > 11) ? 'PM' : 'AM' - } - else - { - var hours = this.hours; - var ampm = ''; - } - - if (time == 'y') - { - return this.year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ' ' + ampm; - } - else - { - return this.year + '-' + month + '-' + day; - } -} - -//--> -</script> -<?php - -$r = ob_get_contents(); -ob_end_clean(); -return $r; -} - - -function js_calendar_write($field_id, $time = '', $highlight = TRUE) -{ - if ($time == '') - $time = time(); - - return - '<script type="text/javascript"> - var '.$field_id.' = new calendar("'.$field_id.'", '.$time.', '.(($highlight == TRUE) ? 'true' : 'false').'); - document.write('.$field_id.'.write()); - </script>'; -} - - -/* End of file js_calendar_pi.php */ -/* Location: ./system/plugins/js_calendar_pi.php */
\ No newline at end of file diff --git a/system/scaffolding/Scaffolding.php b/system/scaffolding/Scaffolding.php deleted file mode 100644 index d110626b1..000000000 --- a/system/scaffolding/Scaffolding.php +++ /dev/null @@ -1,291 +0,0 @@ -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); -/** - * CodeIgniter - * - * An open source application development framework for PHP 4.3.2 or newer - * - * @package CodeIgniter - * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. - * @license http://codeigniter.com/user_guide/license.html - * @link http://codeigniter.com - * @since Version 1.0 - * @filesource - */ - -// ------------------------------------------------------------------------ - -/** - * Scaffolding Class - * - * Provides the Scaffolding framework - * - * @package CodeIgniter - * @subpackage Scaffolding - * @author ExpressionEngine Dev Team - * @link http://codeigniter.com/user_guide/general/scaffolding.html - */ -class Scaffolding { - - var $CI; - var $current_table; - var $base_url = ''; - var $lang = array(); - - function Scaffolding($db_table) - { - $this->CI =& get_instance(); - - $this->CI->load->database("", FALSE, TRUE); - $this->CI->load->library('pagination'); - - // Turn off caching - $this->CI->db->cache_off(); - - /** - * Set the current table name - * This is done when initializing scaffolding: - * $this->load->scaffolding('table_name') - * - */ - $this->current_table = $db_table; - - /** - * Set the path to the "view" files - * We'll manually override the "view" path so that - * the load->view function knows where to look. - */ - - $this->CI->load->_ci_view_path = BASEPATH.'scaffolding/views/'; - - // Set the base URL - $this->base_url = $this->CI->config->site_url().'/'.$this->CI->uri->segment(1).$this->CI->uri->slash_segment(2, 'both'); - $this->base_uri = $this->CI->uri->segment(1).$this->CI->uri->slash_segment(2, 'leading'); - - // Set a few globals - $data = array( - 'image_url' => $this->CI->config->system_url().'scaffolding/images/', - 'base_uri' => $this->base_uri, - 'base_url' => $this->base_url, - 'title' => $this->current_table - ); - - $this->CI->load->vars($data); - - // Load the language file and create variables - $this->lang = $this->CI->load->scaffold_language('scaffolding', '', TRUE); - $this->CI->load->vars($this->lang); - - // Load the helper files we plan to use - $this->CI->load->helper(array('url', 'form')); - - - log_message('debug', 'Scaffolding Class Initialized'); - } - - // -------------------------------------------------------------------- - - /** - * "Add" Page - * - * Shows a form representing the currently selected DB - * so that data can be inserted - * - * @access public - * @return string the HTML "add" page - */ - function add() - { - $data = array( - 'title' => ( ! isset($this->lang['scaff_add'])) ? 'Add Data' : $this->lang['scaff_add'], - 'fields' => $this->CI->db->field_data($this->current_table), - 'action' => $this->base_uri.'/insert' - ); - - $this->CI->load->view('add', $data); - } - - // -------------------------------------------------------------------- - - /** - * Insert the data - * - * @access public - * @return void redirects to the view page - */ - function insert() - { - if ($this->CI->db->insert($this->current_table, $_POST) === FALSE) - { - $this->add(); - } - else - { - redirect($this->base_uri.'/view/'); - } - } - - // -------------------------------------------------------------------- - - /** - * "View" Page - * - * Shows a table containing the data in the currently - * selected DB - * - * @access public - * @return string the HTML "view" page - */ - function view() - { - // Fetch the total number of DB rows - $total_rows = $this->CI->db->count_all($this->current_table); - - if ($total_rows < 1) - { - return $this->CI->load->view('no_data'); - } - - // Set the query limit/offset - $per_page = 20; - $offset = $this->CI->uri->segment(4, 0); - - // Run the query - $query = $this->CI->db->get($this->current_table, $per_page, $offset); - - // Now let's get the field names - $fields = $this->CI->db->list_fields($this->current_table); - - // We assume that the column in the first position is the primary field. - $primary = current($fields); - - // Pagination! - $this->CI->pagination->initialize( - array( - 'base_url' => $this->base_url.'/view', - 'total_rows' => $total_rows, - 'per_page' => $per_page, - 'uri_segment' => 4, - 'full_tag_open' => '<p>', - 'full_tag_close' => '</p>' - ) - ); - - $data = array( - 'title' => ( ! isset($this->lang['scaff_view'])) ? 'View Data' : $this->lang['scaff_view'], - 'query' => $query, - 'fields' => $fields, - 'primary' => $primary, - 'paginate' => $this->CI->pagination->create_links() - ); - - $this->CI->load->view('view', $data); - } - - // -------------------------------------------------------------------- - - /** - * "Edit" Page - * - * Shows a form representing the currently selected DB - * so that data can be edited - * - * @access public - * @return string the HTML "edit" page - */ - function edit() - { - if (FALSE === ($id = $this->CI->uri->segment(4))) - { - return $this->view(); - } - - // Fetch the primary field name - $primary = $this->CI->db->primary($this->current_table); - - // Run the query - $query = $this->CI->db->get_where($this->current_table, array($primary => $id)); - - $data = array( - 'title' => ( ! isset($this->lang['scaff_edit'])) ? 'Edit Data' : $this->lang['scaff_edit'], - 'fields' => $query->field_data(), - 'query' => $query->row(), - 'action' => $this->base_uri.'/update/'.$this->CI->uri->segment(4) - ); - - $this->CI->load->view('edit', $data); - } - - // -------------------------------------------------------------------- - - /** - * Update - * - * @access public - * @return void redirects to the view page - */ - function update() - { - // Fetch the primary key - $primary = $this->CI->db->primary($this->current_table); - - // Now do the query - $this->CI->db->update($this->current_table, $_POST, array($primary => $this->CI->uri->segment(4))); - - redirect($this->base_uri.'/view/'); - } - - // -------------------------------------------------------------------- - - /** - * Delete Confirmation - * - * @access public - * @return string the HTML "delete confirm" page - */ - function delete() - { - if ( ! isset($this->lang['scaff_del_confirm'])) - { - $message = 'Are you sure you want to delete the following row: '.$this->CI->uri->segment(4); - } - else - { - $message = $this->lang['scaff_del_confirm'].' '.$this->CI->uri->segment(4); - } - - $data = array( - 'title' => ( ! isset($this->lang['scaff_delete'])) ? 'Delete Data' : $this->lang['scaff_delete'], - 'message' => $message, - 'no' => anchor(array($this->base_uri, 'view'), ( ! isset($this->lang['scaff_no'])) ? 'No' : $this->lang['scaff_no']), - 'yes' => anchor(array($this->base_uri, 'do_delete', $this->CI->uri->segment(4)), ( ! isset($this->lang['scaff_yes'])) ? 'Yes' : $this->lang['scaff_yes']) - ); - - $this->CI->load->view('delete', $data); - } - - // -------------------------------------------------------------------- - - /** - * Delete - * - * @access public - * @return void redirects to the view page - */ - function do_delete() - { - // Fetch the primary key - $primary = $this->CI->db->primary($this->current_table); - - // Now do the query - $this->CI->db->where($primary, $this->CI->uri->segment(4)); - $this->CI->db->delete($this->current_table); - - header("Refresh:0;url=".site_url(array($this->base_uri, 'view'))); - exit; - } - -} - -/* End of file Scaffolding.php */ -/* Location: ./system/scaffolding/Scaffolding.php */
\ No newline at end of file diff --git a/system/scaffolding/images/background.jpg b/system/scaffolding/images/background.jpg Binary files differdeleted file mode 100644 index 9d5bdcea1..000000000 --- a/system/scaffolding/images/background.jpg +++ /dev/null diff --git a/system/scaffolding/images/logo.jpg b/system/scaffolding/images/logo.jpg Binary files differdeleted file mode 100644 index d6cc9a76d..000000000 --- a/system/scaffolding/images/logo.jpg +++ /dev/null diff --git a/system/scaffolding/views/add.php b/system/scaffolding/views/add.php deleted file mode 100644 index cbb12f6fb..000000000 --- a/system/scaffolding/views/add.php +++ /dev/null @@ -1,32 +0,0 @@ -<?php $this->load->view('header'); ?> - -<p><?php echo anchor(array($base_uri, 'view'), '< '.$scaff_view_all); ?></p> - - -<?php echo form_open($action); ?> - -<table border="0" cellpadding="3" cellspacing="1"> -<?php foreach($fields as $field): ?> - -<?php if ($field->primary_key == 1) continue; ?> - -<tr> - <td><?php echo $field->name; echo ' '.$field->default; ?></td> - - <?php if ($field->type == 'blob'): ?> - <td><textarea class="textarea" name="<?php echo $field->name; ?>" cols="60" rows="10" ><?php echo form_prep($field->default); ?></textarea></td> - <?php else : ?> - <td><input class="input" name="<?php echo $field->name; ?>" value="<?php echo form_prep($field->default); ?>" size="60" /></td> - <?php endif; ?> - -</tr> -<?php endforeach; ?> -</table> - -<input type="submit" class="submit" value="Insert" /> - -</form> - -<?php $this->load->view('footer'); -/* End of file add.php */ -/* Location: ./system/scaffolding/views/add.php */ diff --git a/system/scaffolding/views/delete.php b/system/scaffolding/views/delete.php deleted file mode 100644 index d19542195..000000000 --- a/system/scaffolding/views/delete.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php $this->load->view('header'); ?> - -<p><?php echo $message; ?></p> - -<p><?php echo $no; ?> | <?php echo $yes; ?> - -<?php $this->load->view('footer'); -/* End of file delete.php */ -/* Location: ./system/scaffolding/views/delete.php */ diff --git a/system/scaffolding/views/edit.php b/system/scaffolding/views/edit.php deleted file mode 100644 index fe553e591..000000000 --- a/system/scaffolding/views/edit.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php $this->load->view('header'); ?> - - -<p><?php echo anchor(array($base_uri, 'view'), '< '.$scaff_view_all);?></p> - - -<?php echo form_open($action); ?> - -<table border="0" cellpadding="3" cellspacing="1"> -<?php foreach($fields as $field): ?> - -<?php if ($field->primary_key == 1) continue; ?> - -<tr> - <td><?php echo $field->name; ?></td> - - <?php if ($field->type == 'blob'): ?> - <td><textarea class="textarea" name="<?php echo $field->name;?>" cols="60" rows="10" ><?php $f = $field->name; echo form_prep($query->$f); ?></textarea></td> - <?php else : ?> - <td><input class="input" value="<?php $f = $field->name; echo form_prep($query->$f); ?>" name="<?php echo $field->name; ?>" size="60" /></td> - <?php endif; ?> - -</tr> -<?php endforeach; ?> -</table> - -<input type="submit" class="submit" value="Update" /> - -</form> - -<?php $this->load->view('footer'); -/* End of file edit.php */ -/* Location: ./system/scaffolding/views/edit.php */
\ No newline at end of file diff --git a/system/scaffolding/views/footer.php b/system/scaffolding/views/footer.php deleted file mode 100644 index 0e71401c9..000000000 --- a/system/scaffolding/views/footer.php +++ /dev/null @@ -1,10 +0,0 @@ - -</div> - -<div id="footer"> -<p><a href="http://codeigniter.com/">CodeIgniter</a>, by <a href="http://www.EllisLab.com">EllisLab</a> - Version <?php echo CI_VERSION ?></p> -<p>Page rendered in {elapsed_time}</p> -</div> - -</body> -</html>
\ No newline at end of file diff --git a/system/scaffolding/views/header.php b/system/scaffolding/views/header.php deleted file mode 100644 index 50f234a49..000000000 --- a/system/scaffolding/views/header.php +++ /dev/null @@ -1,29 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html> -<head> - -<title><?php echo $title; ?></title> - -<style type='text/css'> -<?php $this->file(BASEPATH.'scaffolding/views/stylesheet.css'); ?> -</style> - -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<meta http-equiv='expires' content='-1' /> -<meta http-equiv= 'pragma' content='no-cache' /> - -</head> -<body> - -<div id="header"> -<div id="header_left"> -<h3>Scaffolding: <?php echo $title; ?></h3> -</div> -<div id="header_right"> -<?php echo anchor(array($base_uri, 'view'), $scaff_view_records); ?> | -<?php echo anchor(array($base_uri, 'add'), $scaff_create_record); ?> -</div> -</div> - -<br clear="all"> -<div id="outer">
\ No newline at end of file diff --git a/system/scaffolding/views/index.html b/system/scaffolding/views/index.html deleted file mode 100644 index c942a79ce..000000000 --- a/system/scaffolding/views/index.html +++ /dev/null @@ -1,10 +0,0 @@ -<html> -<head> - <title>403 Forbidden</title> -</head> -<body> - -<p>Directory access is forbidden.</p> - -</body> -</html>
\ No newline at end of file diff --git a/system/scaffolding/views/no_data.php b/system/scaffolding/views/no_data.php deleted file mode 100644 index bc81e7480..000000000 --- a/system/scaffolding/views/no_data.php +++ /dev/null @@ -1,8 +0,0 @@ -<?php $this->load->view('header'); ?> - -<p><?php echo $scaff_no_data; ?></p> -<p><?php echo anchor(array($base_uri, 'add'), $scaff_create_record); ?></p> - -<?php $this->load->view('footer'); -/* End of file no_data.php */ -/* Location: ./system/scaffolding/views/no_data.php */
\ No newline at end of file diff --git a/system/scaffolding/views/stylesheet.css b/system/scaffolding/views/stylesheet.css deleted file mode 100644 index 3f487dd0b..000000000 --- a/system/scaffolding/views/stylesheet.css +++ /dev/null @@ -1,143 +0,0 @@ -body { - margin: 0; - padding: 0; - font-family: Lucida Grande, Verdana, Geneva, Sans-serif; - font-size: 11px; - color: #4F5155; - background: #fff url(<?php echo $image_url; ?>background.jpg) repeat-x left top; -} - -a { - color: #8B0D00; - background-color: transparent; - text-decoration: none; - font-weight: bold; -} - -a:visited { - color: #8B0D00; - background-color: transparent; - text-decoration: none; -} - -a:hover { - color: #000; - text-decoration: none; - background-color: transparent; -} - - -#header { - margin: 0; - padding: 0; -} - -#header_left { - background-color: transparent; - float: left; - padding: 21px 0 0 32px; - margin: 0 -} - -#header_right { - background-color: transparent; - float: right; - text-align: right; - padding: 35px 50px 20px 0; - margin: 0 -} - -#footer { - margin: 20px 0 15px 0; - padding: 0; -} - -#footer p { - font-size: 10px; - color: #999; - text-align: center; -} - -#outer { - margin: 30px 40px 0 40px; -} - -img { - padding:0; - border: 0; - margin: 0; -} - -.nopad { - padding:0; - border: 0; - margin: 0; -} - -table { - background-color: #efefef; -} - -th { - background-color: #eee; - font-weight: bold; - padding: 6px; - text-align: left; -} - -td { - background-color: #fff; - padding: 6px; -} - - -form { - margin: 0; - padding: 0; -} - -.input { - font-family: Lucida Grande, Verdana, Geneva, Sans-serif; - font-size: 11px; - width: 600px; - color: #333; - border: 1px solid #B3B4BD; - font-size: 11px; - height: 2em; - padding: 0; - margin: 0; -} - -.textarea { - font-family: Lucida Grande, Verdana, Geneva, Sans-serif; - font-size: 12px; - width: 600px; - color: #333; - border: 1px solid #B3B4BD; - padding: 0; - margin: 0; -} - -.select { - background-color: #fff; - font-size: 11px; - font-weight: normal; - color: #333; - padding: 0; - margin: 0 0 3px 0; -} - -.checkbox { - background-color: transparent; - padding: 0; - border: 0; -} - -.submit { - background-color: #8B0D00; - color: #FFF; - font-weight: normal; - border: 1px solid #000; - margin: 6px 0 0 0; - padding: 1px 5px 1px 5px; -} diff --git a/system/scaffolding/views/view.php b/system/scaffolding/views/view.php deleted file mode 100644 index a81241d39..000000000 --- a/system/scaffolding/views/view.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php $this->load->view('header'); ?> - -<table border="0" cellpadding="0" cellspacing="1" style="width:100%"> - <tr> - <th>Edit</th> - <th>Delete</th> - <?php foreach($fields as $field): ?> - <th><?php echo $field; ?></th> - <?php endforeach; ?> -</tr> - -<?php foreach($query->result() as $row): ?> - <tr> - <td> <?php echo anchor(array($base_uri, 'edit', $row->$primary), $scaff_edit); ?> </td> - <td><?php echo anchor(array($base_uri, 'delete', $row->$primary), $scaff_delete); ?></td> - <?php foreach($fields as $field): ?> - <td><?php echo form_prep($row->$field);?></td> - <?php endforeach; ?> - </tr> -<?php endforeach; ?> -</table> - -<?php echo $paginate; ?> - -<?php $this->load->view('footer'); -/* End of file view.php */ -/* Location: ./system/scaffolding/views/view.php */
\ No newline at end of file |