From b48acc6c610ab01c1b23e42fe2e6320e7be08cd2 Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Fri, 8 Aug 2014 15:41:59 -0400 Subject: [PATCH] First public commit --- .gitignore | 6 + README.md | 0 application/config/autoload.php | 123 + application/config/config.php | 350 +++ application/config/constants.php | 114 + application/config/database.php | 62 + application/config/doctypes.php | 17 + application/config/form_validation.php | 67 + application/config/hooks.php | 23 + application/config/index.html | 10 + application/config/mimes.php | 105 + application/config/min_config.php | 144 + application/config/min_groupsConfig.php | 36 + application/config/profiler.php | 53 + application/config/routes.php | 54 + application/config/sites.php | 119 + application/config/smileys.php | 66 + application/config/testing/database.php | 62 + application/config/user_agents.php | 175 ++ application/controllers/account.php | 103 + application/controllers/calendar.php | 133 + application/controllers/category.php | 86 + application/controllers/friend.php | 99 + application/controllers/group.php | 95 + application/controllers/login.php | 114 + application/controllers/reminder.php | 40 + application/controllers/task.php | 349 +++ application/core/MY_Controller.php | 36 + application/errors/error_404.php | 3 + application/errors/error_db.php | 61 + application/errors/error_general.php | 61 + application/errors/error_php.php | 10 + application/hooks/pre-controller.php | 32 + application/language/english/index.html | 10 + application/libraries/MY_Form_validation.php | 34 + application/libraries/MY_Session.php | 81 + application/libraries/Page.php | 297 ++ application/libraries/Todo.php | 843 +++++ .../libraries/Validation_callbacks.php | 61 + application/logs/index.html | 10 + application/models/friend_model.php | 283 ++ application/models/mail_model.php | 147 + application/models/task_model.php | 1597 ++++++++++ .../third_party/CIUnit/bootstrap_phpunit.php | 278 ++ .../third_party/CIUnit/config/config.php | 13 + .../CIUnit/core/CIU_Controller.php | 23 + .../CIUnit/core/CIU_Exceptions.php | 137 + .../third_party/CIUnit/core/CIU_Loader.php | 437 +++ .../third_party/CIUnit/core/CIU_Output.php | 290 ++ .../third_party/CIUnit/core/CodeIgniter.php | 419 +++ .../third_party/CIUnit/core/Common.php | 188 ++ .../third_party/CIUnit/core/README.txt | 3 + .../CIUnit/helpers/CIU_url_helper.php | 62 + application/third_party/CIUnit/index.html | 15 + .../CIUnit/libraries/CIU_Session.php | 82 + .../third_party/CIUnit/libraries/CIUnit.php | 256 ++ .../CIUnit/libraries/CIUnitTestCase.php | 222 ++ .../third_party/CIUnit/libraries/Fixture.php | 84 + .../CIUnit/libraries/Unit_test.php | 434 +++ .../third_party/CIUnit/libraries/spyc/README | 159 + .../libraries/spyc/examples/yaml-dump.php | 25 + .../libraries/spyc/examples/yaml-load.php | 25 + .../CIUnit/libraries/spyc/php4/5to4.php | 16 + .../CIUnit/libraries/spyc/php4/spyc.php4 | 1023 +++++++ .../CIUnit/libraries/spyc/php4/test.php4 | 162 + .../CIUnit/libraries/spyc/spyc.php | 1024 +++++++ .../CIUnit/libraries/spyc/spyc.yaml | 196 ++ .../CIUnit/libraries/spyc/tests/DumpTest.php | 58 + .../libraries/spyc/tests/IndentTest.php | 57 + .../CIUnit/libraries/spyc/tests/ParseTest.php | 305 ++ .../CIUnit/libraries/spyc/tests/failing1.yaml | 2 + .../CIUnit/libraries/spyc/tests/indent_1.yaml | 53 + .../CIUnit/libraries/spyc/tests/quotes.yaml | 8 + application/views/account/password.php | 38 + application/views/account/side_nav.php | 15 + application/views/account/status.php | 48 + application/views/footer.php | 28 + application/views/friend/ajax_search.php | 13 + application/views/friend/group_list.php | 46 + application/views/friend/list.php | 30 + application/views/friend/manage.php | 31 + application/views/friend/requests.php | 33 + application/views/friend/search.php | 24 + application/views/friend/side_nav.php | 36 + application/views/header.php | 10 + application/views/login/login.php | 49 + application/views/login/register.php | 42 + application/views/menu.php | 39 + application/views/message.php | 4 + application/views/task/add.php | 165 + application/views/task/ajax_checklist.php | 5 + application/views/task/calendar.php | 33 + application/views/task/cat_add.php | 25 + application/views/task/cat_list.php | 64 + application/views/task/checklist_view.php | 15 + application/views/task/comments_view.php | 21 + application/views/task/edit.php | 211 ++ application/views/task/list.php | 53 + application/views/task/side_nav.php | 45 + application/views/task/view.php | 113 + phpci.yml | 25 + system/.htaccess | 1 + system/core/Benchmark.php | 118 + system/core/CodeIgniter.php | 402 +++ system/core/Common.php | 564 ++++ system/core/Config.php | 379 +++ system/core/Controller.php | 64 + system/core/Exceptions.php | 193 ++ system/core/Hooks.php | 248 ++ system/core/Input.php | 849 ++++++ system/core/Lang.php | 160 + system/core/Loader.php | 1248 ++++++++ system/core/Model.php | 57 + system/core/Output.php | 574 ++++ system/core/Router.php | 522 ++++ system/core/Security.php | 875 ++++++ system/core/URI.php | 654 ++++ system/core/Utf8.php | 165 + system/core/index.html | 10 + system/database/DB.php | 209 ++ system/database/DB_cache.php | 218 ++ system/database/DB_driver.php | 1886 ++++++++++++ system/database/DB_forge.php | 1063 +++++++ system/database/DB_query_builder.php | 2710 +++++++++++++++++ system/database/DB_result.php | 658 ++++ system/database/DB_utility.php | 415 +++ .../database/drivers/cubrid/cubrid_driver.php | 427 +++ .../database/drivers/cubrid/cubrid_forge.php | 219 ++ .../database/drivers/cubrid/cubrid_result.php | 170 ++ .../drivers/cubrid/cubrid_utility.php | 71 + system/database/drivers/cubrid/index.html | 10 + .../database/drivers/ibase/ibase_driver.php | 401 +++ system/database/drivers/ibase/ibase_forge.php | 243 ++ .../database/drivers/ibase/ibase_result.php | 154 + .../database/drivers/ibase/ibase_utility.php | 61 + system/database/drivers/ibase/index.html | 10 + system/database/drivers/index.html | 10 + system/database/drivers/mssql/index.html | 10 + .../database/drivers/mssql/mssql_driver.php | 528 ++++ system/database/drivers/mssql/mssql_forge.php | 136 + .../database/drivers/mssql/mssql_result.php | 189 ++ .../database/drivers/mssql/mssql_utility.php | 67 + system/database/drivers/mysql/index.html | 10 + .../database/drivers/mysql/mysql_driver.php | 496 +++ system/database/drivers/mysql/mysql_forge.php | 233 ++ .../database/drivers/mysql/mysql_result.php | 192 ++ .../database/drivers/mysql/mysql_utility.php | 203 ++ system/database/drivers/mysqli/index.html | 10 + .../database/drivers/mysqli/mysqli_driver.php | 473 +++ .../database/drivers/mysqli/mysqli_forge.php | 233 ++ .../database/drivers/mysqli/mysqli_result.php | 177 ++ .../drivers/mysqli/mysqli_utility.php | 203 ++ system/database/drivers/oci8/index.html | 10 + system/database/drivers/oci8/oci8_driver.php | 706 +++++ system/database/drivers/oci8/oci8_forge.php | 133 + system/database/drivers/oci8/oci8_result.php | 222 ++ system/database/drivers/oci8/oci8_utility.php | 60 + system/database/drivers/odbc/index.html | 10 + system/database/drivers/odbc/odbc_driver.php | 366 +++ system/database/drivers/odbc/odbc_forge.php | 76 + system/database/drivers/odbc/odbc_result.php | 259 ++ system/database/drivers/odbc/odbc_utility.php | 53 + system/database/drivers/pdo/index.html | 10 + system/database/drivers/pdo/pdo_driver.php | 392 +++ system/database/drivers/pdo/pdo_forge.php | 55 + system/database/drivers/pdo/pdo_result.php | 189 ++ system/database/drivers/pdo/pdo_utility.php | 53 + .../drivers/pdo/subdrivers/index.html | 10 + .../drivers/pdo/subdrivers/pdo_4d_driver.php | 192 ++ .../drivers/pdo/subdrivers/pdo_4d_forge.php | 209 ++ .../pdo/subdrivers/pdo_cubrid_driver.php | 247 ++ .../pdo/subdrivers/pdo_cubrid_forge.php | 219 ++ .../pdo/subdrivers/pdo_dblib_driver.php | 329 ++ .../pdo/subdrivers/pdo_dblib_forge.php | 136 + .../pdo/subdrivers/pdo_firebird_driver.php | 260 ++ .../pdo/subdrivers/pdo_firebird_forge.php | 229 ++ .../drivers/pdo/subdrivers/pdo_ibm_driver.php | 236 ++ .../drivers/pdo/subdrivers/pdo_ibm_forge.php | 146 + .../pdo/subdrivers/pdo_informix_driver.php | 301 ++ .../pdo/subdrivers/pdo_informix_forge.php | 155 + .../pdo/subdrivers/pdo_mysql_driver.php | 263 ++ .../pdo/subdrivers/pdo_mysql_forge.php | 247 ++ .../drivers/pdo/subdrivers/pdo_oci_driver.php | 291 ++ .../drivers/pdo/subdrivers/pdo_oci_forge.php | 133 + .../pdo/subdrivers/pdo_odbc_driver.php | 258 ++ .../drivers/pdo/subdrivers/pdo_odbc_forge.php | 62 + .../pdo/subdrivers/pdo_pgsql_driver.php | 376 +++ .../pdo/subdrivers/pdo_pgsql_forge.php | 195 ++ .../pdo/subdrivers/pdo_sqlite_driver.php | 202 ++ .../pdo/subdrivers/pdo_sqlite_forge.php | 229 ++ .../pdo/subdrivers/pdo_sqlsrv_driver.php | 363 +++ .../pdo/subdrivers/pdo_sqlsrv_forge.php | 136 + system/database/drivers/postgre/index.html | 10 + .../drivers/postgre/postgre_driver.php | 641 ++++ .../drivers/postgre/postgre_forge.php | 188 ++ .../drivers/postgre/postgre_result.php | 173 ++ .../drivers/postgre/postgre_utility.php | 68 + system/database/drivers/sqlite/index.html | 10 + .../database/drivers/sqlite/sqlite_driver.php | 354 +++ .../database/drivers/sqlite/sqlite_forge.php | 197 ++ .../database/drivers/sqlite/sqlite_result.php | 157 + .../drivers/sqlite/sqlite_utility.php | 53 + system/database/drivers/sqlite3/index.html | 10 + .../drivers/sqlite3/sqlite3_driver.php | 358 +++ .../drivers/sqlite3/sqlite3_forge.php | 216 ++ .../drivers/sqlite3/sqlite3_result.php | 187 ++ .../drivers/sqlite3/sqlite3_utility.php | 53 + system/database/drivers/sqlsrv/index.html | 10 + .../database/drivers/sqlsrv/sqlsrv_driver.php | 565 ++++ .../database/drivers/sqlsrv/sqlsrv_forge.php | 136 + .../database/drivers/sqlsrv/sqlsrv_result.php | 186 ++ .../drivers/sqlsrv/sqlsrv_utility.php | 69 + system/database/index.html | 10 + system/fonts/index.html | 10 + system/fonts/texb.ttf | Bin 0 -> 143830 bytes system/helpers/array_helper.php | 119 + system/helpers/captcha_helper.php | 246 ++ system/helpers/cookie_helper.php | 103 + system/helpers/date_helper.php | 611 ++++ system/helpers/directory_helper.php | 80 + system/helpers/download_helper.php | 107 + system/helpers/email_helper.php | 62 + system/helpers/file_helper.php | 479 +++ system/helpers/form_helper.php | 1054 +++++++ system/helpers/html_helper.php | 436 +++ system/helpers/index.html | 10 + system/helpers/inflector_helper.php | 203 ++ system/helpers/language_helper.php | 58 + system/helpers/number_helper.php | 76 + system/helpers/path_helper.php | 72 + system/helpers/security_helper.php | 128 + system/helpers/smiley_helper.php | 281 ++ system/helpers/string_helper.php | 307 ++ system/helpers/text_helper.php | 535 ++++ system/helpers/typography_helper.php | 93 + system/helpers/url_helper.php | 594 ++++ system/helpers/xml_helper.php | 71 + system/index.html | 10 + system/language/english/calendar_lang.php | 51 + system/language/english/date_lang.php | 61 + system/language/english/db_lang.php | 29 + system/language/english/email_lang.php | 24 + .../language/english/form_validation_lang.php | 29 + system/language/english/ftp_lang.php | 18 + system/language/english/imglib_lang.php | 24 + system/language/english/index.html | 10 + system/language/english/migration_lang.php | 13 + system/language/english/number_lang.php | 10 + system/language/english/profiler_lang.php | 25 + system/language/english/unit_test_lang.php | 25 + system/language/english/upload_lang.php | 22 + system/language/index.html | 10 + system/libraries/Cache/Cache.php | 214 ++ system/libraries/Cache/drivers/Cache_apc.php | 147 + .../libraries/Cache/drivers/Cache_dummy.php | 126 + system/libraries/Cache/drivers/Cache_file.php | 193 ++ .../Cache/drivers/Cache_memcached.php | 214 ++ system/libraries/Cache/drivers/index.html | 10 + system/libraries/Cache/index.html | 10 + system/libraries/Calendar.php | 475 +++ system/libraries/Cart.php | 551 ++++ system/libraries/Driver.php | 227 ++ system/libraries/Email.php | 2092 +++++++++++++ system/libraries/Encrypt.php | 500 +++ system/libraries/Form_validation.php | 1382 +++++++++ system/libraries/Ftp.php | 660 ++++ system/libraries/Image_lib.php | 1537 ++++++++++ system/libraries/Javascript.php | 871 ++++++ system/libraries/Log.php | 114 + system/libraries/Migration.php | 329 ++ system/libraries/Pagination.php | 340 +++ system/libraries/Parser.php | 212 ++ system/libraries/Profiler.php | 558 ++++ system/libraries/Session.php | 793 +++++ system/libraries/Sha1.php | 251 ++ system/libraries/Table.php | 531 ++++ system/libraries/Trackback.php | 548 ++++ system/libraries/Typography.php | 410 +++ system/libraries/Unit_test.php | 383 +++ system/libraries/Upload.php | 1136 +++++++ system/libraries/User_agent.php | 549 ++++ system/libraries/Xmlrpc.php | 1423 +++++++++ system/libraries/Xmlrpcs.php | 612 ++++ system/libraries/Zip.php | 423 +++ system/libraries/index.html | 10 + system/libraries/javascript/Jquery.php | 1071 +++++++ system/libraries/javascript/index.html | 10 + tests/bootstrap.php | 47 + tests/controllers/LoginControllerTest.php | 96 + tests/core/MyControllerTest.php | 26 + tests/env/SomeModelTest.php | 47 + tests/env/autoloader.php | 35 + tests/fixtures/todo_category_fixt.yml | 34 + tests/fixtures/todo_checklist_fixt.yml | 12 + tests/fixtures/todo_ci_sessions_fixt.yml | 21 + tests/fixtures/todo_group_fixt.yml | 19 + tests/fixtures/todo_group_task_link_fixt.yml | 6 + tests/fixtures/todo_group_users_link_fixt.yml | 24 + tests/fixtures/todo_item_comments_fixt.yml | 16 + tests/fixtures/todo_item_fixt.yml | 35 + tests/fixtures/todo_priority_fixt.yml | 36 + tests/fixtures/todo_reminder_fixt.yml | 6 + tests/fixtures/todo_status_fixt.yml | 20 + tests/fixtures/todo_task_view_fixt.yml | 13 + tests/fixtures/todo_user_fixt.yml | 30 + tests/fixtures/todo_user_friend_link_fixt.yml | 9 + tests/fixtures/todo_user_task_link_fixt.yml | 4 + tests/generate | 145 + tests/libs/MySessionLibTest.php | 59 + tests/libs/PageLibTest.php | 54 + tests/libs/TodoLibTest.php | 567 ++++ tests/models/FriendModelTest.php | 253 ++ tests/models/TaskModelTest.php | 620 ++++ tests/phpunit.xml | 41 + tests/system/PHPTest.php | 13 + web/css/images/animated-overlay.gif | Bin 0 -> 1738 bytes .../ui-bg_diagonals-thick_90_eeeeee_40x40.png | Bin 0 -> 312 bytes .../images/ui-bg_flat_15_cd0a0a_40x100.png | Bin 0 -> 206 bytes .../images/ui-bg_glass_100_e4f1fb_1x400.png | Bin 0 -> 350 bytes .../images/ui-bg_glass_50_3baae3_1x400.png | Bin 0 -> 336 bytes .../images/ui-bg_glass_80_d7ebf9_1x400.png | Bin 0 -> 346 bytes .../ui-bg_highlight-hard_100_f2f5f7_1x100.png | Bin 0 -> 332 bytes .../ui-bg_highlight-hard_70_000000_1x100.png | Bin 0 -> 249 bytes .../ui-bg_highlight-soft_100_deedf7_1x100.png | Bin 0 -> 387 bytes .../ui-bg_highlight-soft_25_ffef8f_1x100.png | Bin 0 -> 309 bytes web/css/images/ui-icons_2694e8_256x240.png | Bin 0 -> 4549 bytes web/css/images/ui-icons_2e83ff_256x240.png | Bin 0 -> 4549 bytes web/css/images/ui-icons_3d80b3_256x240.png | Bin 0 -> 4549 bytes web/css/images/ui-icons_72a7cf_256x240.png | Bin 0 -> 4549 bytes web/css/images/ui-icons_ffffff_256x240.png | Bin 0 -> 6299 bytes web/css/jquery-ui.min.css | 1382 +++++++++ web/css/message.css | 37 + web/css/todo.css | 760 +++++ web/famfamfam.css | 1015 ++++++ web/favicon.ico | Bin 0 -> 1406 bytes web/fonts/Puritan/Puritan_Bold-cufon.js | 9 + web/fonts/Puritan/Puritan_Bold-webfont.eot | Bin 0 -> 42630 bytes web/fonts/Puritan/Puritan_Bold-webfont.svg | 228 ++ web/fonts/Puritan/Puritan_Bold-webfont.ttf | Bin 0 -> 42464 bytes web/fonts/Puritan/Puritan_Bold-webfont.woff | Bin 0 -> 24088 bytes .../Puritan/Puritan_Bold_Italic-cufon.js | 9 + .../Puritan/Puritan_Bold_Italic-webfont.eot | Bin 0 -> 47330 bytes .../Puritan/Puritan_Bold_Italic-webfont.svg | 228 ++ .../Puritan/Puritan_Bold_Italic-webfont.ttf | Bin 0 -> 47164 bytes .../Puritan/Puritan_Bold_Italic-webfont.woff | Bin 0 -> 26096 bytes web/fonts/Puritan/Puritan_Italic-cufon.js | 9 + web/fonts/Puritan/Puritan_Italic-webfont.eot | Bin 0 -> 47770 bytes web/fonts/Puritan/Puritan_Italic-webfont.svg | 228 ++ web/fonts/Puritan/Puritan_Italic-webfont.ttf | Bin 0 -> 47604 bytes web/fonts/Puritan/Puritan_Italic-webfont.woff | Bin 0 -> 25828 bytes web/fonts/Puritan/Puritan_Regular-cufon.js | 9 + web/fonts/Puritan/Puritan_Regular-webfont.eot | Bin 0 -> 43178 bytes web/fonts/Puritan/Puritan_Regular-webfont.svg | 228 ++ web/fonts/Puritan/Puritan_Regular-webfont.ttf | Bin 0 -> 43012 bytes .../Puritan/Puritan_Regular-webfont.woff | Bin 0 -> 23548 bytes .../Puritan/SIL Open Font License 1.1.txt | 91 + web/fonts/Puritan/demo.html | 48 + web/fonts/Puritan/stylesheet.css | 32 + web/fonts/Quicksand/Quicksand License.txt | 5 + web/fonts/Quicksand/Quicksand_Bold-cufon.js | 16 + .../Quicksand/Quicksand_Bold-webfont.eot | Bin 0 -> 47982 bytes .../Quicksand/Quicksand_Bold-webfont.svg | 221 ++ .../Quicksand/Quicksand_Bold-webfont.ttf | Bin 0 -> 47780 bytes .../Quicksand/Quicksand_Bold-webfont.woff | Bin 0 -> 24900 bytes .../Quicksand/Quicksand_Bold_Oblique-cufon.js | 16 + .../Quicksand_Bold_Oblique-webfont.eot | Bin 0 -> 50498 bytes .../Quicksand_Bold_Oblique-webfont.svg | 215 ++ .../Quicksand_Bold_Oblique-webfont.ttf | Bin 0 -> 50264 bytes .../Quicksand_Bold_Oblique-webfont.woff | Bin 0 -> 24512 bytes web/fonts/Quicksand/Quicksand_Book-cufon.js | 16 + .../Quicksand/Quicksand_Book-webfont.eot | Bin 0 -> 46380 bytes .../Quicksand/Quicksand_Book-webfont.svg | 225 ++ .../Quicksand/Quicksand_Book-webfont.ttf | Bin 0 -> 46196 bytes .../Quicksand/Quicksand_Book-webfont.woff | Bin 0 -> 24724 bytes .../Quicksand/Quicksand_Book_Oblique-cufon.js | 16 + .../Quicksand_Book_Oblique-webfont.eot | Bin 0 -> 54720 bytes .../Quicksand_Book_Oblique-webfont.svg | 216 ++ .../Quicksand_Book_Oblique-webfont.ttf | Bin 0 -> 54504 bytes .../Quicksand_Book_Oblique-webfont.woff | Bin 0 -> 26520 bytes web/fonts/Quicksand/Quicksand_Dash-cufon.js | 16 + .../Quicksand/Quicksand_Dash-webfont.eot | Bin 0 -> 50180 bytes .../Quicksand/Quicksand_Dash-webfont.svg | 130 + .../Quicksand/Quicksand_Dash-webfont.ttf | Bin 0 -> 49996 bytes .../Quicksand/Quicksand_Dash-webfont.woff | Bin 0 -> 27728 bytes web/fonts/Quicksand/Quicksand_Light-cufon.js | 16 + .../Quicksand/Quicksand_Light-webfont.eot | Bin 0 -> 42716 bytes .../Quicksand/Quicksand_Light-webfont.svg | 215 ++ .../Quicksand/Quicksand_Light-webfont.ttf | Bin 0 -> 42528 bytes .../Quicksand/Quicksand_Light-webfont.woff | Bin 0 -> 23160 bytes .../Quicksand_Light_Oblique-cufon.js | 16 + .../Quicksand_Light_Oblique-webfont.eot | Bin 0 -> 54028 bytes .../Quicksand_Light_Oblique-webfont.svg | 212 ++ .../Quicksand_Light_Oblique-webfont.ttf | Bin 0 -> 53808 bytes .../Quicksand_Light_Oblique-webfont.woff | Bin 0 -> 26288 bytes web/fonts/Quicksand/demo.html | 63 + web/fonts/Quicksand/stylesheet.css | 60 + web/google522e2aaa807852ba.html | 1 + web/images/ajax-loader.gif | Bin 0 -> 7247 bytes web/images/bgs/Title.png | Bin 0 -> 196 bytes web/images/bgs/TitleBG.png | Bin 0 -> 425 bytes web/images/bgs/blue2.png | Bin 0 -> 337 bytes web/images/bgs/blue3.png | Bin 0 -> 396 bytes web/images/famfamfam.png | Bin 0 -> 285860 bytes web/images/favicon.ico | Bin 0 -> 1406 bytes web/images/icons/accept.png | Bin 0 -> 781 bytes web/images/icons/add.png | Bin 0 -> 733 bytes web/images/icons/anchor.png | Bin 0 -> 523 bytes web/images/icons/application.png | Bin 0 -> 464 bytes web/images/icons/arrow_branch.png | Bin 0 -> 582 bytes web/images/icons/arrow_divide.png | Bin 0 -> 677 bytes web/images/icons/arrow_down.png | Bin 0 -> 379 bytes web/images/icons/arrow_in.png | Bin 0 -> 600 bytes web/images/icons/arrow_inout.png | Bin 0 -> 551 bytes web/images/icons/arrow_join.png | Bin 0 -> 626 bytes web/images/icons/arrow_left.png | Bin 0 -> 345 bytes web/images/icons/arrow_merge.png | Bin 0 -> 484 bytes web/images/icons/arrow_out.png | Bin 0 -> 594 bytes web/images/icons/arrow_redo.png | Bin 0 -> 625 bytes web/images/icons/arrow_refresh.png | Bin 0 -> 685 bytes web/images/icons/arrow_refresh_small.png | Bin 0 -> 506 bytes web/images/icons/arrow_right.png | Bin 0 -> 349 bytes .../icons/arrow_rotate_anticlockwise.png | Bin 0 -> 608 bytes web/images/icons/arrow_rotate_clockwise.png | Bin 0 -> 602 bytes web/images/icons/arrow_switch.png | Bin 0 -> 683 bytes web/images/icons/arrow_turn_left.png | Bin 0 -> 516 bytes web/images/icons/arrow_turn_right.png | Bin 0 -> 489 bytes web/images/icons/arrow_undo.png | Bin 0 -> 631 bytes web/images/icons/arrow_up.png | Bin 0 -> 372 bytes web/images/icons/asterisk_orange.png | Bin 0 -> 760 bytes web/images/icons/asterisk_yellow.png | Bin 0 -> 743 bytes web/images/icons/attach.png | Bin 0 -> 391 bytes web/images/icons/award_star_add.png | Bin 0 -> 853 bytes web/images/icons/award_star_bronze_1.png | Bin 0 -> 733 bytes web/images/icons/award_star_bronze_2.png | Bin 0 -> 755 bytes web/images/icons/award_star_bronze_3.png | Bin 0 -> 754 bytes web/images/icons/award_star_delete.png | Bin 0 -> 849 bytes web/images/icons/award_star_gold_1.png | Bin 0 -> 753 bytes web/images/icons/award_star_gold_2.png | Bin 0 -> 770 bytes web/images/icons/award_star_gold_3.png | Bin 0 -> 781 bytes web/images/icons/award_star_silver_1.png | Bin 0 -> 714 bytes web/images/icons/award_star_silver_2.png | Bin 0 -> 734 bytes web/images/icons/award_star_silver_3.png | Bin 0 -> 738 bytes web/images/icons/basket.png | Bin 0 -> 669 bytes web/images/icons/basket_add.png | Bin 0 -> 752 bytes web/images/icons/basket_delete.png | Bin 0 -> 773 bytes web/images/icons/basket_edit.png | Bin 0 -> 811 bytes web/images/icons/basket_error.png | Bin 0 -> 794 bytes web/images/icons/basket_go.png | Bin 0 -> 777 bytes web/images/icons/basket_put.png | Bin 0 -> 733 bytes web/images/icons/basket_remove.png | Bin 0 -> 738 bytes web/images/icons/bell.png | Bin 0 -> 789 bytes web/images/icons/bell_add.png | Bin 0 -> 816 bytes web/images/icons/bell_delete.png | Bin 0 -> 824 bytes web/images/icons/bell_error.png | Bin 0 -> 813 bytes web/images/icons/bell_go.png | Bin 0 -> 836 bytes web/images/icons/bell_link.png | Bin 0 -> 850 bytes web/images/icons/bin.png | Bin 0 -> 476 bytes web/images/icons/bin_closed.png | Bin 0 -> 363 bytes web/images/icons/bin_empty.png | Bin 0 -> 475 bytes web/images/icons/bomb.png | Bin 0 -> 793 bytes web/images/icons/book.png | Bin 0 -> 593 bytes web/images/icons/book_add.png | Bin 0 -> 714 bytes web/images/icons/book_addresses.png | Bin 0 -> 770 bytes web/images/icons/book_delete.png | Bin 0 -> 719 bytes web/images/icons/book_edit.png | Bin 0 -> 813 bytes web/images/icons/book_error.png | Bin 0 -> 734 bytes web/images/icons/book_go.png | Bin 0 -> 745 bytes web/images/icons/book_key.png | Bin 0 -> 779 bytes web/images/icons/book_link.png | Bin 0 -> 789 bytes web/images/icons/book_next.png | Bin 0 -> 702 bytes web/images/icons/book_open.png | Bin 0 -> 622 bytes web/images/icons/book_previous.png | Bin 0 -> 680 bytes web/images/icons/box.png | Bin 0 -> 555 bytes web/images/icons/brick.png | Bin 0 -> 452 bytes web/images/icons/brick_add.png | Bin 0 -> 729 bytes web/images/icons/brick_delete.png | Bin 0 -> 745 bytes web/images/icons/brick_edit.png | Bin 0 -> 775 bytes web/images/icons/brick_error.png | Bin 0 -> 798 bytes web/images/icons/brick_go.png | Bin 0 -> 790 bytes web/images/icons/brick_link.png | Bin 0 -> 764 bytes web/images/icons/bricks.png | Bin 0 -> 825 bytes web/images/icons/briefcase.png | Bin 0 -> 793 bytes web/images/icons/bug.png | Bin 0 -> 774 bytes web/images/icons/bug_add.png | Bin 0 -> 806 bytes web/images/icons/bug_delete.png | Bin 0 -> 836 bytes web/images/icons/bug_edit.png | Bin 0 -> 873 bytes web/images/icons/bug_error.png | Bin 0 -> 841 bytes web/images/icons/bug_go.png | Bin 0 -> 831 bytes web/images/icons/bug_link.png | Bin 0 -> 847 bytes web/images/icons/building.png | Bin 0 -> 556 bytes web/images/icons/building_add.png | Bin 0 -> 631 bytes web/images/icons/building_delete.png | Bin 0 -> 633 bytes web/images/icons/building_edit.png | Bin 0 -> 731 bytes web/images/icons/building_error.png | Bin 0 -> 653 bytes web/images/icons/building_go.png | Bin 0 -> 665 bytes web/images/icons/building_key.png | Bin 0 -> 705 bytes web/images/icons/building_link.png | Bin 0 -> 668 bytes web/images/icons/bullet_add.png | Bin 0 -> 286 bytes web/images/icons/bullet_arrow_bottom.png | Bin 0 -> 229 bytes web/images/icons/bullet_arrow_down.png | Bin 0 -> 201 bytes web/images/icons/bullet_arrow_top.png | Bin 0 -> 230 bytes web/images/icons/bullet_arrow_up.png | Bin 0 -> 201 bytes web/images/icons/bullet_black.png | Bin 0 -> 211 bytes web/images/icons/bullet_blue.png | Bin 0 -> 289 bytes web/images/icons/bullet_delete.png | Bin 0 -> 308 bytes web/images/icons/bullet_disk.png | Bin 0 -> 483 bytes web/images/icons/bullet_error.png | Bin 0 -> 454 bytes web/images/icons/bullet_feed.png | Bin 0 -> 262 bytes web/images/icons/bullet_go.png | Bin 0 -> 410 bytes web/images/icons/bullet_green.png | Bin 0 -> 295 bytes web/images/icons/bullet_key.png | Bin 0 -> 436 bytes web/images/icons/bullet_orange.png | Bin 0 -> 283 bytes web/images/icons/bullet_picture.png | Bin 0 -> 470 bytes web/images/icons/bullet_pink.png | Bin 0 -> 286 bytes web/images/icons/bullet_purple.png | Bin 0 -> 294 bytes web/images/icons/bullet_red.png | Bin 0 -> 287 bytes web/images/icons/bullet_star.png | Bin 0 -> 331 bytes web/images/icons/bullet_toggle_minus.png | Bin 0 -> 207 bytes web/images/icons/bullet_toggle_plus.png | Bin 0 -> 209 bytes web/images/icons/bullet_white.png | Bin 0 -> 201 bytes web/images/icons/bullet_wrench.png | Bin 0 -> 448 bytes web/images/icons/bullet_yellow.png | Bin 0 -> 287 bytes web/images/icons/cake.png | Bin 0 -> 676 bytes web/images/icons/calculator.png | Bin 0 -> 543 bytes web/images/icons/calculator_add.png | Bin 0 -> 660 bytes web/images/icons/calculator_delete.png | Bin 0 -> 692 bytes web/images/icons/calculator_edit.png | Bin 0 -> 767 bytes web/images/icons/calculator_error.png | Bin 0 -> 731 bytes web/images/icons/calculator_link.png | Bin 0 -> 723 bytes web/images/icons/calendar.png | Bin 0 -> 675 bytes web/images/icons/calendar_add.png | Bin 0 -> 723 bytes web/images/icons/calendar_delete.png | Bin 0 -> 742 bytes web/images/icons/calendar_edit.png | Bin 0 -> 777 bytes web/images/icons/calendar_link.png | Bin 0 -> 795 bytes web/images/icons/calendar_view_day.png | Bin 0 -> 572 bytes web/images/icons/calendar_view_month.png | Bin 0 -> 595 bytes web/images/icons/calendar_view_week.png | Bin 0 -> 480 bytes web/images/icons/camera.png | Bin 0 -> 665 bytes web/images/icons/camera_add.png | Bin 0 -> 800 bytes web/images/icons/camera_delete.png | Bin 0 -> 797 bytes web/images/icons/camera_edit.png | Bin 0 -> 872 bytes web/images/icons/camera_error.png | Bin 0 -> 835 bytes web/images/icons/camera_go.png | Bin 0 -> 809 bytes web/images/icons/camera_link.png | Bin 0 -> 839 bytes web/images/icons/camera_small.png | Bin 0 -> 489 bytes web/images/icons/cancel.png | Bin 0 -> 587 bytes web/images/icons/car.png | Bin 0 -> 610 bytes web/images/icons/car_add.png | Bin 0 -> 677 bytes web/images/icons/car_delete.png | Bin 0 -> 689 bytes web/images/icons/cart.png | Bin 0 -> 421 bytes web/images/icons/cart_add.png | Bin 0 -> 711 bytes web/images/icons/cart_delete.png | Bin 0 -> 742 bytes web/images/icons/cart_edit.png | Bin 0 -> 789 bytes web/images/icons/cart_error.png | Bin 0 -> 790 bytes web/images/icons/cart_go.png | Bin 0 -> 763 bytes web/images/icons/cart_put.png | Bin 0 -> 763 bytes web/images/icons/cart_remove.png | Bin 0 -> 769 bytes web/images/icons/cd.png | Bin 0 -> 673 bytes web/images/icons/cd_add.png | Bin 0 -> 758 bytes web/images/icons/cd_burn.png | Bin 0 -> 756 bytes web/images/icons/cd_delete.png | Bin 0 -> 767 bytes web/images/icons/cd_edit.png | Bin 0 -> 790 bytes web/images/icons/cd_eject.png | Bin 0 -> 786 bytes web/images/icons/cd_go.png | Bin 0 -> 793 bytes web/images/icons/chart_bar.png | Bin 0 -> 541 bytes web/images/icons/chart_bar_add.png | Bin 0 -> 626 bytes web/images/icons/chart_bar_delete.png | Bin 0 -> 636 bytes web/images/icons/chart_bar_edit.png | Bin 0 -> 754 bytes web/images/icons/chart_bar_error.png | Bin 0 -> 671 bytes web/images/icons/chart_bar_link.png | Bin 0 -> 712 bytes web/images/icons/chart_curve.png | Bin 0 -> 710 bytes web/images/icons/chart_curve_add.png | Bin 0 -> 761 bytes web/images/icons/chart_curve_delete.png | Bin 0 -> 782 bytes web/images/icons/chart_curve_edit.png | Bin 0 -> 822 bytes web/images/icons/chart_curve_error.png | Bin 0 -> 837 bytes web/images/icons/chart_curve_go.png | Bin 0 -> 823 bytes web/images/icons/chart_curve_link.png | Bin 0 -> 829 bytes web/images/icons/chart_line.png | Bin 0 -> 526 bytes web/images/icons/chart_line_add.png | Bin 0 -> 655 bytes web/images/icons/chart_line_delete.png | Bin 0 -> 675 bytes web/images/icons/chart_line_edit.png | Bin 0 -> 718 bytes web/images/icons/chart_line_error.png | Bin 0 -> 741 bytes web/images/icons/chart_line_link.png | Bin 0 -> 749 bytes web/images/icons/chart_organisation.png | Bin 0 -> 444 bytes web/images/icons/chart_organisation_add.png | Bin 0 -> 551 bytes .../icons/chart_organisation_delete.png | Bin 0 -> 563 bytes web/images/icons/chart_pie.png | Bin 0 -> 918 bytes web/images/icons/chart_pie_add.png | Bin 0 -> 975 bytes web/images/icons/chart_pie_delete.png | Bin 0 -> 983 bytes web/images/icons/chart_pie_edit.png | Bin 0 -> 986 bytes web/images/icons/chart_pie_error.png | Bin 0 -> 989 bytes web/images/icons/chart_pie_link.png | Bin 0 -> 1021 bytes web/images/icons/circular/add.png | Bin 0 -> 634 bytes web/images/icons/circular/arrow_down.png | Bin 0 -> 724 bytes web/images/icons/circular/arrow_left.png | Bin 0 -> 739 bytes web/images/icons/circular/arrow_right.png | Bin 0 -> 744 bytes web/images/icons/circular/arrow_up.png | Bin 0 -> 731 bytes web/images/icons/circular/arrows_4_way.png | Bin 0 -> 817 bytes .../icons/circular/arrows_east_west.png | Bin 0 -> 744 bytes .../icons/circular/arrows_north_east.png | Bin 0 -> 736 bytes .../icons/circular/arrows_north_south.png | Bin 0 -> 754 bytes .../icons/circular/arrows_south_west.png | Bin 0 -> 734 bytes web/images/icons/circular/at.png | Bin 0 -> 1001 bytes web/images/icons/circular/book.png | Bin 0 -> 794 bytes web/images/icons/circular/broadcast.png | Bin 0 -> 849 bytes web/images/icons/circular/bulb.png | Bin 0 -> 889 bytes web/images/icons/circular/bullet_black.png | Bin 0 -> 296 bytes web/images/icons/circular/bullet_blue.png | Bin 0 -> 311 bytes web/images/icons/circular/bullet_green.png | Bin 0 -> 311 bytes web/images/icons/circular/bullet_red.png | Bin 0 -> 311 bytes web/images/icons/circular/bullet_yellow.png | Bin 0 -> 301 bytes web/images/icons/circular/cancel.png | Bin 0 -> 971 bytes web/images/icons/circular/cart.png | Bin 0 -> 746 bytes web/images/icons/circular/cd.png | Bin 0 -> 964 bytes web/images/icons/circular/clock.png | Bin 0 -> 852 bytes web/images/icons/circular/cog.png | Bin 0 -> 925 bytes web/images/icons/circular/comment.png | Bin 0 -> 761 bytes web/images/icons/circular/comments.png | Bin 0 -> 840 bytes web/images/icons/circular/copy.png | Bin 0 -> 785 bytes web/images/icons/circular/copyright.png | Bin 0 -> 852 bytes web/images/icons/circular/currency_eur.png | Bin 0 -> 768 bytes web/images/icons/circular/currency_gbp.png | Bin 0 -> 788 bytes web/images/icons/circular/currency_jpn.png | Bin 0 -> 790 bytes web/images/icons/circular/currency_usd.png | Bin 0 -> 776 bytes web/images/icons/circular/cut.png | Bin 0 -> 927 bytes web/images/icons/circular/delete.png | Bin 0 -> 843 bytes web/images/icons/circular/edit.png | Bin 0 -> 845 bytes web/images/icons/circular/element_clouds.png | Bin 0 -> 742 bytes web/images/icons/circular/element_fire.png | Bin 0 -> 852 bytes .../icons/circular/element_lightning.png | Bin 0 -> 849 bytes .../icons/circular/element_rain_clouds.png | Bin 0 -> 885 bytes web/images/icons/circular/element_sun.png | Bin 0 -> 988 bytes .../icons/circular/element_sun_cloud.png | Bin 0 -> 793 bytes web/images/icons/circular/element_water.png | Bin 0 -> 811 bytes web/images/icons/circular/email.png | Bin 0 -> 824 bytes web/images/icons/circular/eye.png | Bin 0 -> 929 bytes web/images/icons/circular/fast_forward.png | Bin 0 -> 763 bytes web/images/icons/circular/flag_black.png | Bin 0 -> 796 bytes web/images/icons/circular/flag_blue.png | Bin 0 -> 786 bytes web/images/icons/circular/flag_green.png | Bin 0 -> 786 bytes web/images/icons/circular/flag_red.png | Bin 0 -> 794 bytes web/images/icons/circular/flag_yellow.png | Bin 0 -> 790 bytes web/images/icons/circular/folder.png | Bin 0 -> 739 bytes web/images/icons/circular/folder_close.png | Bin 0 -> 840 bytes web/images/icons/circular/folder_document.png | Bin 0 -> 775 bytes web/images/icons/circular/folder_open.png | Bin 0 -> 861 bytes web/images/icons/circular/heart_black.png | Bin 0 -> 805 bytes web/images/icons/circular/heart_blue.png | Bin 0 -> 849 bytes web/images/icons/circular/heart_green.png | Bin 0 -> 867 bytes web/images/icons/circular/heart_red.png | Bin 0 -> 872 bytes web/images/icons/circular/heart_yellow.png | Bin 0 -> 789 bytes web/images/icons/circular/help.png | Bin 0 -> 780 bytes web/images/icons/circular/home.png | Bin 0 -> 776 bytes web/images/icons/circular/hourglass.png | Bin 0 -> 839 bytes web/images/icons/circular/information.png | Bin 0 -> 678 bytes web/images/icons/circular/key.png | Bin 0 -> 822 bytes web/images/icons/circular/magnify.png | Bin 0 -> 894 bytes web/images/icons/circular/magnify_minus.png | Bin 0 -> 927 bytes web/images/icons/circular/magnify_plus.png | Bin 0 -> 935 bytes web/images/icons/circular/minus.png | Bin 0 -> 725 bytes web/images/icons/circular/moon.png | Bin 0 -> 778 bytes web/images/icons/circular/music.png | Bin 0 -> 748 bytes web/images/icons/circular/new.png | Bin 0 -> 749 bytes web/images/icons/circular/no.png | Bin 0 -> 894 bytes web/images/icons/circular/omega.png | Bin 0 -> 771 bytes web/images/icons/circular/padlock_closed.png | Bin 0 -> 716 bytes web/images/icons/circular/padlock_open.png | Bin 0 -> 733 bytes web/images/icons/circular/paperclip.png | Bin 0 -> 800 bytes web/images/icons/circular/paste.png | Bin 0 -> 752 bytes web/images/icons/circular/pause.png | Bin 0 -> 643 bytes web/images/icons/circular/phone.png | Bin 0 -> 833 bytes web/images/icons/circular/pie_chart.png | Bin 0 -> 876 bytes web/images/icons/circular/play.png | Bin 0 -> 734 bytes web/images/icons/circular/pointer.png | Bin 0 -> 724 bytes web/images/icons/circular/power_off.png | Bin 0 -> 877 bytes web/images/icons/circular/power_on.png | Bin 0 -> 857 bytes web/images/icons/circular/print.png | Bin 0 -> 781 bytes web/images/icons/circular/puzzle.png | Bin 0 -> 775 bytes web/images/icons/circular/quote.png | Bin 0 -> 761 bytes web/images/icons/circular/refresh.png | Bin 0 -> 903 bytes web/images/icons/circular/rewind.png | Bin 0 -> 727 bytes web/images/icons/circular/rss.png | Bin 0 -> 781 bytes web/images/icons/circular/save.png | Bin 0 -> 756 bytes web/images/icons/circular/share_this.png | Bin 0 -> 893 bytes web/images/icons/circular/smiley_big_grin.png | Bin 0 -> 751 bytes web/images/icons/circular/smiley_flat.png | Bin 0 -> 648 bytes web/images/icons/circular/smiley_frown.png | Bin 0 -> 733 bytes web/images/icons/circular/smiley_smile.png | Bin 0 -> 731 bytes web/images/icons/circular/smiley_tounge.png | Bin 0 -> 713 bytes web/images/icons/circular/smiley_wink.png | Bin 0 -> 765 bytes web/images/icons/circular/speaker_off.png | Bin 0 -> 742 bytes web/images/icons/circular/speaker_on.png | Bin 0 -> 915 bytes web/images/icons/circular/star_black.png | Bin 0 -> 799 bytes web/images/icons/circular/star_blue.png | Bin 0 -> 783 bytes web/images/icons/circular/star_green.png | Bin 0 -> 810 bytes web/images/icons/circular/star_red.png | Bin 0 -> 811 bytes web/images/icons/circular/star_yellow.png | Bin 0 -> 753 bytes web/images/icons/circular/stop.png | Bin 0 -> 713 bytes web/images/icons/circular/tag_black.png | Bin 0 -> 817 bytes web/images/icons/circular/tag_blue.png | Bin 0 -> 781 bytes web/images/icons/circular/tag_green.png | Bin 0 -> 776 bytes web/images/icons/circular/tag_red.png | Bin 0 -> 792 bytes web/images/icons/circular/tag_yellow.png | Bin 0 -> 786 bytes web/images/icons/circular/turn_left.png | Bin 0 -> 907 bytes web/images/icons/circular/turn_right.png | Bin 0 -> 903 bytes web/images/icons/circular/user.png | Bin 0 -> 869 bytes web/images/icons/circular/warning.png | Bin 0 -> 713 bytes web/images/icons/circular/world.png | Bin 0 -> 881 bytes web/images/icons/circular/yes.png | Bin 0 -> 781 bytes web/images/icons/clock.png | Bin 0 -> 882 bytes web/images/icons/clock_add.png | Bin 0 -> 925 bytes web/images/icons/clock_delete.png | Bin 0 -> 952 bytes web/images/icons/clock_edit.png | Bin 0 -> 967 bytes web/images/icons/clock_error.png | Bin 0 -> 953 bytes web/images/icons/clock_go.png | Bin 0 -> 959 bytes web/images/icons/clock_link.png | Bin 0 -> 961 bytes web/images/icons/clock_pause.png | Bin 0 -> 927 bytes web/images/icons/clock_play.png | Bin 0 -> 943 bytes web/images/icons/clock_red.png | Bin 0 -> 889 bytes web/images/icons/clock_stop.png | Bin 0 -> 922 bytes web/images/icons/cog.png | Bin 0 -> 512 bytes web/images/icons/cog_add.png | Bin 0 -> 814 bytes web/images/icons/cog_delete.png | Bin 0 -> 847 bytes web/images/icons/cog_edit.png | Bin 0 -> 865 bytes web/images/icons/cog_error.png | Bin 0 -> 869 bytes web/images/icons/cog_go.png | Bin 0 -> 859 bytes web/images/icons/coins.png | Bin 0 -> 732 bytes web/images/icons/coins_add.png | Bin 0 -> 789 bytes web/images/icons/coins_delete.png | Bin 0 -> 775 bytes web/images/icons/color_swatch.png | Bin 0 -> 209 bytes web/images/icons/color_wheel.png | Bin 0 -> 892 bytes web/images/icons/comment.png | Bin 0 -> 413 bytes web/images/icons/comment_add.png | Bin 0 -> 530 bytes web/images/icons/comment_delete.png | Bin 0 -> 548 bytes web/images/icons/comment_edit.png | Bin 0 -> 644 bytes web/images/icons/comments.png | Bin 0 -> 557 bytes web/images/icons/comments_add.png | Bin 0 -> 648 bytes web/images/icons/comments_delete.png | Bin 0 -> 670 bytes web/images/icons/compress.png | Bin 0 -> 766 bytes web/images/icons/computer.png | Bin 0 -> 667 bytes web/images/icons/computer_add.png | Bin 0 -> 781 bytes web/images/icons/computer_delete.png | Bin 0 -> 775 bytes web/images/icons/computer_edit.png | Bin 0 -> 792 bytes web/images/icons/computer_error.png | Bin 0 -> 784 bytes web/images/icons/computer_go.png | Bin 0 -> 777 bytes web/images/icons/computer_key.png | Bin 0 -> 771 bytes web/images/icons/computer_link.png | Bin 0 -> 792 bytes web/images/icons/connect.png | Bin 0 -> 748 bytes web/images/icons/contrast.png | Bin 0 -> 434 bytes web/images/icons/contrast_decrease.png | Bin 0 -> 695 bytes web/images/icons/contrast_high.png | Bin 0 -> 435 bytes web/images/icons/contrast_increase.png | Bin 0 -> 717 bytes web/images/icons/contrast_low.png | Bin 0 -> 421 bytes web/images/icons/control_eject.png | Bin 0 -> 603 bytes web/images/icons/control_eject_blue.png | Bin 0 -> 727 bytes web/images/icons/control_end.png | Bin 0 -> 621 bytes web/images/icons/control_end_blue.png | Bin 0 -> 737 bytes web/images/icons/control_equalizer.png | Bin 0 -> 432 bytes web/images/icons/control_equalizer_blue.png | Bin 0 -> 764 bytes web/images/icons/control_fastforward.png | Bin 0 -> 607 bytes web/images/icons/control_fastforward_blue.png | Bin 0 -> 736 bytes web/images/icons/control_pause.png | Bin 0 -> 598 bytes web/images/icons/control_pause_blue.png | Bin 0 -> 721 bytes web/images/icons/control_play.png | Bin 0 -> 592 bytes web/images/icons/control_play_blue.png | Bin 0 -> 717 bytes web/images/icons/control_repeat.png | Bin 0 -> 422 bytes web/images/icons/control_repeat_blue.png | Bin 0 -> 750 bytes web/images/icons/control_rewind.png | Bin 0 -> 614 bytes web/images/icons/control_rewind_blue.png | Bin 0 -> 745 bytes web/images/icons/control_start.png | Bin 0 -> 604 bytes web/images/icons/control_start_blue.png | Bin 0 -> 720 bytes web/images/icons/control_stop.png | Bin 0 -> 403 bytes web/images/icons/control_stop_blue.png | Bin 0 -> 695 bytes web/images/icons/controller.png | Bin 0 -> 666 bytes web/images/icons/controller_add.png | Bin 0 -> 759 bytes web/images/icons/controller_delete.png | Bin 0 -> 770 bytes web/images/icons/controller_error.png | Bin 0 -> 815 bytes web/images/icons/creditcards.png | Bin 0 -> 693 bytes web/images/icons/cross.png | Bin 0 -> 655 bytes web/images/icons/css.png | Bin 0 -> 524 bytes web/images/icons/css_add.png | Bin 0 -> 666 bytes web/images/icons/css_delete.png | Bin 0 -> 654 bytes web/images/icons/css_go.png | Bin 0 -> 655 bytes web/images/icons/css_valid.png | Bin 0 -> 661 bytes web/images/icons/cup.png | Bin 0 -> 633 bytes web/images/icons/cup_add.png | Bin 0 -> 715 bytes web/images/icons/cup_delete.png | Bin 0 -> 731 bytes web/images/icons/cup_edit.png | Bin 0 -> 778 bytes web/images/icons/cup_error.png | Bin 0 -> 790 bytes web/images/icons/cup_go.png | Bin 0 -> 780 bytes web/images/icons/cup_key.png | Bin 0 -> 776 bytes web/images/icons/cup_link.png | Bin 0 -> 760 bytes web/images/icons/cursor.png | Bin 0 -> 354 bytes web/images/icons/cut.png | Bin 0 -> 648 bytes web/images/icons/cut_red.png | Bin 0 -> 650 bytes web/images/icons/database.png | Bin 0 -> 390 bytes web/images/icons/database_add.png | Bin 0 -> 658 bytes web/images/icons/database_connect.png | Bin 0 -> 763 bytes web/images/icons/database_delete.png | Bin 0 -> 659 bytes web/images/icons/database_edit.png | Bin 0 -> 767 bytes web/images/icons/database_error.png | Bin 0 -> 682 bytes web/images/icons/database_gear.png | Bin 0 -> 468 bytes web/images/icons/database_go.png | Bin 0 -> 698 bytes web/images/icons/database_key.png | Bin 0 -> 764 bytes web/images/icons/database_lightning.png | Bin 0 -> 775 bytes web/images/icons/database_link.png | Bin 0 -> 679 bytes web/images/icons/database_refresh.png | Bin 0 -> 770 bytes web/images/icons/database_save.png | Bin 0 -> 755 bytes web/images/icons/database_table.png | Bin 0 -> 726 bytes web/images/icons/date.png | Bin 0 -> 626 bytes web/images/icons/date_add.png | Bin 0 -> 703 bytes web/images/icons/date_delete.png | Bin 0 -> 716 bytes web/images/icons/date_edit.png | Bin 0 -> 799 bytes web/images/icons/date_error.png | Bin 0 -> 753 bytes web/images/icons/date_go.png | Bin 0 -> 753 bytes web/images/icons/date_link.png | Bin 0 -> 764 bytes web/images/icons/date_magnify.png | Bin 0 -> 711 bytes web/images/icons/date_next.png | Bin 0 -> 688 bytes web/images/icons/date_previous.png | Bin 0 -> 720 bytes web/images/icons/delete.png | Bin 0 -> 715 bytes web/images/icons/disconnect.png | Bin 0 -> 796 bytes web/images/icons/disk.png | Bin 0 -> 620 bytes web/images/icons/disk_multiple.png | Bin 0 -> 691 bytes web/images/icons/door.png | Bin 0 -> 412 bytes web/images/icons/door_in.png | Bin 0 -> 693 bytes web/images/icons/door_open.png | Bin 0 -> 508 bytes web/images/icons/door_out.png | Bin 0 -> 688 bytes web/images/icons/drink.png | Bin 0 -> 692 bytes web/images/icons/drink_empty.png | Bin 0 -> 433 bytes web/images/icons/drive.png | Bin 0 -> 346 bytes web/images/icons/drive_add.png | Bin 0 -> 623 bytes web/images/icons/drive_burn.png | Bin 0 -> 608 bytes web/images/icons/drive_cd.png | Bin 0 -> 734 bytes web/images/icons/drive_cd_empty.png | Bin 0 -> 341 bytes web/images/icons/drive_delete.png | Bin 0 -> 628 bytes web/images/icons/drive_disk.png | Bin 0 -> 695 bytes web/images/icons/drive_edit.png | Bin 0 -> 714 bytes web/images/icons/drive_error.png | Bin 0 -> 705 bytes web/images/icons/drive_go.png | Bin 0 -> 661 bytes web/images/icons/drive_key.png | Bin 0 -> 681 bytes web/images/icons/drive_link.png | Bin 0 -> 679 bytes web/images/icons/drive_magnify.png | Bin 0 -> 641 bytes web/images/icons/drive_network.png | Bin 0 -> 585 bytes web/images/icons/drive_rename.png | Bin 0 -> 494 bytes web/images/icons/drive_user.png | Bin 0 -> 712 bytes web/images/icons/drive_web.png | Bin 0 -> 686 bytes web/images/icons/dvd.png | Bin 0 -> 764 bytes web/images/icons/dvd_add.png | Bin 0 -> 788 bytes web/images/icons/dvd_delete.png | Bin 0 -> 800 bytes web/images/icons/dvd_edit.png | Bin 0 -> 844 bytes web/images/icons/dvd_error.png | Bin 0 -> 854 bytes web/images/icons/dvd_go.png | Bin 0 -> 854 bytes web/images/icons/dvd_key.png | Bin 0 -> 816 bytes web/images/icons/dvd_link.png | Bin 0 -> 819 bytes web/images/icons/email.png | Bin 0 -> 641 bytes web/images/icons/email_add.png | Bin 0 -> 761 bytes web/images/icons/email_attach.png | Bin 0 -> 793 bytes web/images/icons/email_delete.png | Bin 0 -> 756 bytes web/images/icons/email_edit.png | Bin 0 -> 756 bytes web/images/icons/email_error.png | Bin 0 -> 792 bytes web/images/icons/email_go.png | Bin 0 -> 754 bytes web/images/icons/email_link.png | Bin 0 -> 821 bytes web/images/icons/email_open.png | Bin 0 -> 783 bytes web/images/icons/email_open_image.png | Bin 0 -> 811 bytes web/images/icons/emoticon_evilgrin.png | Bin 0 -> 727 bytes web/images/icons/emoticon_grin.png | Bin 0 -> 714 bytes web/images/icons/emoticon_happy.png | Bin 0 -> 731 bytes web/images/icons/emoticon_smile.png | Bin 0 -> 725 bytes web/images/icons/emoticon_surprised.png | Bin 0 -> 741 bytes web/images/icons/emoticon_tongue.png | Bin 0 -> 727 bytes web/images/icons/emoticon_unhappy.png | Bin 0 -> 723 bytes web/images/icons/emoticon_waii.png | Bin 0 -> 737 bytes web/images/icons/emoticon_wink.png | Bin 0 -> 712 bytes web/images/icons/error.png | Bin 0 -> 666 bytes web/images/icons/error_add.png | Bin 0 -> 710 bytes web/images/icons/error_delete.png | Bin 0 -> 729 bytes web/images/icons/error_go.png | Bin 0 -> 734 bytes web/images/icons/exclamation.png | Bin 0 -> 701 bytes web/images/icons/eye.png | Bin 0 -> 750 bytes web/images/icons/feed.png | Bin 0 -> 691 bytes web/images/icons/feed_add.png | Bin 0 -> 763 bytes web/images/icons/feed_delete.png | Bin 0 -> 746 bytes web/images/icons/feed_disk.png | Bin 0 -> 738 bytes web/images/icons/feed_edit.png | Bin 0 -> 801 bytes web/images/icons/feed_error.png | Bin 0 -> 770 bytes web/images/icons/feed_go.png | Bin 0 -> 761 bytes web/images/icons/feed_key.png | Bin 0 -> 771 bytes web/images/icons/feed_link.png | Bin 0 -> 806 bytes web/images/icons/feed_magnify.png | Bin 0 -> 737 bytes web/images/icons/female.png | Bin 0 -> 590 bytes web/images/icons/film.png | Bin 0 -> 653 bytes web/images/icons/film_add.png | Bin 0 -> 739 bytes web/images/icons/film_edit.png | Bin 0 -> 855 bytes web/images/icons/film_error.png | Bin 0 -> 800 bytes web/images/icons/film_go.png | Bin 0 -> 813 bytes web/images/icons/film_key.png | Bin 0 -> 835 bytes web/images/icons/film_link.png | Bin 0 -> 830 bytes web/images/icons/film_save.png | Bin 0 -> 806 bytes web/images/icons/find.png | Bin 0 -> 659 bytes web/images/icons/flag_blue.png | Bin 0 -> 671 bytes web/images/icons/flag_green.png | Bin 0 -> 672 bytes web/images/icons/flag_orange.png | Bin 0 -> 669 bytes web/images/icons/flag_pink.png | Bin 0 -> 651 bytes web/images/icons/flag_purple.png | Bin 0 -> 656 bytes web/images/icons/flag_red.png | Bin 0 -> 665 bytes web/images/icons/flag_yellow.png | Bin 0 -> 671 bytes web/images/icons/folder.png | Bin 0 -> 537 bytes web/images/icons/folder_add.png | Bin 0 -> 668 bytes web/images/icons/folder_bell.png | Bin 0 -> 781 bytes web/images/icons/folder_brick.png | Bin 0 -> 735 bytes web/images/icons/folder_bug.png | Bin 0 -> 829 bytes web/images/icons/folder_camera.png | Bin 0 -> 729 bytes web/images/icons/folder_database.png | Bin 0 -> 687 bytes web/images/icons/folder_delete.png | Bin 0 -> 666 bytes web/images/icons/folder_edit.png | Bin 0 -> 733 bytes web/images/icons/folder_error.png | Bin 0 -> 727 bytes web/images/icons/folder_explore.png | Bin 0 -> 679 bytes web/images/icons/folder_feed.png | Bin 0 -> 691 bytes web/images/icons/folder_find.png | Bin 0 -> 795 bytes web/images/icons/folder_go.png | Bin 0 -> 694 bytes web/images/icons/folder_heart.png | Bin 0 -> 741 bytes web/images/icons/folder_image.png | Bin 0 -> 677 bytes web/images/icons/folder_key.png | Bin 0 -> 720 bytes web/images/icons/folder_lightbulb.png | Bin 0 -> 741 bytes web/images/icons/folder_link.png | Bin 0 -> 785 bytes web/images/icons/folder_magnify.png | Bin 0 -> 686 bytes web/images/icons/folder_page.png | Bin 0 -> 688 bytes web/images/icons/folder_page_white.png | Bin 0 -> 639 bytes web/images/icons/folder_palette.png | Bin 0 -> 822 bytes web/images/icons/folder_picture.png | Bin 0 -> 713 bytes web/images/icons/folder_star.png | Bin 0 -> 755 bytes web/images/icons/folder_table.png | Bin 0 -> 675 bytes web/images/icons/folder_user.png | Bin 0 -> 730 bytes web/images/icons/folder_wrench.png | Bin 0 -> 740 bytes web/images/icons/font.png | Bin 0 -> 567 bytes web/images/icons/font_add.png | Bin 0 -> 634 bytes web/images/icons/font_delete.png | Bin 0 -> 661 bytes web/images/icons/font_go.png | Bin 0 -> 700 bytes web/images/icons/group.png | Bin 0 -> 753 bytes web/images/icons/group_add.png | Bin 0 -> 807 bytes web/images/icons/group_delete.png | Bin 0 -> 827 bytes web/images/icons/group_edit.png | Bin 0 -> 785 bytes web/images/icons/group_error.png | Bin 0 -> 842 bytes web/images/icons/group_gear.png | Bin 0 -> 824 bytes web/images/icons/group_go.png | Bin 0 -> 842 bytes web/images/icons/group_key.png | Bin 0 -> 813 bytes web/images/icons/group_link.png | Bin 0 -> 858 bytes web/images/icons/heart.png | Bin 0 -> 749 bytes web/images/icons/heart_add.png | Bin 0 -> 820 bytes web/images/icons/heart_delete.png | Bin 0 -> 823 bytes web/images/icons/help.png | Bin 0 -> 786 bytes web/images/icons/hourglass.png | Bin 0 -> 744 bytes web/images/icons/hourglass_add.png | Bin 0 -> 814 bytes web/images/icons/hourglass_delete.png | Bin 0 -> 829 bytes web/images/icons/hourglass_go.png | Bin 0 -> 866 bytes web/images/icons/hourglass_link.png | Bin 0 -> 871 bytes web/images/icons/house.png | Bin 0 -> 806 bytes web/images/icons/house_go.png | Bin 0 -> 861 bytes web/images/icons/house_link.png | Bin 0 -> 868 bytes web/images/icons/html.png | Bin 0 -> 578 bytes web/images/icons/html_add.png | Bin 0 -> 698 bytes web/images/icons/html_delete.png | Bin 0 -> 688 bytes web/images/icons/html_go.png | Bin 0 -> 692 bytes web/images/icons/html_valid.png | Bin 0 -> 704 bytes web/images/icons/image.png | Bin 0 -> 516 bytes web/images/icons/image_add.png | Bin 0 -> 653 bytes web/images/icons/image_delete.png | Bin 0 -> 653 bytes web/images/icons/image_edit.png | Bin 0 -> 783 bytes web/images/icons/image_link.png | Bin 0 -> 773 bytes web/images/icons/images.png | Bin 0 -> 661 bytes web/images/icons/information.png | Bin 0 -> 778 bytes web/images/icons/ipod.png | Bin 0 -> 463 bytes web/images/icons/ipod_cast.png | Bin 0 -> 711 bytes web/images/icons/ipod_cast_add.png | Bin 0 -> 796 bytes web/images/icons/ipod_cast_delete.png | Bin 0 -> 809 bytes web/images/icons/ipod_sound.png | Bin 0 -> 678 bytes web/images/icons/joystick.png | Bin 0 -> 559 bytes web/images/icons/joystick_add.png | Bin 0 -> 669 bytes web/images/icons/joystick_delete.png | Bin 0 -> 671 bytes web/images/icons/joystick_error.png | Bin 0 -> 711 bytes web/images/icons/key.png | Bin 0 -> 612 bytes web/images/icons/key_add.png | Bin 0 -> 703 bytes web/images/icons/key_delete.png | Bin 0 -> 724 bytes web/images/icons/key_go.png | Bin 0 -> 744 bytes web/images/icons/keyboard.png | Bin 0 -> 570 bytes web/images/icons/keyboard_add.png | Bin 0 -> 683 bytes web/images/icons/keyboard_delete.png | Bin 0 -> 681 bytes web/images/icons/keyboard_magnify.png | Bin 0 -> 651 bytes web/images/icons/layers.png | Bin 0 -> 597 bytes web/images/icons/layout.png | Bin 0 -> 480 bytes web/images/icons/layout_add.png | Bin 0 -> 577 bytes web/images/icons/layout_content.png | Bin 0 -> 519 bytes web/images/icons/layout_delete.png | Bin 0 -> 608 bytes web/images/icons/layout_edit.png | Bin 0 -> 716 bytes web/images/icons/layout_error.png | Bin 0 -> 666 bytes web/images/icons/layout_header.png | Bin 0 -> 500 bytes web/images/icons/layout_link.png | Bin 0 -> 660 bytes web/images/icons/layout_sidebar.png | Bin 0 -> 479 bytes web/images/icons/lightbulb.png | Bin 0 -> 782 bytes web/images/icons/lightbulb_add.png | Bin 0 -> 839 bytes web/images/icons/lightbulb_delete.png | Bin 0 -> 857 bytes web/images/icons/lightbulb_off.png | Bin 0 -> 700 bytes web/images/icons/lightning.png | Bin 0 -> 634 bytes web/images/icons/lightning_add.png | Bin 0 -> 746 bytes web/images/icons/lightning_delete.png | Bin 0 -> 745 bytes web/images/icons/lightning_go.png | Bin 0 -> 739 bytes web/images/icons/link.png | Bin 0 -> 343 bytes web/images/icons/link_add.png | Bin 0 -> 570 bytes web/images/icons/link_break.png | Bin 0 -> 657 bytes web/images/icons/link_delete.png | Bin 0 -> 600 bytes web/images/icons/link_edit.png | Bin 0 -> 703 bytes web/images/icons/link_error.png | Bin 0 -> 698 bytes web/images/icons/link_go.png | Bin 0 -> 655 bytes web/images/icons/lock.png | Bin 0 -> 749 bytes web/images/icons/lock_add.png | Bin 0 -> 824 bytes web/images/icons/lock_break.png | Bin 0 -> 771 bytes web/images/icons/lock_delete.png | Bin 0 -> 815 bytes web/images/icons/lock_edit.png | Bin 0 -> 861 bytes web/images/icons/lock_go.png | Bin 0 -> 829 bytes web/images/icons/lock_open.png | Bin 0 -> 727 bytes web/images/icons/lorry.png | Bin 0 -> 582 bytes web/images/icons/lorry_add.png | Bin 0 -> 689 bytes web/images/icons/lorry_delete.png | Bin 0 -> 683 bytes web/images/icons/lorry_error.png | Bin 0 -> 739 bytes web/images/icons/lorry_flatbed.png | Bin 0 -> 450 bytes web/images/icons/lorry_go.png | Bin 0 -> 699 bytes web/images/icons/lorry_link.png | Bin 0 -> 775 bytes web/images/icons/magifier_zoom_out.png | Bin 0 -> 657 bytes web/images/icons/magnifier.png | Bin 0 -> 615 bytes web/images/icons/magnifier_zoom_in.png | Bin 0 -> 680 bytes web/images/icons/male.png | Bin 0 -> 629 bytes web/images/icons/map.png | Bin 0 -> 804 bytes web/images/icons/map_add.png | Bin 0 -> 836 bytes web/images/icons/map_delete.png | Bin 0 -> 835 bytes web/images/icons/map_edit.png | Bin 0 -> 876 bytes web/images/icons/map_go.png | Bin 0 -> 842 bytes web/images/icons/map_magnify.png | Bin 0 -> 797 bytes web/images/icons/medal_bronze_1.png | Bin 0 -> 640 bytes web/images/icons/medal_bronze_2.png | Bin 0 -> 654 bytes web/images/icons/medal_bronze_3.png | Bin 0 -> 646 bytes web/images/icons/medal_bronze_add.png | Bin 0 -> 747 bytes web/images/icons/medal_bronze_delete.png | Bin 0 -> 730 bytes web/images/icons/medal_gold_1.png | Bin 0 -> 629 bytes web/images/icons/medal_gold_2.png | Bin 0 -> 641 bytes web/images/icons/medal_gold_3.png | Bin 0 -> 634 bytes web/images/icons/medal_gold_add.png | Bin 0 -> 733 bytes web/images/icons/medal_gold_delete.png | Bin 0 -> 724 bytes web/images/icons/medal_silver_1.png | Bin 0 -> 589 bytes web/images/icons/medal_silver_2.png | Bin 0 -> 600 bytes web/images/icons/medal_silver_3.png | Bin 0 -> 597 bytes web/images/icons/medal_silver_add.png | Bin 0 -> 727 bytes web/images/icons/medal_silver_delete.png | Bin 0 -> 714 bytes web/images/icons/money.png | Bin 0 -> 738 bytes web/images/icons/money_add.png | Bin 0 -> 784 bytes web/images/icons/money_delete.png | Bin 0 -> 806 bytes web/images/icons/money_dollar.png | Bin 0 -> 630 bytes web/images/icons/money_euro.png | Bin 0 -> 605 bytes web/images/icons/money_pound.png | Bin 0 -> 565 bytes web/images/icons/money_yen.png | Bin 0 -> 562 bytes web/images/icons/monitor.png | Bin 0 -> 612 bytes web/images/icons/monitor_add.png | Bin 0 -> 692 bytes web/images/icons/monitor_delete.png | Bin 0 -> 691 bytes web/images/icons/monitor_edit.png | Bin 0 -> 769 bytes web/images/icons/monitor_error.png | Bin 0 -> 714 bytes web/images/icons/monitor_go.png | Bin 0 -> 696 bytes web/images/icons/monitor_lightning.png | Bin 0 -> 768 bytes web/images/icons/monitor_link.png | Bin 0 -> 736 bytes web/images/icons/mouse.png | Bin 0 -> 634 bytes web/images/icons/mouse_add.png | Bin 0 -> 729 bytes web/images/icons/mouse_delete.png | Bin 0 -> 741 bytes web/images/icons/mouse_error.png | Bin 0 -> 790 bytes web/images/icons/music.png | Bin 0 -> 385 bytes web/images/icons/new.png | Bin 0 -> 378 bytes web/images/icons/newspaper.png | Bin 0 -> 658 bytes web/images/icons/newspaper_add.png | Bin 0 -> 750 bytes web/images/icons/newspaper_delete.png | Bin 0 -> 775 bytes web/images/icons/newspaper_go.png | Bin 0 -> 779 bytes web/images/icons/newspaper_link.png | Bin 0 -> 787 bytes web/images/icons/note.png | Bin 0 -> 500 bytes web/images/icons/note_add.png | Bin 0 -> 641 bytes web/images/icons/note_delete.png | Bin 0 -> 631 bytes web/images/icons/note_edit.png | Bin 0 -> 731 bytes web/images/icons/note_error.png | Bin 0 -> 680 bytes web/images/icons/note_go.png | Bin 0 -> 661 bytes web/images/icons/overlays.png | Bin 0 -> 716 bytes web/images/icons/package.png | Bin 0 -> 853 bytes web/images/icons/package_add.png | Bin 0 -> 899 bytes web/images/icons/package_delete.png | Bin 0 -> 891 bytes web/images/icons/package_go.png | Bin 0 -> 898 bytes web/images/icons/package_green.png | Bin 0 -> 896 bytes web/images/icons/package_link.png | Bin 0 -> 939 bytes web/images/icons/page.png | Bin 0 -> 635 bytes web/images/icons/page_add.png | Bin 0 -> 739 bytes web/images/icons/page_attach.png | Bin 0 -> 794 bytes web/images/icons/page_code.png | Bin 0 -> 818 bytes web/images/icons/page_copy.png | Bin 0 -> 663 bytes web/images/icons/page_delete.png | Bin 0 -> 740 bytes web/images/icons/page_edit.png | Bin 0 -> 807 bytes web/images/icons/page_error.png | Bin 0 -> 793 bytes web/images/icons/page_excel.png | Bin 0 -> 817 bytes web/images/icons/page_find.png | Bin 0 -> 879 bytes web/images/icons/page_gear.png | Bin 0 -> 833 bytes web/images/icons/page_go.png | Bin 0 -> 779 bytes web/images/icons/page_green.png | Bin 0 -> 621 bytes web/images/icons/page_key.png | Bin 0 -> 801 bytes web/images/icons/page_lightning.png | Bin 0 -> 839 bytes web/images/icons/page_link.png | Bin 0 -> 830 bytes web/images/icons/page_paintbrush.png | Bin 0 -> 813 bytes web/images/icons/page_paste.png | Bin 0 -> 703 bytes web/images/icons/page_red.png | Bin 0 -> 641 bytes web/images/icons/page_refresh.png | Bin 0 -> 858 bytes web/images/icons/page_save.png | Bin 0 -> 774 bytes web/images/icons/page_white.png | Bin 0 -> 294 bytes web/images/icons/page_white_acrobat.png | Bin 0 -> 591 bytes web/images/icons/page_white_actionscript.png | Bin 0 -> 664 bytes web/images/icons/page_white_add.png | Bin 0 -> 512 bytes web/images/icons/page_white_c.png | Bin 0 -> 587 bytes web/images/icons/page_white_camera.png | Bin 0 -> 656 bytes web/images/icons/page_white_cd.png | Bin 0 -> 666 bytes web/images/icons/page_white_code.png | Bin 0 -> 603 bytes web/images/icons/page_white_code_red.png | Bin 0 -> 587 bytes web/images/icons/page_white_coldfusion.png | Bin 0 -> 592 bytes web/images/icons/page_white_compressed.png | Bin 0 -> 724 bytes web/images/icons/page_white_copy.png | Bin 0 -> 309 bytes web/images/icons/page_white_cplusplus.png | Bin 0 -> 621 bytes web/images/icons/page_white_csharp.png | Bin 0 -> 700 bytes web/images/icons/page_white_cup.png | Bin 0 -> 639 bytes web/images/icons/page_white_database.png | Bin 0 -> 579 bytes web/images/icons/page_white_delete.png | Bin 0 -> 536 bytes web/images/icons/page_white_dvd.png | Bin 0 -> 638 bytes web/images/icons/page_white_edit.png | Bin 0 -> 618 bytes web/images/icons/page_white_error.png | Bin 0 -> 623 bytes web/images/icons/page_white_excel.png | Bin 0 -> 663 bytes web/images/icons/page_white_find.png | Bin 0 -> 676 bytes web/images/icons/page_white_flash.png | Bin 0 -> 582 bytes web/images/icons/page_white_freehand.png | Bin 0 -> 639 bytes web/images/icons/page_white_gear.png | Bin 0 -> 402 bytes web/images/icons/page_white_get.png | Bin 0 -> 516 bytes web/images/icons/page_white_go.png | Bin 0 -> 612 bytes web/images/icons/page_white_h.png | Bin 0 -> 603 bytes web/images/icons/page_white_horizontal.png | Bin 0 -> 296 bytes web/images/icons/page_white_key.png | Bin 0 -> 616 bytes web/images/icons/page_white_lightning.png | Bin 0 -> 669 bytes web/images/icons/page_white_link.png | Bin 0 -> 614 bytes web/images/icons/page_white_magnify.png | Bin 0 -> 554 bytes web/images/icons/page_white_medal.png | Bin 0 -> 706 bytes web/images/icons/page_white_office.png | Bin 0 -> 779 bytes web/images/icons/page_white_paint.png | Bin 0 -> 688 bytes web/images/icons/page_white_paintbrush.png | Bin 0 -> 618 bytes web/images/icons/page_white_paste.png | Bin 0 -> 620 bytes web/images/icons/page_white_php.png | Bin 0 -> 538 bytes web/images/icons/page_white_picture.png | Bin 0 -> 650 bytes web/images/icons/page_white_powerpoint.png | Bin 0 -> 588 bytes web/images/icons/page_white_put.png | Bin 0 -> 523 bytes web/images/icons/page_white_ruby.png | Bin 0 -> 626 bytes web/images/icons/page_white_stack.png | Bin 0 -> 317 bytes web/images/icons/page_white_star.png | Bin 0 -> 565 bytes web/images/icons/page_white_swoosh.png | Bin 0 -> 634 bytes web/images/icons/page_white_text.png | Bin 0 -> 342 bytes web/images/icons/page_white_text_width.png | Bin 0 -> 315 bytes web/images/icons/page_white_tux.png | Bin 0 -> 668 bytes web/images/icons/page_white_vector.png | Bin 0 -> 644 bytes web/images/icons/page_white_visualstudio.png | Bin 0 -> 702 bytes web/images/icons/page_white_width.png | Bin 0 -> 309 bytes web/images/icons/page_white_word.png | Bin 0 -> 651 bytes web/images/icons/page_white_world.png | Bin 0 -> 734 bytes web/images/icons/page_white_wrench.png | Bin 0 -> 613 bytes web/images/icons/page_white_zip.png | Bin 0 -> 386 bytes web/images/icons/page_word.png | Bin 0 -> 777 bytes web/images/icons/page_world.png | Bin 0 -> 903 bytes web/images/icons/paintbrush.png | Bin 0 -> 548 bytes web/images/icons/paintcan.png | Bin 0 -> 707 bytes web/images/icons/palette.png | Bin 0 -> 856 bytes web/images/icons/paste_plain.png | Bin 0 -> 605 bytes web/images/icons/paste_word.png | Bin 0 -> 701 bytes web/images/icons/pencil.png | Bin 0 -> 450 bytes web/images/icons/pencil_add.png | Bin 0 -> 589 bytes web/images/icons/pencil_delete.png | Bin 0 -> 603 bytes web/images/icons/pencil_go.png | Bin 0 -> 666 bytes web/images/icons/phone.png | Bin 0 -> 488 bytes web/images/icons/phone_add.png | Bin 0 -> 621 bytes web/images/icons/phone_delete.png | Bin 0 -> 615 bytes web/images/icons/phone_sound.png | Bin 0 -> 703 bytes web/images/icons/photo.png | Bin 0 -> 589 bytes web/images/icons/photo_add.png | Bin 0 -> 707 bytes web/images/icons/photo_delete.png | Bin 0 -> 703 bytes web/images/icons/photo_link.png | Bin 0 -> 784 bytes web/images/icons/photos.png | Bin 0 -> 647 bytes web/images/icons/picture.png | Bin 0 -> 606 bytes web/images/icons/picture_add.png | Bin 0 -> 745 bytes web/images/icons/picture_delete.png | Bin 0 -> 744 bytes web/images/icons/picture_edit.png | Bin 0 -> 826 bytes web/images/icons/picture_empty.png | Bin 0 -> 463 bytes web/images/icons/picture_error.png | Bin 0 -> 755 bytes web/images/icons/picture_go.png | Bin 0 -> 758 bytes web/images/icons/picture_key.png | Bin 0 -> 794 bytes web/images/icons/picture_link.png | Bin 0 -> 835 bytes web/images/icons/picture_save.png | Bin 0 -> 755 bytes web/images/icons/pictures.png | Bin 0 -> 704 bytes web/images/icons/pilcrow.png | Bin 0 -> 361 bytes web/images/icons/pill.png | Bin 0 -> 719 bytes web/images/icons/pill_add.png | Bin 0 -> 797 bytes web/images/icons/pill_delete.png | Bin 0 -> 805 bytes web/images/icons/pill_go.png | Bin 0 -> 817 bytes web/images/icons/plugin.png | Bin 0 -> 591 bytes web/images/icons/plugin_add.png | Bin 0 -> 691 bytes web/images/icons/plugin_delete.png | Bin 0 -> 692 bytes web/images/icons/plugin_disabled.png | Bin 0 -> 347 bytes web/images/icons/plugin_edit.png | Bin 0 -> 746 bytes web/images/icons/plugin_error.png | Bin 0 -> 702 bytes web/images/icons/plugin_go.png | Bin 0 -> 694 bytes web/images/icons/plugin_link.png | Bin 0 -> 759 bytes web/images/icons/printer.png | Bin 0 -> 731 bytes web/images/icons/printer_delete.png | Bin 0 -> 792 bytes web/images/icons/printer_empty.png | Bin 0 -> 350 bytes web/images/icons/printer_error.png | Bin 0 -> 854 bytes web/images/icons/rainbow.png | Bin 0 -> 655 bytes web/images/icons/report.png | Bin 0 -> 649 bytes web/images/icons/report_add.png | Bin 0 -> 714 bytes web/images/icons/report_delete.png | Bin 0 -> 729 bytes web/images/icons/report_disk.png | Bin 0 -> 760 bytes web/images/icons/report_edit.png | Bin 0 -> 762 bytes web/images/icons/report_go.png | Bin 0 -> 756 bytes web/images/icons/report_key.png | Bin 0 -> 760 bytes web/images/icons/report_link.png | Bin 0 -> 754 bytes web/images/icons/report_magnify.png | Bin 0 -> 738 bytes web/images/icons/report_picture.png | Bin 0 -> 733 bytes web/images/icons/report_user.png | Bin 0 -> 785 bytes web/images/icons/report_word.png | Bin 0 -> 731 bytes web/images/icons/resultset_first.png | Bin 0 -> 522 bytes web/images/icons/resultset_last.png | Bin 0 -> 524 bytes web/images/icons/resultset_next.png | Bin 0 -> 395 bytes web/images/icons/resultset_previous.png | Bin 0 -> 389 bytes web/images/icons/rosette.png | Bin 0 -> 673 bytes web/images/icons/rss.png | Bin 0 -> 530 bytes web/images/icons/rss_add.png | Bin 0 -> 649 bytes web/images/icons/rss_delete.png | Bin 0 -> 633 bytes web/images/icons/rss_go.png | Bin 0 -> 635 bytes web/images/icons/rss_valid.png | Bin 0 -> 660 bytes web/images/icons/ruby.png | Bin 0 -> 592 bytes web/images/icons/ruby_add.png | Bin 0 -> 691 bytes web/images/icons/ruby_delete.png | Bin 0 -> 704 bytes web/images/icons/ruby_gear.png | Bin 0 -> 716 bytes web/images/icons/ruby_get.png | Bin 0 -> 692 bytes web/images/icons/ruby_go.png | Bin 0 -> 720 bytes web/images/icons/ruby_key.png | Bin 0 -> 732 bytes web/images/icons/ruby_link.png | Bin 0 -> 767 bytes web/images/icons/ruby_put.png | Bin 0 -> 694 bytes web/images/icons/script.png | Bin 0 -> 748 bytes web/images/icons/script_add.png | Bin 0 -> 811 bytes web/images/icons/script_code.png | Bin 0 -> 859 bytes web/images/icons/script_code_red.png | Bin 0 -> 868 bytes web/images/icons/script_delete.png | Bin 0 -> 811 bytes web/images/icons/script_edit.png | Bin 0 -> 880 bytes web/images/icons/script_error.png | Bin 0 -> 861 bytes web/images/icons/script_gear.png | Bin 0 -> 861 bytes web/images/icons/script_go.png | Bin 0 -> 839 bytes web/images/icons/script_key.png | Bin 0 -> 853 bytes web/images/icons/script_lightning.png | Bin 0 -> 879 bytes web/images/icons/script_link.png | Bin 0 -> 876 bytes web/images/icons/script_palette.png | Bin 0 -> 917 bytes web/images/icons/script_save.png | Bin 0 -> 804 bytes web/images/icons/server.png | Bin 0 -> 530 bytes web/images/icons/server_add.png | Bin 0 -> 676 bytes web/images/icons/server_chart.png | Bin 0 -> 673 bytes web/images/icons/server_compressed.png | Bin 0 -> 721 bytes web/images/icons/server_connect.png | Bin 0 -> 755 bytes web/images/icons/server_database.png | Bin 0 -> 666 bytes web/images/icons/server_delete.png | Bin 0 -> 668 bytes web/images/icons/server_edit.png | Bin 0 -> 749 bytes web/images/icons/server_error.png | Bin 0 -> 678 bytes web/images/icons/server_go.png | Bin 0 -> 706 bytes web/images/icons/server_key.png | Bin 0 -> 746 bytes web/images/icons/server_lightning.png | Bin 0 -> 729 bytes web/images/icons/server_link.png | Bin 0 -> 706 bytes web/images/icons/server_uncompressed.png | Bin 0 -> 669 bytes web/images/icons/shading.png | Bin 0 -> 225 bytes web/images/icons/shape_align_bottom.png | Bin 0 -> 398 bytes web/images/icons/shape_align_center.png | Bin 0 -> 384 bytes web/images/icons/shape_align_left.png | Bin 0 -> 402 bytes web/images/icons/shape_align_middle.png | Bin 0 -> 414 bytes web/images/icons/shape_align_right.png | Bin 0 -> 401 bytes web/images/icons/shape_align_top.png | Bin 0 -> 406 bytes web/images/icons/shape_flip_horizontal.png | Bin 0 -> 403 bytes web/images/icons/shape_flip_vertical.png | Bin 0 -> 418 bytes web/images/icons/shape_group.png | Bin 0 -> 553 bytes web/images/icons/shape_handles.png | Bin 0 -> 538 bytes web/images/icons/shape_move_back.png | Bin 0 -> 395 bytes web/images/icons/shape_move_backwards.png | Bin 0 -> 358 bytes web/images/icons/shape_move_forwards.png | Bin 0 -> 381 bytes web/images/icons/shape_move_front.png | Bin 0 -> 435 bytes .../icons/shape_rotate_anticlockwise.png | Bin 0 -> 657 bytes web/images/icons/shape_rotate_clockwise.png | Bin 0 -> 673 bytes web/images/icons/shape_square.png | Bin 0 -> 353 bytes web/images/icons/shape_square_add.png | Bin 0 -> 539 bytes web/images/icons/shape_square_delete.png | Bin 0 -> 537 bytes web/images/icons/shape_square_edit.png | Bin 0 -> 660 bytes web/images/icons/shape_square_error.png | Bin 0 -> 570 bytes web/images/icons/shape_square_go.png | Bin 0 -> 566 bytes web/images/icons/shape_square_key.png | Bin 0 -> 607 bytes web/images/icons/shape_square_link.png | Bin 0 -> 642 bytes web/images/icons/shape_ungroup.png | Bin 0 -> 666 bytes web/images/icons/shield.png | Bin 0 -> 702 bytes web/images/icons/shield_add.png | Bin 0 -> 758 bytes web/images/icons/shield_delete.png | Bin 0 -> 768 bytes web/images/icons/shield_go.png | Bin 0 -> 775 bytes web/images/icons/sitemap.png | Bin 0 -> 278 bytes web/images/icons/sitemap_color.png | Bin 0 -> 406 bytes web/images/icons/sound.png | Bin 0 -> 610 bytes web/images/icons/sound_add.png | Bin 0 -> 684 bytes web/images/icons/sound_delete.png | Bin 0 -> 711 bytes web/images/icons/sound_low.png | Bin 0 -> 524 bytes web/images/icons/sound_mute.png | Bin 0 -> 474 bytes web/images/icons/sound_none.png | Bin 0 -> 417 bytes web/images/icons/spellcheck.png | Bin 0 -> 603 bytes web/images/icons/sport_8ball.png | Bin 0 -> 490 bytes web/images/icons/sport_basketball.png | Bin 0 -> 977 bytes web/images/icons/sport_football.png | Bin 0 -> 875 bytes web/images/icons/sport_golf.png | Bin 0 -> 504 bytes web/images/icons/sport_raquet.png | Bin 0 -> 719 bytes web/images/icons/sport_shuttlecock.png | Bin 0 -> 683 bytes web/images/icons/sport_soccer.png | Bin 0 -> 517 bytes web/images/icons/sport_tennis.png | Bin 0 -> 884 bytes web/images/icons/star.png | Bin 0 -> 670 bytes web/images/icons/status_away.png | Bin 0 -> 794 bytes web/images/icons/status_busy.png | Bin 0 -> 751 bytes web/images/icons/status_offline.png | Bin 0 -> 422 bytes web/images/icons/status_online.png | Bin 0 -> 722 bytes web/images/icons/stop.png | Bin 0 -> 700 bytes web/images/icons/style.png | Bin 0 -> 813 bytes web/images/icons/style_add.png | Bin 0 -> 844 bytes web/images/icons/style_delete.png | Bin 0 -> 865 bytes web/images/icons/style_edit.png | Bin 0 -> 927 bytes web/images/icons/style_go.png | Bin 0 -> 862 bytes web/images/icons/sum.png | Bin 0 -> 289 bytes web/images/icons/tab.png | Bin 0 -> 323 bytes web/images/icons/tab_add.png | Bin 0 -> 488 bytes web/images/icons/tab_delete.png | Bin 0 -> 493 bytes web/images/icons/tab_edit.png | Bin 0 -> 580 bytes web/images/icons/tab_go.png | Bin 0 -> 552 bytes web/images/icons/table.png | Bin 0 -> 566 bytes web/images/icons/table_add.png | Bin 0 -> 663 bytes web/images/icons/table_delete.png | Bin 0 -> 660 bytes web/images/icons/table_edit.png | Bin 0 -> 744 bytes web/images/icons/table_error.png | Bin 0 -> 687 bytes web/images/icons/table_gear.png | Bin 0 -> 714 bytes web/images/icons/table_go.png | Bin 0 -> 683 bytes web/images/icons/table_key.png | Bin 0 -> 746 bytes web/images/icons/table_lightning.png | Bin 0 -> 736 bytes web/images/icons/table_link.png | Bin 0 -> 728 bytes web/images/icons/table_multiple.png | Bin 0 -> 612 bytes web/images/icons/table_refresh.png | Bin 0 -> 795 bytes web/images/icons/table_relationship.png | Bin 0 -> 663 bytes web/images/icons/table_row_delete.png | Bin 0 -> 629 bytes web/images/icons/table_row_insert.png | Bin 0 -> 641 bytes web/images/icons/table_save.png | Bin 0 -> 723 bytes web/images/icons/table_sort.png | Bin 0 -> 678 bytes web/images/icons/tag.png | Bin 0 -> 389 bytes web/images/icons/tag_blue.png | Bin 0 -> 586 bytes web/images/icons/tag_blue_add.png | Bin 0 -> 671 bytes web/images/icons/tag_blue_delete.png | Bin 0 -> 701 bytes web/images/icons/tag_blue_edit.png | Bin 0 -> 748 bytes web/images/icons/tag_green.png | Bin 0 -> 613 bytes web/images/icons/tag_orange.png | Bin 0 -> 586 bytes web/images/icons/tag_pink.png | Bin 0 -> 579 bytes web/images/icons/tag_purple.png | Bin 0 -> 599 bytes web/images/icons/tag_red.png | Bin 0 -> 592 bytes web/images/icons/tag_yellow.png | Bin 0 -> 586 bytes web/images/icons/telephone.png | Bin 0 -> 791 bytes web/images/icons/telephone_add.png | Bin 0 -> 860 bytes web/images/icons/telephone_delete.png | Bin 0 -> 856 bytes web/images/icons/telephone_edit.png | Bin 0 -> 893 bytes web/images/icons/telephone_error.png | Bin 0 -> 884 bytes web/images/icons/telephone_go.png | Bin 0 -> 865 bytes web/images/icons/telephone_key.png | Bin 0 -> 881 bytes web/images/icons/telephone_link.png | Bin 0 -> 909 bytes web/images/icons/television.png | Bin 0 -> 696 bytes web/images/icons/television_add.png | Bin 0 -> 809 bytes web/images/icons/television_delete.png | Bin 0 -> 810 bytes web/images/icons/text_align_center.png | Bin 0 -> 234 bytes web/images/icons/text_align_justify.png | Bin 0 -> 209 bytes web/images/icons/text_align_left.png | Bin 0 -> 209 bytes web/images/icons/text_align_right.png | Bin 0 -> 209 bytes web/images/icons/text_allcaps.png | Bin 0 -> 284 bytes web/images/icons/text_bold.png | Bin 0 -> 304 bytes web/images/icons/text_columns.png | Bin 0 -> 246 bytes web/images/icons/text_dropcaps.png | Bin 0 -> 314 bytes web/images/icons/text_heading_1.png | Bin 0 -> 276 bytes web/images/icons/text_heading_2.png | Bin 0 -> 304 bytes web/images/icons/text_heading_3.png | Bin 0 -> 306 bytes web/images/icons/text_heading_4.png | Bin 0 -> 293 bytes web/images/icons/text_heading_5.png | Bin 0 -> 304 bytes web/images/icons/text_heading_6.png | Bin 0 -> 310 bytes web/images/icons/text_horizontalrule.png | Bin 0 -> 317 bytes web/images/icons/text_indent.png | Bin 0 -> 353 bytes web/images/icons/text_indent_remove.png | Bin 0 -> 351 bytes web/images/icons/text_italic.png | Bin 0 -> 223 bytes web/images/icons/text_kerning.png | Bin 0 -> 495 bytes web/images/icons/text_letter_omega.png | Bin 0 -> 541 bytes web/images/icons/text_letterspacing.png | Bin 0 -> 503 bytes web/images/icons/text_linespacing.png | Bin 0 -> 363 bytes web/images/icons/text_list_bullets.png | Bin 0 -> 344 bytes web/images/icons/text_list_numbers.png | Bin 0 -> 357 bytes web/images/icons/text_lowercase.png | Bin 0 -> 709 bytes web/images/icons/text_padding_bottom.png | Bin 0 -> 237 bytes web/images/icons/text_padding_left.png | Bin 0 -> 271 bytes web/images/icons/text_padding_right.png | Bin 0 -> 271 bytes web/images/icons/text_padding_top.png | Bin 0 -> 236 bytes web/images/icons/text_replace.png | Bin 0 -> 691 bytes web/images/icons/text_signature.png | Bin 0 -> 524 bytes web/images/icons/text_smallcaps.png | Bin 0 -> 260 bytes web/images/icons/text_strikethrough.png | Bin 0 -> 269 bytes web/images/icons/text_subscript.png | Bin 0 -> 422 bytes web/images/icons/text_superscript.png | Bin 0 -> 421 bytes web/images/icons/text_underline.png | Bin 0 -> 273 bytes web/images/icons/text_uppercase.png | Bin 0 -> 747 bytes web/images/icons/textfield.png | Bin 0 -> 153 bytes web/images/icons/textfield_add.png | Bin 0 -> 321 bytes web/images/icons/textfield_delete.png | Bin 0 -> 335 bytes web/images/icons/textfield_key.png | Bin 0 -> 455 bytes web/images/icons/textfield_rename.png | Bin 0 -> 273 bytes web/images/icons/thumb_down.png | Bin 0 -> 601 bytes web/images/icons/thumb_up.png | Bin 0 -> 619 bytes web/images/icons/tick.png | Bin 0 -> 537 bytes web/images/icons/time.png | Bin 0 -> 793 bytes web/images/icons/time_add.png | Bin 0 -> 827 bytes web/images/icons/time_delete.png | Bin 0 -> 853 bytes web/images/icons/time_go.png | Bin 0 -> 882 bytes web/images/icons/timeline_marker.png | Bin 0 -> 327 bytes web/images/icons/transmit.png | Bin 0 -> 749 bytes web/images/icons/transmit_add.png | Bin 0 -> 803 bytes web/images/icons/transmit_blue.png | Bin 0 -> 814 bytes web/images/icons/transmit_delete.png | Bin 0 -> 827 bytes web/images/icons/transmit_edit.png | Bin 0 -> 848 bytes web/images/icons/transmit_error.png | Bin 0 -> 883 bytes web/images/icons/transmit_go.png | Bin 0 -> 842 bytes web/images/icons/tux.png | Bin 0 -> 696 bytes web/images/icons/urgent.png | Bin 0 -> 564 bytes web/images/icons/user.png | Bin 0 -> 741 bytes web/images/icons/user_add.png | Bin 0 -> 746 bytes web/images/icons/user_comment.png | Bin 0 -> 743 bytes web/images/icons/user_delete.png | Bin 0 -> 767 bytes web/images/icons/user_edit.png | Bin 0 -> 833 bytes web/images/icons/user_female.png | Bin 0 -> 663 bytes web/images/icons/user_go.png | Bin 0 -> 793 bytes web/images/icons/user_gray.png | Bin 0 -> 706 bytes web/images/icons/user_green.png | Bin 0 -> 722 bytes web/images/icons/user_orange.png | Bin 0 -> 723 bytes web/images/icons/user_red.png | Bin 0 -> 717 bytes web/images/icons/user_suit.png | Bin 0 -> 748 bytes web/images/icons/vcard.png | Bin 0 -> 533 bytes web/images/icons/vcard_add.png | Bin 0 -> 661 bytes web/images/icons/vcard_delete.png | Bin 0 -> 651 bytes web/images/icons/vcard_edit.png | Bin 0 -> 775 bytes web/images/icons/vector.png | Bin 0 -> 481 bytes web/images/icons/vector_add.png | Bin 0 -> 616 bytes web/images/icons/vector_delete.png | Bin 0 -> 635 bytes web/images/icons/wand.png | Bin 0 -> 570 bytes web/images/icons/weather_clouds.png | Bin 0 -> 581 bytes web/images/icons/weather_cloudy.png | Bin 0 -> 694 bytes web/images/icons/weather_lightning.png | Bin 0 -> 641 bytes web/images/icons/weather_rain.png | Bin 0 -> 626 bytes web/images/icons/weather_snow.png | Bin 0 -> 341 bytes web/images/icons/weather_sun.png | Bin 0 -> 623 bytes web/images/icons/webcam.png | Bin 0 -> 728 bytes web/images/icons/webcam_add.png | Bin 0 -> 786 bytes web/images/icons/webcam_delete.png | Bin 0 -> 805 bytes web/images/icons/webcam_error.png | Bin 0 -> 821 bytes web/images/icons/world.png | Bin 0 -> 923 bytes web/images/icons/world_add.png | Bin 0 -> 940 bytes web/images/icons/world_delete.png | Bin 0 -> 945 bytes web/images/icons/world_edit.png | Bin 0 -> 945 bytes web/images/icons/world_go.png | Bin 0 -> 944 bytes web/images/icons/world_link.png | Bin 0 -> 957 bytes web/images/icons/wrench.png | Bin 0 -> 610 bytes web/images/icons/wrench_orange.png | Bin 0 -> 584 bytes web/images/icons/xhtml.png | Bin 0 -> 595 bytes web/images/icons/xhtml_add.png | Bin 0 -> 703 bytes web/images/icons/xhtml_delete.png | Bin 0 -> 696 bytes web/images/icons/xhtml_go.png | Bin 0 -> 697 bytes web/images/icons/xhtml_valid.png | Bin 0 -> 718 bytes web/images/icons/zoom.png | Bin 0 -> 692 bytes web/images/icons/zoom_in.png | Bin 0 -> 725 bytes web/images/icons/zoom_out.png | Bin 0 -> 708 bytes web/images/todo.png | Bin 0 -> 22673 bytes web/index.php | 277 ++ web/js/CLEditor/images/buttons.gif | Bin 0 -> 3064 bytes web/js/CLEditor/images/toolbar.gif | Bin 0 -> 68 bytes web/js/CLEditor/jquery.cleditor.css | 24 + web/js/CLEditor/jquery.cleditor.js | 1176 +++++++ web/js/CLEditor/jquery.cleditor.min.js | 8 + web/js/CLEditor/jquery.cleditor.xhtml.js | 230 ++ web/js/CLEditor/jquery.cleditor.xhtml.min.js | 18 + web/js/jquery-ui.min.js | 11 + web/js/jquery.html5form-min.js | 0 web/js/jquery.js | 1 + web/js/todo.js | 516 ++++ web/min/index.php | 64 + web/min/lib/FirePHP.php | 1370 +++++++++ web/min/lib/HTTP/ConditionalGet.php | 348 +++ web/min/lib/HTTP/Encoder.php | 326 ++ web/min/lib/JSMin.php | 314 ++ web/min/lib/JSMinPlus.php | 1872 ++++++++++++ web/min/lib/Minify.php | 532 ++++ web/min/lib/Minify/Build.php | 103 + web/min/lib/Minify/CSS.php | 83 + web/min/lib/Minify/CSS/Compressor.php | 250 ++ web/min/lib/Minify/CSS/UriRewriter.php | 270 ++ web/min/lib/Minify/Cache/APC.php | 130 + web/min/lib/Minify/Cache/File.php | 125 + web/min/lib/Minify/Cache/Memcache.php | 137 + web/min/lib/Minify/CommentPreserver.php | 90 + web/min/lib/Minify/Controller/Base.php | 202 ++ web/min/lib/Minify/Controller/Files.php | 78 + web/min/lib/Minify/Controller/Groups.php | 94 + web/min/lib/Minify/Controller/MinApp.php | 132 + web/min/lib/Minify/Controller/Page.php | 82 + web/min/lib/Minify/Controller/Version1.php | 118 + web/min/lib/Minify/HTML.php | 245 ++ web/min/lib/Minify/ImportProcessor.php | 157 + web/min/lib/Minify/Lines.php | 131 + web/min/lib/Minify/Logger.php | 45 + web/min/lib/Minify/Packer.php | 37 + web/min/lib/Minify/Source.php | 187 ++ web/min/lib/Minify/YUICompressor.php | 139 + web/min/lib/Solar/Dir.php | 199 ++ web/min/utils.php | 90 + web/robots.txt | 3 + 1528 files changed, 87833 insertions(+) create mode 100755 .gitignore create mode 100644 README.md create mode 100755 application/config/autoload.php create mode 100755 application/config/config.php create mode 100755 application/config/constants.php create mode 100755 application/config/database.php create mode 100755 application/config/doctypes.php create mode 100755 application/config/form_validation.php create mode 100755 application/config/hooks.php create mode 100755 application/config/index.html create mode 100755 application/config/mimes.php create mode 100755 application/config/min_config.php create mode 100755 application/config/min_groupsConfig.php create mode 100755 application/config/profiler.php create mode 100755 application/config/routes.php create mode 100755 application/config/sites.php create mode 100755 application/config/smileys.php create mode 100755 application/config/testing/database.php create mode 100755 application/config/user_agents.php create mode 100755 application/controllers/account.php create mode 100755 application/controllers/calendar.php create mode 100755 application/controllers/category.php create mode 100755 application/controllers/friend.php create mode 100755 application/controllers/group.php create mode 100755 application/controllers/login.php create mode 100755 application/controllers/reminder.php create mode 100755 application/controllers/task.php create mode 100755 application/core/MY_Controller.php create mode 100755 application/errors/error_404.php create mode 100755 application/errors/error_db.php create mode 100755 application/errors/error_general.php create mode 100755 application/errors/error_php.php create mode 100755 application/hooks/pre-controller.php create mode 100755 application/language/english/index.html create mode 100644 application/libraries/MY_Form_validation.php create mode 100755 application/libraries/MY_Session.php create mode 100755 application/libraries/Page.php create mode 100755 application/libraries/Todo.php create mode 100755 application/libraries/Validation_callbacks.php create mode 100755 application/logs/index.html create mode 100755 application/models/friend_model.php create mode 100755 application/models/mail_model.php create mode 100755 application/models/task_model.php create mode 100755 application/third_party/CIUnit/bootstrap_phpunit.php create mode 100755 application/third_party/CIUnit/config/config.php create mode 100755 application/third_party/CIUnit/core/CIU_Controller.php create mode 100755 application/third_party/CIUnit/core/CIU_Exceptions.php create mode 100755 application/third_party/CIUnit/core/CIU_Loader.php create mode 100755 application/third_party/CIUnit/core/CIU_Output.php create mode 100755 application/third_party/CIUnit/core/CodeIgniter.php create mode 100755 application/third_party/CIUnit/core/Common.php create mode 100755 application/third_party/CIUnit/core/README.txt create mode 100755 application/third_party/CIUnit/helpers/CIU_url_helper.php create mode 100755 application/third_party/CIUnit/index.html create mode 100755 application/third_party/CIUnit/libraries/CIU_Session.php create mode 100755 application/third_party/CIUnit/libraries/CIUnit.php create mode 100755 application/third_party/CIUnit/libraries/CIUnitTestCase.php create mode 100755 application/third_party/CIUnit/libraries/Fixture.php create mode 100755 application/third_party/CIUnit/libraries/Unit_test.php create mode 100755 application/third_party/CIUnit/libraries/spyc/README create mode 100755 application/third_party/CIUnit/libraries/spyc/examples/yaml-dump.php create mode 100755 application/third_party/CIUnit/libraries/spyc/examples/yaml-load.php create mode 100755 application/third_party/CIUnit/libraries/spyc/php4/5to4.php create mode 100755 application/third_party/CIUnit/libraries/spyc/php4/spyc.php4 create mode 100755 application/third_party/CIUnit/libraries/spyc/php4/test.php4 create mode 100755 application/third_party/CIUnit/libraries/spyc/spyc.php create mode 100755 application/third_party/CIUnit/libraries/spyc/spyc.yaml create mode 100755 application/third_party/CIUnit/libraries/spyc/tests/DumpTest.php create mode 100755 application/third_party/CIUnit/libraries/spyc/tests/IndentTest.php create mode 100755 application/third_party/CIUnit/libraries/spyc/tests/ParseTest.php create mode 100755 application/third_party/CIUnit/libraries/spyc/tests/failing1.yaml create mode 100755 application/third_party/CIUnit/libraries/spyc/tests/indent_1.yaml create mode 100755 application/third_party/CIUnit/libraries/spyc/tests/quotes.yaml create mode 100755 application/views/account/password.php create mode 100755 application/views/account/side_nav.php create mode 100755 application/views/account/status.php create mode 100755 application/views/footer.php create mode 100755 application/views/friend/ajax_search.php create mode 100755 application/views/friend/group_list.php create mode 100755 application/views/friend/list.php create mode 100755 application/views/friend/manage.php create mode 100755 application/views/friend/requests.php create mode 100755 application/views/friend/search.php create mode 100755 application/views/friend/side_nav.php create mode 100755 application/views/header.php create mode 100755 application/views/login/login.php create mode 100755 application/views/login/register.php create mode 100755 application/views/menu.php create mode 100755 application/views/message.php create mode 100755 application/views/task/add.php create mode 100755 application/views/task/ajax_checklist.php create mode 100755 application/views/task/calendar.php create mode 100755 application/views/task/cat_add.php create mode 100755 application/views/task/cat_list.php create mode 100755 application/views/task/checklist_view.php create mode 100755 application/views/task/comments_view.php create mode 100755 application/views/task/edit.php create mode 100755 application/views/task/list.php create mode 100755 application/views/task/side_nav.php create mode 100755 application/views/task/view.php create mode 100755 phpci.yml create mode 100755 system/.htaccess create mode 100755 system/core/Benchmark.php create mode 100755 system/core/CodeIgniter.php create mode 100755 system/core/Common.php create mode 100755 system/core/Config.php create mode 100755 system/core/Controller.php create mode 100755 system/core/Exceptions.php create mode 100755 system/core/Hooks.php create mode 100755 system/core/Input.php create mode 100755 system/core/Lang.php create mode 100755 system/core/Loader.php create mode 100755 system/core/Model.php create mode 100755 system/core/Output.php create mode 100755 system/core/Router.php create mode 100755 system/core/Security.php create mode 100755 system/core/URI.php create mode 100755 system/core/Utf8.php create mode 100755 system/core/index.html create mode 100755 system/database/DB.php create mode 100755 system/database/DB_cache.php create mode 100755 system/database/DB_driver.php create mode 100755 system/database/DB_forge.php create mode 100755 system/database/DB_query_builder.php create mode 100755 system/database/DB_result.php create mode 100755 system/database/DB_utility.php create mode 100755 system/database/drivers/cubrid/cubrid_driver.php create mode 100755 system/database/drivers/cubrid/cubrid_forge.php create mode 100755 system/database/drivers/cubrid/cubrid_result.php create mode 100755 system/database/drivers/cubrid/cubrid_utility.php create mode 100755 system/database/drivers/cubrid/index.html create mode 100755 system/database/drivers/ibase/ibase_driver.php create mode 100755 system/database/drivers/ibase/ibase_forge.php create mode 100755 system/database/drivers/ibase/ibase_result.php create mode 100755 system/database/drivers/ibase/ibase_utility.php create mode 100755 system/database/drivers/ibase/index.html create mode 100755 system/database/drivers/index.html create mode 100755 system/database/drivers/mssql/index.html create mode 100755 system/database/drivers/mssql/mssql_driver.php create mode 100755 system/database/drivers/mssql/mssql_forge.php create mode 100755 system/database/drivers/mssql/mssql_result.php create mode 100755 system/database/drivers/mssql/mssql_utility.php create mode 100755 system/database/drivers/mysql/index.html create mode 100755 system/database/drivers/mysql/mysql_driver.php create mode 100755 system/database/drivers/mysql/mysql_forge.php create mode 100755 system/database/drivers/mysql/mysql_result.php create mode 100755 system/database/drivers/mysql/mysql_utility.php create mode 100755 system/database/drivers/mysqli/index.html create mode 100755 system/database/drivers/mysqli/mysqli_driver.php create mode 100755 system/database/drivers/mysqli/mysqli_forge.php create mode 100755 system/database/drivers/mysqli/mysqli_result.php create mode 100755 system/database/drivers/mysqli/mysqli_utility.php create mode 100755 system/database/drivers/oci8/index.html create mode 100755 system/database/drivers/oci8/oci8_driver.php create mode 100755 system/database/drivers/oci8/oci8_forge.php create mode 100755 system/database/drivers/oci8/oci8_result.php create mode 100755 system/database/drivers/oci8/oci8_utility.php create mode 100755 system/database/drivers/odbc/index.html create mode 100755 system/database/drivers/odbc/odbc_driver.php create mode 100755 system/database/drivers/odbc/odbc_forge.php create mode 100755 system/database/drivers/odbc/odbc_result.php create mode 100755 system/database/drivers/odbc/odbc_utility.php create mode 100755 system/database/drivers/pdo/index.html create mode 100755 system/database/drivers/pdo/pdo_driver.php create mode 100755 system/database/drivers/pdo/pdo_forge.php create mode 100755 system/database/drivers/pdo/pdo_result.php create mode 100755 system/database/drivers/pdo/pdo_utility.php create mode 100755 system/database/drivers/pdo/subdrivers/index.html create mode 100755 system/database/drivers/pdo/subdrivers/pdo_4d_driver.php create mode 100755 system/database/drivers/pdo/subdrivers/pdo_4d_forge.php create mode 100755 system/database/drivers/pdo/subdrivers/pdo_cubrid_driver.php create mode 100755 system/database/drivers/pdo/subdrivers/pdo_cubrid_forge.php create mode 100755 system/database/drivers/pdo/subdrivers/pdo_dblib_driver.php create mode 100755 system/database/drivers/pdo/subdrivers/pdo_dblib_forge.php create mode 100755 system/database/drivers/pdo/subdrivers/pdo_firebird_driver.php create mode 100755 system/database/drivers/pdo/subdrivers/pdo_firebird_forge.php create mode 100755 system/database/drivers/pdo/subdrivers/pdo_ibm_driver.php create mode 100755 system/database/drivers/pdo/subdrivers/pdo_ibm_forge.php create mode 100755 system/database/drivers/pdo/subdrivers/pdo_informix_driver.php create mode 100755 system/database/drivers/pdo/subdrivers/pdo_informix_forge.php create mode 100755 system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php create mode 100755 system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php create mode 100755 system/database/drivers/pdo/subdrivers/pdo_oci_driver.php create mode 100755 system/database/drivers/pdo/subdrivers/pdo_oci_forge.php create mode 100755 system/database/drivers/pdo/subdrivers/pdo_odbc_driver.php create mode 100755 system/database/drivers/pdo/subdrivers/pdo_odbc_forge.php create mode 100755 system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php create mode 100755 system/database/drivers/pdo/subdrivers/pdo_pgsql_forge.php create mode 100755 system/database/drivers/pdo/subdrivers/pdo_sqlite_driver.php create mode 100755 system/database/drivers/pdo/subdrivers/pdo_sqlite_forge.php create mode 100755 system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php create mode 100755 system/database/drivers/pdo/subdrivers/pdo_sqlsrv_forge.php create mode 100755 system/database/drivers/postgre/index.html create mode 100755 system/database/drivers/postgre/postgre_driver.php create mode 100755 system/database/drivers/postgre/postgre_forge.php create mode 100755 system/database/drivers/postgre/postgre_result.php create mode 100755 system/database/drivers/postgre/postgre_utility.php create mode 100755 system/database/drivers/sqlite/index.html create mode 100755 system/database/drivers/sqlite/sqlite_driver.php create mode 100755 system/database/drivers/sqlite/sqlite_forge.php create mode 100755 system/database/drivers/sqlite/sqlite_result.php create mode 100755 system/database/drivers/sqlite/sqlite_utility.php create mode 100755 system/database/drivers/sqlite3/index.html create mode 100755 system/database/drivers/sqlite3/sqlite3_driver.php create mode 100755 system/database/drivers/sqlite3/sqlite3_forge.php create mode 100755 system/database/drivers/sqlite3/sqlite3_result.php create mode 100755 system/database/drivers/sqlite3/sqlite3_utility.php create mode 100755 system/database/drivers/sqlsrv/index.html create mode 100755 system/database/drivers/sqlsrv/sqlsrv_driver.php create mode 100755 system/database/drivers/sqlsrv/sqlsrv_forge.php create mode 100755 system/database/drivers/sqlsrv/sqlsrv_result.php create mode 100755 system/database/drivers/sqlsrv/sqlsrv_utility.php create mode 100755 system/database/index.html create mode 100755 system/fonts/index.html create mode 100755 system/fonts/texb.ttf create mode 100755 system/helpers/array_helper.php create mode 100755 system/helpers/captcha_helper.php create mode 100755 system/helpers/cookie_helper.php create mode 100755 system/helpers/date_helper.php create mode 100755 system/helpers/directory_helper.php create mode 100755 system/helpers/download_helper.php create mode 100755 system/helpers/email_helper.php create mode 100755 system/helpers/file_helper.php create mode 100755 system/helpers/form_helper.php create mode 100755 system/helpers/html_helper.php create mode 100755 system/helpers/index.html create mode 100755 system/helpers/inflector_helper.php create mode 100755 system/helpers/language_helper.php create mode 100755 system/helpers/number_helper.php create mode 100755 system/helpers/path_helper.php create mode 100755 system/helpers/security_helper.php create mode 100755 system/helpers/smiley_helper.php create mode 100755 system/helpers/string_helper.php create mode 100755 system/helpers/text_helper.php create mode 100755 system/helpers/typography_helper.php create mode 100755 system/helpers/url_helper.php create mode 100755 system/helpers/xml_helper.php create mode 100755 system/index.html create mode 100755 system/language/english/calendar_lang.php create mode 100755 system/language/english/date_lang.php create mode 100755 system/language/english/db_lang.php create mode 100755 system/language/english/email_lang.php create mode 100755 system/language/english/form_validation_lang.php create mode 100755 system/language/english/ftp_lang.php create mode 100755 system/language/english/imglib_lang.php create mode 100755 system/language/english/index.html create mode 100755 system/language/english/migration_lang.php create mode 100755 system/language/english/number_lang.php create mode 100755 system/language/english/profiler_lang.php create mode 100755 system/language/english/unit_test_lang.php create mode 100755 system/language/english/upload_lang.php create mode 100755 system/language/index.html create mode 100755 system/libraries/Cache/Cache.php create mode 100755 system/libraries/Cache/drivers/Cache_apc.php create mode 100755 system/libraries/Cache/drivers/Cache_dummy.php create mode 100755 system/libraries/Cache/drivers/Cache_file.php create mode 100755 system/libraries/Cache/drivers/Cache_memcached.php create mode 100755 system/libraries/Cache/drivers/index.html create mode 100755 system/libraries/Cache/index.html create mode 100755 system/libraries/Calendar.php create mode 100755 system/libraries/Cart.php create mode 100755 system/libraries/Driver.php create mode 100755 system/libraries/Email.php create mode 100755 system/libraries/Encrypt.php create mode 100755 system/libraries/Form_validation.php create mode 100755 system/libraries/Ftp.php create mode 100755 system/libraries/Image_lib.php create mode 100755 system/libraries/Javascript.php create mode 100755 system/libraries/Log.php create mode 100755 system/libraries/Migration.php create mode 100755 system/libraries/Pagination.php create mode 100755 system/libraries/Parser.php create mode 100755 system/libraries/Profiler.php create mode 100755 system/libraries/Session.php create mode 100755 system/libraries/Sha1.php create mode 100755 system/libraries/Table.php create mode 100755 system/libraries/Trackback.php create mode 100755 system/libraries/Typography.php create mode 100755 system/libraries/Unit_test.php create mode 100755 system/libraries/Upload.php create mode 100755 system/libraries/User_agent.php create mode 100755 system/libraries/Xmlrpc.php create mode 100755 system/libraries/Xmlrpcs.php create mode 100755 system/libraries/Zip.php create mode 100755 system/libraries/index.html create mode 100755 system/libraries/javascript/Jquery.php create mode 100755 system/libraries/javascript/index.html create mode 100755 tests/bootstrap.php create mode 100755 tests/controllers/LoginControllerTest.php create mode 100755 tests/core/MyControllerTest.php create mode 100755 tests/env/SomeModelTest.php create mode 100755 tests/env/autoloader.php create mode 100755 tests/fixtures/todo_category_fixt.yml create mode 100755 tests/fixtures/todo_checklist_fixt.yml create mode 100755 tests/fixtures/todo_ci_sessions_fixt.yml create mode 100755 tests/fixtures/todo_group_fixt.yml create mode 100755 tests/fixtures/todo_group_task_link_fixt.yml create mode 100755 tests/fixtures/todo_group_users_link_fixt.yml create mode 100755 tests/fixtures/todo_item_comments_fixt.yml create mode 100755 tests/fixtures/todo_item_fixt.yml create mode 100755 tests/fixtures/todo_priority_fixt.yml create mode 100755 tests/fixtures/todo_reminder_fixt.yml create mode 100755 tests/fixtures/todo_status_fixt.yml create mode 100755 tests/fixtures/todo_task_view_fixt.yml create mode 100755 tests/fixtures/todo_user_fixt.yml create mode 100755 tests/fixtures/todo_user_friend_link_fixt.yml create mode 100755 tests/fixtures/todo_user_task_link_fixt.yml create mode 100755 tests/generate create mode 100755 tests/libs/MySessionLibTest.php create mode 100755 tests/libs/PageLibTest.php create mode 100755 tests/libs/TodoLibTest.php create mode 100755 tests/models/FriendModelTest.php create mode 100755 tests/models/TaskModelTest.php create mode 100755 tests/phpunit.xml create mode 100755 tests/system/PHPTest.php create mode 100755 web/css/images/animated-overlay.gif create mode 100755 web/css/images/ui-bg_diagonals-thick_90_eeeeee_40x40.png create mode 100755 web/css/images/ui-bg_flat_15_cd0a0a_40x100.png create mode 100755 web/css/images/ui-bg_glass_100_e4f1fb_1x400.png create mode 100755 web/css/images/ui-bg_glass_50_3baae3_1x400.png create mode 100755 web/css/images/ui-bg_glass_80_d7ebf9_1x400.png create mode 100755 web/css/images/ui-bg_highlight-hard_100_f2f5f7_1x100.png create mode 100755 web/css/images/ui-bg_highlight-hard_70_000000_1x100.png create mode 100755 web/css/images/ui-bg_highlight-soft_100_deedf7_1x100.png create mode 100755 web/css/images/ui-bg_highlight-soft_25_ffef8f_1x100.png create mode 100755 web/css/images/ui-icons_2694e8_256x240.png create mode 100755 web/css/images/ui-icons_2e83ff_256x240.png create mode 100755 web/css/images/ui-icons_3d80b3_256x240.png create mode 100755 web/css/images/ui-icons_72a7cf_256x240.png create mode 100755 web/css/images/ui-icons_ffffff_256x240.png create mode 100755 web/css/jquery-ui.min.css create mode 100755 web/css/message.css create mode 100755 web/css/todo.css create mode 100755 web/famfamfam.css create mode 100755 web/favicon.ico create mode 100755 web/fonts/Puritan/Puritan_Bold-cufon.js create mode 100755 web/fonts/Puritan/Puritan_Bold-webfont.eot create mode 100755 web/fonts/Puritan/Puritan_Bold-webfont.svg create mode 100755 web/fonts/Puritan/Puritan_Bold-webfont.ttf create mode 100755 web/fonts/Puritan/Puritan_Bold-webfont.woff create mode 100755 web/fonts/Puritan/Puritan_Bold_Italic-cufon.js create mode 100755 web/fonts/Puritan/Puritan_Bold_Italic-webfont.eot create mode 100755 web/fonts/Puritan/Puritan_Bold_Italic-webfont.svg create mode 100755 web/fonts/Puritan/Puritan_Bold_Italic-webfont.ttf create mode 100755 web/fonts/Puritan/Puritan_Bold_Italic-webfont.woff create mode 100755 web/fonts/Puritan/Puritan_Italic-cufon.js create mode 100755 web/fonts/Puritan/Puritan_Italic-webfont.eot create mode 100755 web/fonts/Puritan/Puritan_Italic-webfont.svg create mode 100755 web/fonts/Puritan/Puritan_Italic-webfont.ttf create mode 100755 web/fonts/Puritan/Puritan_Italic-webfont.woff create mode 100755 web/fonts/Puritan/Puritan_Regular-cufon.js create mode 100755 web/fonts/Puritan/Puritan_Regular-webfont.eot create mode 100755 web/fonts/Puritan/Puritan_Regular-webfont.svg create mode 100755 web/fonts/Puritan/Puritan_Regular-webfont.ttf create mode 100755 web/fonts/Puritan/Puritan_Regular-webfont.woff create mode 100755 web/fonts/Puritan/SIL Open Font License 1.1.txt create mode 100755 web/fonts/Puritan/demo.html create mode 100755 web/fonts/Puritan/stylesheet.css create mode 100755 web/fonts/Quicksand/Quicksand License.txt create mode 100755 web/fonts/Quicksand/Quicksand_Bold-cufon.js create mode 100755 web/fonts/Quicksand/Quicksand_Bold-webfont.eot create mode 100755 web/fonts/Quicksand/Quicksand_Bold-webfont.svg create mode 100755 web/fonts/Quicksand/Quicksand_Bold-webfont.ttf create mode 100755 web/fonts/Quicksand/Quicksand_Bold-webfont.woff create mode 100755 web/fonts/Quicksand/Quicksand_Bold_Oblique-cufon.js create mode 100755 web/fonts/Quicksand/Quicksand_Bold_Oblique-webfont.eot create mode 100755 web/fonts/Quicksand/Quicksand_Bold_Oblique-webfont.svg create mode 100755 web/fonts/Quicksand/Quicksand_Bold_Oblique-webfont.ttf create mode 100755 web/fonts/Quicksand/Quicksand_Bold_Oblique-webfont.woff create mode 100755 web/fonts/Quicksand/Quicksand_Book-cufon.js create mode 100755 web/fonts/Quicksand/Quicksand_Book-webfont.eot create mode 100755 web/fonts/Quicksand/Quicksand_Book-webfont.svg create mode 100755 web/fonts/Quicksand/Quicksand_Book-webfont.ttf create mode 100755 web/fonts/Quicksand/Quicksand_Book-webfont.woff create mode 100755 web/fonts/Quicksand/Quicksand_Book_Oblique-cufon.js create mode 100755 web/fonts/Quicksand/Quicksand_Book_Oblique-webfont.eot create mode 100755 web/fonts/Quicksand/Quicksand_Book_Oblique-webfont.svg create mode 100755 web/fonts/Quicksand/Quicksand_Book_Oblique-webfont.ttf create mode 100755 web/fonts/Quicksand/Quicksand_Book_Oblique-webfont.woff create mode 100755 web/fonts/Quicksand/Quicksand_Dash-cufon.js create mode 100755 web/fonts/Quicksand/Quicksand_Dash-webfont.eot create mode 100755 web/fonts/Quicksand/Quicksand_Dash-webfont.svg create mode 100755 web/fonts/Quicksand/Quicksand_Dash-webfont.ttf create mode 100755 web/fonts/Quicksand/Quicksand_Dash-webfont.woff create mode 100755 web/fonts/Quicksand/Quicksand_Light-cufon.js create mode 100755 web/fonts/Quicksand/Quicksand_Light-webfont.eot create mode 100755 web/fonts/Quicksand/Quicksand_Light-webfont.svg create mode 100755 web/fonts/Quicksand/Quicksand_Light-webfont.ttf create mode 100755 web/fonts/Quicksand/Quicksand_Light-webfont.woff create mode 100755 web/fonts/Quicksand/Quicksand_Light_Oblique-cufon.js create mode 100755 web/fonts/Quicksand/Quicksand_Light_Oblique-webfont.eot create mode 100755 web/fonts/Quicksand/Quicksand_Light_Oblique-webfont.svg create mode 100755 web/fonts/Quicksand/Quicksand_Light_Oblique-webfont.ttf create mode 100755 web/fonts/Quicksand/Quicksand_Light_Oblique-webfont.woff create mode 100755 web/fonts/Quicksand/demo.html create mode 100755 web/fonts/Quicksand/stylesheet.css create mode 100755 web/google522e2aaa807852ba.html create mode 100755 web/images/ajax-loader.gif create mode 100755 web/images/bgs/Title.png create mode 100755 web/images/bgs/TitleBG.png create mode 100755 web/images/bgs/blue2.png create mode 100755 web/images/bgs/blue3.png create mode 100755 web/images/famfamfam.png create mode 100755 web/images/favicon.ico create mode 100755 web/images/icons/accept.png create mode 100755 web/images/icons/add.png create mode 100755 web/images/icons/anchor.png create mode 100755 web/images/icons/application.png create mode 100755 web/images/icons/arrow_branch.png create mode 100755 web/images/icons/arrow_divide.png create mode 100755 web/images/icons/arrow_down.png create mode 100755 web/images/icons/arrow_in.png create mode 100755 web/images/icons/arrow_inout.png create mode 100755 web/images/icons/arrow_join.png create mode 100755 web/images/icons/arrow_left.png create mode 100755 web/images/icons/arrow_merge.png create mode 100755 web/images/icons/arrow_out.png create mode 100755 web/images/icons/arrow_redo.png create mode 100755 web/images/icons/arrow_refresh.png create mode 100755 web/images/icons/arrow_refresh_small.png create mode 100755 web/images/icons/arrow_right.png create mode 100755 web/images/icons/arrow_rotate_anticlockwise.png create mode 100755 web/images/icons/arrow_rotate_clockwise.png create mode 100755 web/images/icons/arrow_switch.png create mode 100755 web/images/icons/arrow_turn_left.png create mode 100755 web/images/icons/arrow_turn_right.png create mode 100755 web/images/icons/arrow_undo.png create mode 100755 web/images/icons/arrow_up.png create mode 100755 web/images/icons/asterisk_orange.png create mode 100755 web/images/icons/asterisk_yellow.png create mode 100755 web/images/icons/attach.png create mode 100755 web/images/icons/award_star_add.png create mode 100755 web/images/icons/award_star_bronze_1.png create mode 100755 web/images/icons/award_star_bronze_2.png create mode 100755 web/images/icons/award_star_bronze_3.png create mode 100755 web/images/icons/award_star_delete.png create mode 100755 web/images/icons/award_star_gold_1.png create mode 100755 web/images/icons/award_star_gold_2.png create mode 100755 web/images/icons/award_star_gold_3.png create mode 100755 web/images/icons/award_star_silver_1.png create mode 100755 web/images/icons/award_star_silver_2.png create mode 100755 web/images/icons/award_star_silver_3.png create mode 100755 web/images/icons/basket.png create mode 100755 web/images/icons/basket_add.png create mode 100755 web/images/icons/basket_delete.png create mode 100755 web/images/icons/basket_edit.png create mode 100755 web/images/icons/basket_error.png create mode 100755 web/images/icons/basket_go.png create mode 100755 web/images/icons/basket_put.png create mode 100755 web/images/icons/basket_remove.png create mode 100755 web/images/icons/bell.png create mode 100755 web/images/icons/bell_add.png create mode 100755 web/images/icons/bell_delete.png create mode 100755 web/images/icons/bell_error.png create mode 100755 web/images/icons/bell_go.png create mode 100755 web/images/icons/bell_link.png create mode 100755 web/images/icons/bin.png create mode 100755 web/images/icons/bin_closed.png create mode 100755 web/images/icons/bin_empty.png create mode 100755 web/images/icons/bomb.png create mode 100755 web/images/icons/book.png create mode 100755 web/images/icons/book_add.png create mode 100755 web/images/icons/book_addresses.png create mode 100755 web/images/icons/book_delete.png create mode 100755 web/images/icons/book_edit.png create mode 100755 web/images/icons/book_error.png create mode 100755 web/images/icons/book_go.png create mode 100755 web/images/icons/book_key.png create mode 100755 web/images/icons/book_link.png create mode 100755 web/images/icons/book_next.png create mode 100755 web/images/icons/book_open.png create mode 100755 web/images/icons/book_previous.png create mode 100755 web/images/icons/box.png create mode 100755 web/images/icons/brick.png create mode 100755 web/images/icons/brick_add.png create mode 100755 web/images/icons/brick_delete.png create mode 100755 web/images/icons/brick_edit.png create mode 100755 web/images/icons/brick_error.png create mode 100755 web/images/icons/brick_go.png create mode 100755 web/images/icons/brick_link.png create mode 100755 web/images/icons/bricks.png create mode 100755 web/images/icons/briefcase.png create mode 100755 web/images/icons/bug.png create mode 100755 web/images/icons/bug_add.png create mode 100755 web/images/icons/bug_delete.png create mode 100755 web/images/icons/bug_edit.png create mode 100755 web/images/icons/bug_error.png create mode 100755 web/images/icons/bug_go.png create mode 100755 web/images/icons/bug_link.png create mode 100755 web/images/icons/building.png create mode 100755 web/images/icons/building_add.png create mode 100755 web/images/icons/building_delete.png create mode 100755 web/images/icons/building_edit.png create mode 100755 web/images/icons/building_error.png create mode 100755 web/images/icons/building_go.png create mode 100755 web/images/icons/building_key.png create mode 100755 web/images/icons/building_link.png create mode 100755 web/images/icons/bullet_add.png create mode 100755 web/images/icons/bullet_arrow_bottom.png create mode 100755 web/images/icons/bullet_arrow_down.png create mode 100755 web/images/icons/bullet_arrow_top.png create mode 100755 web/images/icons/bullet_arrow_up.png create mode 100755 web/images/icons/bullet_black.png create mode 100755 web/images/icons/bullet_blue.png create mode 100755 web/images/icons/bullet_delete.png create mode 100755 web/images/icons/bullet_disk.png create mode 100755 web/images/icons/bullet_error.png create mode 100755 web/images/icons/bullet_feed.png create mode 100755 web/images/icons/bullet_go.png create mode 100755 web/images/icons/bullet_green.png create mode 100755 web/images/icons/bullet_key.png create mode 100755 web/images/icons/bullet_orange.png create mode 100755 web/images/icons/bullet_picture.png create mode 100755 web/images/icons/bullet_pink.png create mode 100755 web/images/icons/bullet_purple.png create mode 100755 web/images/icons/bullet_red.png create mode 100755 web/images/icons/bullet_star.png create mode 100755 web/images/icons/bullet_toggle_minus.png create mode 100755 web/images/icons/bullet_toggle_plus.png create mode 100755 web/images/icons/bullet_white.png create mode 100755 web/images/icons/bullet_wrench.png create mode 100755 web/images/icons/bullet_yellow.png create mode 100755 web/images/icons/cake.png create mode 100755 web/images/icons/calculator.png create mode 100755 web/images/icons/calculator_add.png create mode 100755 web/images/icons/calculator_delete.png create mode 100755 web/images/icons/calculator_edit.png create mode 100755 web/images/icons/calculator_error.png create mode 100755 web/images/icons/calculator_link.png create mode 100755 web/images/icons/calendar.png create mode 100755 web/images/icons/calendar_add.png create mode 100755 web/images/icons/calendar_delete.png create mode 100755 web/images/icons/calendar_edit.png create mode 100755 web/images/icons/calendar_link.png create mode 100755 web/images/icons/calendar_view_day.png create mode 100755 web/images/icons/calendar_view_month.png create mode 100755 web/images/icons/calendar_view_week.png create mode 100755 web/images/icons/camera.png create mode 100755 web/images/icons/camera_add.png create mode 100755 web/images/icons/camera_delete.png create mode 100755 web/images/icons/camera_edit.png create mode 100755 web/images/icons/camera_error.png create mode 100755 web/images/icons/camera_go.png create mode 100755 web/images/icons/camera_link.png create mode 100755 web/images/icons/camera_small.png create mode 100755 web/images/icons/cancel.png create mode 100755 web/images/icons/car.png create mode 100755 web/images/icons/car_add.png create mode 100755 web/images/icons/car_delete.png create mode 100755 web/images/icons/cart.png create mode 100755 web/images/icons/cart_add.png create mode 100755 web/images/icons/cart_delete.png create mode 100755 web/images/icons/cart_edit.png create mode 100755 web/images/icons/cart_error.png create mode 100755 web/images/icons/cart_go.png create mode 100755 web/images/icons/cart_put.png create mode 100755 web/images/icons/cart_remove.png create mode 100755 web/images/icons/cd.png create mode 100755 web/images/icons/cd_add.png create mode 100755 web/images/icons/cd_burn.png create mode 100755 web/images/icons/cd_delete.png create mode 100755 web/images/icons/cd_edit.png create mode 100755 web/images/icons/cd_eject.png create mode 100755 web/images/icons/cd_go.png create mode 100755 web/images/icons/chart_bar.png create mode 100755 web/images/icons/chart_bar_add.png create mode 100755 web/images/icons/chart_bar_delete.png create mode 100755 web/images/icons/chart_bar_edit.png create mode 100755 web/images/icons/chart_bar_error.png create mode 100755 web/images/icons/chart_bar_link.png create mode 100755 web/images/icons/chart_curve.png create mode 100755 web/images/icons/chart_curve_add.png create mode 100755 web/images/icons/chart_curve_delete.png create mode 100755 web/images/icons/chart_curve_edit.png create mode 100755 web/images/icons/chart_curve_error.png create mode 100755 web/images/icons/chart_curve_go.png create mode 100755 web/images/icons/chart_curve_link.png create mode 100755 web/images/icons/chart_line.png create mode 100755 web/images/icons/chart_line_add.png create mode 100755 web/images/icons/chart_line_delete.png create mode 100755 web/images/icons/chart_line_edit.png create mode 100755 web/images/icons/chart_line_error.png create mode 100755 web/images/icons/chart_line_link.png create mode 100755 web/images/icons/chart_organisation.png create mode 100755 web/images/icons/chart_organisation_add.png create mode 100755 web/images/icons/chart_organisation_delete.png create mode 100755 web/images/icons/chart_pie.png create mode 100755 web/images/icons/chart_pie_add.png create mode 100755 web/images/icons/chart_pie_delete.png create mode 100755 web/images/icons/chart_pie_edit.png create mode 100755 web/images/icons/chart_pie_error.png create mode 100755 web/images/icons/chart_pie_link.png create mode 100755 web/images/icons/circular/add.png create mode 100755 web/images/icons/circular/arrow_down.png create mode 100755 web/images/icons/circular/arrow_left.png create mode 100755 web/images/icons/circular/arrow_right.png create mode 100755 web/images/icons/circular/arrow_up.png create mode 100755 web/images/icons/circular/arrows_4_way.png create mode 100755 web/images/icons/circular/arrows_east_west.png create mode 100755 web/images/icons/circular/arrows_north_east.png create mode 100755 web/images/icons/circular/arrows_north_south.png create mode 100755 web/images/icons/circular/arrows_south_west.png create mode 100755 web/images/icons/circular/at.png create mode 100755 web/images/icons/circular/book.png create mode 100755 web/images/icons/circular/broadcast.png create mode 100755 web/images/icons/circular/bulb.png create mode 100755 web/images/icons/circular/bullet_black.png create mode 100755 web/images/icons/circular/bullet_blue.png create mode 100755 web/images/icons/circular/bullet_green.png create mode 100755 web/images/icons/circular/bullet_red.png create mode 100755 web/images/icons/circular/bullet_yellow.png create mode 100755 web/images/icons/circular/cancel.png create mode 100755 web/images/icons/circular/cart.png create mode 100755 web/images/icons/circular/cd.png create mode 100755 web/images/icons/circular/clock.png create mode 100755 web/images/icons/circular/cog.png create mode 100755 web/images/icons/circular/comment.png create mode 100755 web/images/icons/circular/comments.png create mode 100755 web/images/icons/circular/copy.png create mode 100755 web/images/icons/circular/copyright.png create mode 100755 web/images/icons/circular/currency_eur.png create mode 100755 web/images/icons/circular/currency_gbp.png create mode 100755 web/images/icons/circular/currency_jpn.png create mode 100755 web/images/icons/circular/currency_usd.png create mode 100755 web/images/icons/circular/cut.png create mode 100755 web/images/icons/circular/delete.png create mode 100755 web/images/icons/circular/edit.png create mode 100755 web/images/icons/circular/element_clouds.png create mode 100755 web/images/icons/circular/element_fire.png create mode 100755 web/images/icons/circular/element_lightning.png create mode 100755 web/images/icons/circular/element_rain_clouds.png create mode 100755 web/images/icons/circular/element_sun.png create mode 100755 web/images/icons/circular/element_sun_cloud.png create mode 100755 web/images/icons/circular/element_water.png create mode 100755 web/images/icons/circular/email.png create mode 100755 web/images/icons/circular/eye.png create mode 100755 web/images/icons/circular/fast_forward.png create mode 100755 web/images/icons/circular/flag_black.png create mode 100755 web/images/icons/circular/flag_blue.png create mode 100755 web/images/icons/circular/flag_green.png create mode 100755 web/images/icons/circular/flag_red.png create mode 100755 web/images/icons/circular/flag_yellow.png create mode 100755 web/images/icons/circular/folder.png create mode 100755 web/images/icons/circular/folder_close.png create mode 100755 web/images/icons/circular/folder_document.png create mode 100755 web/images/icons/circular/folder_open.png create mode 100755 web/images/icons/circular/heart_black.png create mode 100755 web/images/icons/circular/heart_blue.png create mode 100755 web/images/icons/circular/heart_green.png create mode 100755 web/images/icons/circular/heart_red.png create mode 100755 web/images/icons/circular/heart_yellow.png create mode 100755 web/images/icons/circular/help.png create mode 100755 web/images/icons/circular/home.png create mode 100755 web/images/icons/circular/hourglass.png create mode 100755 web/images/icons/circular/information.png create mode 100755 web/images/icons/circular/key.png create mode 100755 web/images/icons/circular/magnify.png create mode 100755 web/images/icons/circular/magnify_minus.png create mode 100755 web/images/icons/circular/magnify_plus.png create mode 100755 web/images/icons/circular/minus.png create mode 100755 web/images/icons/circular/moon.png create mode 100755 web/images/icons/circular/music.png create mode 100755 web/images/icons/circular/new.png create mode 100755 web/images/icons/circular/no.png create mode 100755 web/images/icons/circular/omega.png create mode 100755 web/images/icons/circular/padlock_closed.png create mode 100755 web/images/icons/circular/padlock_open.png create mode 100755 web/images/icons/circular/paperclip.png create mode 100755 web/images/icons/circular/paste.png create mode 100755 web/images/icons/circular/pause.png create mode 100755 web/images/icons/circular/phone.png create mode 100755 web/images/icons/circular/pie_chart.png create mode 100755 web/images/icons/circular/play.png create mode 100755 web/images/icons/circular/pointer.png create mode 100755 web/images/icons/circular/power_off.png create mode 100755 web/images/icons/circular/power_on.png create mode 100755 web/images/icons/circular/print.png create mode 100755 web/images/icons/circular/puzzle.png create mode 100755 web/images/icons/circular/quote.png create mode 100755 web/images/icons/circular/refresh.png create mode 100755 web/images/icons/circular/rewind.png create mode 100755 web/images/icons/circular/rss.png create mode 100755 web/images/icons/circular/save.png create mode 100755 web/images/icons/circular/share_this.png create mode 100755 web/images/icons/circular/smiley_big_grin.png create mode 100755 web/images/icons/circular/smiley_flat.png create mode 100755 web/images/icons/circular/smiley_frown.png create mode 100755 web/images/icons/circular/smiley_smile.png create mode 100755 web/images/icons/circular/smiley_tounge.png create mode 100755 web/images/icons/circular/smiley_wink.png create mode 100755 web/images/icons/circular/speaker_off.png create mode 100755 web/images/icons/circular/speaker_on.png create mode 100755 web/images/icons/circular/star_black.png create mode 100755 web/images/icons/circular/star_blue.png create mode 100755 web/images/icons/circular/star_green.png create mode 100755 web/images/icons/circular/star_red.png create mode 100755 web/images/icons/circular/star_yellow.png create mode 100755 web/images/icons/circular/stop.png create mode 100755 web/images/icons/circular/tag_black.png create mode 100755 web/images/icons/circular/tag_blue.png create mode 100755 web/images/icons/circular/tag_green.png create mode 100755 web/images/icons/circular/tag_red.png create mode 100755 web/images/icons/circular/tag_yellow.png create mode 100755 web/images/icons/circular/turn_left.png create mode 100755 web/images/icons/circular/turn_right.png create mode 100755 web/images/icons/circular/user.png create mode 100755 web/images/icons/circular/warning.png create mode 100755 web/images/icons/circular/world.png create mode 100755 web/images/icons/circular/yes.png create mode 100755 web/images/icons/clock.png create mode 100755 web/images/icons/clock_add.png create mode 100755 web/images/icons/clock_delete.png create mode 100755 web/images/icons/clock_edit.png create mode 100755 web/images/icons/clock_error.png create mode 100755 web/images/icons/clock_go.png create mode 100755 web/images/icons/clock_link.png create mode 100755 web/images/icons/clock_pause.png create mode 100755 web/images/icons/clock_play.png create mode 100755 web/images/icons/clock_red.png create mode 100755 web/images/icons/clock_stop.png create mode 100755 web/images/icons/cog.png create mode 100755 web/images/icons/cog_add.png create mode 100755 web/images/icons/cog_delete.png create mode 100755 web/images/icons/cog_edit.png create mode 100755 web/images/icons/cog_error.png create mode 100755 web/images/icons/cog_go.png create mode 100755 web/images/icons/coins.png create mode 100755 web/images/icons/coins_add.png create mode 100755 web/images/icons/coins_delete.png create mode 100755 web/images/icons/color_swatch.png create mode 100755 web/images/icons/color_wheel.png create mode 100755 web/images/icons/comment.png create mode 100755 web/images/icons/comment_add.png create mode 100755 web/images/icons/comment_delete.png create mode 100755 web/images/icons/comment_edit.png create mode 100755 web/images/icons/comments.png create mode 100755 web/images/icons/comments_add.png create mode 100755 web/images/icons/comments_delete.png create mode 100755 web/images/icons/compress.png create mode 100755 web/images/icons/computer.png create mode 100755 web/images/icons/computer_add.png create mode 100755 web/images/icons/computer_delete.png create mode 100755 web/images/icons/computer_edit.png create mode 100755 web/images/icons/computer_error.png create mode 100755 web/images/icons/computer_go.png create mode 100755 web/images/icons/computer_key.png create mode 100755 web/images/icons/computer_link.png create mode 100755 web/images/icons/connect.png create mode 100755 web/images/icons/contrast.png create mode 100755 web/images/icons/contrast_decrease.png create mode 100755 web/images/icons/contrast_high.png create mode 100755 web/images/icons/contrast_increase.png create mode 100755 web/images/icons/contrast_low.png create mode 100755 web/images/icons/control_eject.png create mode 100755 web/images/icons/control_eject_blue.png create mode 100755 web/images/icons/control_end.png create mode 100755 web/images/icons/control_end_blue.png create mode 100755 web/images/icons/control_equalizer.png create mode 100755 web/images/icons/control_equalizer_blue.png create mode 100755 web/images/icons/control_fastforward.png create mode 100755 web/images/icons/control_fastforward_blue.png create mode 100755 web/images/icons/control_pause.png create mode 100755 web/images/icons/control_pause_blue.png create mode 100755 web/images/icons/control_play.png create mode 100755 web/images/icons/control_play_blue.png create mode 100755 web/images/icons/control_repeat.png create mode 100755 web/images/icons/control_repeat_blue.png create mode 100755 web/images/icons/control_rewind.png create mode 100755 web/images/icons/control_rewind_blue.png create mode 100755 web/images/icons/control_start.png create mode 100755 web/images/icons/control_start_blue.png create mode 100755 web/images/icons/control_stop.png create mode 100755 web/images/icons/control_stop_blue.png create mode 100755 web/images/icons/controller.png create mode 100755 web/images/icons/controller_add.png create mode 100755 web/images/icons/controller_delete.png create mode 100755 web/images/icons/controller_error.png create mode 100755 web/images/icons/creditcards.png create mode 100755 web/images/icons/cross.png create mode 100755 web/images/icons/css.png create mode 100755 web/images/icons/css_add.png create mode 100755 web/images/icons/css_delete.png create mode 100755 web/images/icons/css_go.png create mode 100755 web/images/icons/css_valid.png create mode 100755 web/images/icons/cup.png create mode 100755 web/images/icons/cup_add.png create mode 100755 web/images/icons/cup_delete.png create mode 100755 web/images/icons/cup_edit.png create mode 100755 web/images/icons/cup_error.png create mode 100755 web/images/icons/cup_go.png create mode 100755 web/images/icons/cup_key.png create mode 100755 web/images/icons/cup_link.png create mode 100755 web/images/icons/cursor.png create mode 100755 web/images/icons/cut.png create mode 100755 web/images/icons/cut_red.png create mode 100755 web/images/icons/database.png create mode 100755 web/images/icons/database_add.png create mode 100755 web/images/icons/database_connect.png create mode 100755 web/images/icons/database_delete.png create mode 100755 web/images/icons/database_edit.png create mode 100755 web/images/icons/database_error.png create mode 100755 web/images/icons/database_gear.png create mode 100755 web/images/icons/database_go.png create mode 100755 web/images/icons/database_key.png create mode 100755 web/images/icons/database_lightning.png create mode 100755 web/images/icons/database_link.png create mode 100755 web/images/icons/database_refresh.png create mode 100755 web/images/icons/database_save.png create mode 100755 web/images/icons/database_table.png create mode 100755 web/images/icons/date.png create mode 100755 web/images/icons/date_add.png create mode 100755 web/images/icons/date_delete.png create mode 100755 web/images/icons/date_edit.png create mode 100755 web/images/icons/date_error.png create mode 100755 web/images/icons/date_go.png create mode 100755 web/images/icons/date_link.png create mode 100755 web/images/icons/date_magnify.png create mode 100755 web/images/icons/date_next.png create mode 100755 web/images/icons/date_previous.png create mode 100755 web/images/icons/delete.png create mode 100755 web/images/icons/disconnect.png create mode 100755 web/images/icons/disk.png create mode 100755 web/images/icons/disk_multiple.png create mode 100755 web/images/icons/door.png create mode 100755 web/images/icons/door_in.png create mode 100755 web/images/icons/door_open.png create mode 100755 web/images/icons/door_out.png create mode 100755 web/images/icons/drink.png create mode 100755 web/images/icons/drink_empty.png create mode 100755 web/images/icons/drive.png create mode 100755 web/images/icons/drive_add.png create mode 100755 web/images/icons/drive_burn.png create mode 100755 web/images/icons/drive_cd.png create mode 100755 web/images/icons/drive_cd_empty.png create mode 100755 web/images/icons/drive_delete.png create mode 100755 web/images/icons/drive_disk.png create mode 100755 web/images/icons/drive_edit.png create mode 100755 web/images/icons/drive_error.png create mode 100755 web/images/icons/drive_go.png create mode 100755 web/images/icons/drive_key.png create mode 100755 web/images/icons/drive_link.png create mode 100755 web/images/icons/drive_magnify.png create mode 100755 web/images/icons/drive_network.png create mode 100755 web/images/icons/drive_rename.png create mode 100755 web/images/icons/drive_user.png create mode 100755 web/images/icons/drive_web.png create mode 100755 web/images/icons/dvd.png create mode 100755 web/images/icons/dvd_add.png create mode 100755 web/images/icons/dvd_delete.png create mode 100755 web/images/icons/dvd_edit.png create mode 100755 web/images/icons/dvd_error.png create mode 100755 web/images/icons/dvd_go.png create mode 100755 web/images/icons/dvd_key.png create mode 100755 web/images/icons/dvd_link.png create mode 100755 web/images/icons/email.png create mode 100755 web/images/icons/email_add.png create mode 100755 web/images/icons/email_attach.png create mode 100755 web/images/icons/email_delete.png create mode 100755 web/images/icons/email_edit.png create mode 100755 web/images/icons/email_error.png create mode 100755 web/images/icons/email_go.png create mode 100755 web/images/icons/email_link.png create mode 100755 web/images/icons/email_open.png create mode 100755 web/images/icons/email_open_image.png create mode 100755 web/images/icons/emoticon_evilgrin.png create mode 100755 web/images/icons/emoticon_grin.png create mode 100755 web/images/icons/emoticon_happy.png create mode 100755 web/images/icons/emoticon_smile.png create mode 100755 web/images/icons/emoticon_surprised.png create mode 100755 web/images/icons/emoticon_tongue.png create mode 100755 web/images/icons/emoticon_unhappy.png create mode 100755 web/images/icons/emoticon_waii.png create mode 100755 web/images/icons/emoticon_wink.png create mode 100755 web/images/icons/error.png create mode 100755 web/images/icons/error_add.png create mode 100755 web/images/icons/error_delete.png create mode 100755 web/images/icons/error_go.png create mode 100755 web/images/icons/exclamation.png create mode 100755 web/images/icons/eye.png create mode 100755 web/images/icons/feed.png create mode 100755 web/images/icons/feed_add.png create mode 100755 web/images/icons/feed_delete.png create mode 100755 web/images/icons/feed_disk.png create mode 100755 web/images/icons/feed_edit.png create mode 100755 web/images/icons/feed_error.png create mode 100755 web/images/icons/feed_go.png create mode 100755 web/images/icons/feed_key.png create mode 100755 web/images/icons/feed_link.png create mode 100755 web/images/icons/feed_magnify.png create mode 100755 web/images/icons/female.png create mode 100755 web/images/icons/film.png create mode 100755 web/images/icons/film_add.png create mode 100755 web/images/icons/film_edit.png create mode 100755 web/images/icons/film_error.png create mode 100755 web/images/icons/film_go.png create mode 100755 web/images/icons/film_key.png create mode 100755 web/images/icons/film_link.png create mode 100755 web/images/icons/film_save.png create mode 100755 web/images/icons/find.png create mode 100755 web/images/icons/flag_blue.png create mode 100755 web/images/icons/flag_green.png create mode 100755 web/images/icons/flag_orange.png create mode 100755 web/images/icons/flag_pink.png create mode 100755 web/images/icons/flag_purple.png create mode 100755 web/images/icons/flag_red.png create mode 100755 web/images/icons/flag_yellow.png create mode 100755 web/images/icons/folder.png create mode 100755 web/images/icons/folder_add.png create mode 100755 web/images/icons/folder_bell.png create mode 100755 web/images/icons/folder_brick.png create mode 100755 web/images/icons/folder_bug.png create mode 100755 web/images/icons/folder_camera.png create mode 100755 web/images/icons/folder_database.png create mode 100755 web/images/icons/folder_delete.png create mode 100755 web/images/icons/folder_edit.png create mode 100755 web/images/icons/folder_error.png create mode 100755 web/images/icons/folder_explore.png create mode 100755 web/images/icons/folder_feed.png create mode 100755 web/images/icons/folder_find.png create mode 100755 web/images/icons/folder_go.png create mode 100755 web/images/icons/folder_heart.png create mode 100755 web/images/icons/folder_image.png create mode 100755 web/images/icons/folder_key.png create mode 100755 web/images/icons/folder_lightbulb.png create mode 100755 web/images/icons/folder_link.png create mode 100755 web/images/icons/folder_magnify.png create mode 100755 web/images/icons/folder_page.png create mode 100755 web/images/icons/folder_page_white.png create mode 100755 web/images/icons/folder_palette.png create mode 100755 web/images/icons/folder_picture.png create mode 100755 web/images/icons/folder_star.png create mode 100755 web/images/icons/folder_table.png create mode 100755 web/images/icons/folder_user.png create mode 100755 web/images/icons/folder_wrench.png create mode 100755 web/images/icons/font.png create mode 100755 web/images/icons/font_add.png create mode 100755 web/images/icons/font_delete.png create mode 100755 web/images/icons/font_go.png create mode 100755 web/images/icons/group.png create mode 100755 web/images/icons/group_add.png create mode 100755 web/images/icons/group_delete.png create mode 100755 web/images/icons/group_edit.png create mode 100755 web/images/icons/group_error.png create mode 100755 web/images/icons/group_gear.png create mode 100755 web/images/icons/group_go.png create mode 100755 web/images/icons/group_key.png create mode 100755 web/images/icons/group_link.png create mode 100755 web/images/icons/heart.png create mode 100755 web/images/icons/heart_add.png create mode 100755 web/images/icons/heart_delete.png create mode 100755 web/images/icons/help.png create mode 100755 web/images/icons/hourglass.png create mode 100755 web/images/icons/hourglass_add.png create mode 100755 web/images/icons/hourglass_delete.png create mode 100755 web/images/icons/hourglass_go.png create mode 100755 web/images/icons/hourglass_link.png create mode 100755 web/images/icons/house.png create mode 100755 web/images/icons/house_go.png create mode 100755 web/images/icons/house_link.png create mode 100755 web/images/icons/html.png create mode 100755 web/images/icons/html_add.png create mode 100755 web/images/icons/html_delete.png create mode 100755 web/images/icons/html_go.png create mode 100755 web/images/icons/html_valid.png create mode 100755 web/images/icons/image.png create mode 100755 web/images/icons/image_add.png create mode 100755 web/images/icons/image_delete.png create mode 100755 web/images/icons/image_edit.png create mode 100755 web/images/icons/image_link.png create mode 100755 web/images/icons/images.png create mode 100755 web/images/icons/information.png create mode 100755 web/images/icons/ipod.png create mode 100755 web/images/icons/ipod_cast.png create mode 100755 web/images/icons/ipod_cast_add.png create mode 100755 web/images/icons/ipod_cast_delete.png create mode 100755 web/images/icons/ipod_sound.png create mode 100755 web/images/icons/joystick.png create mode 100755 web/images/icons/joystick_add.png create mode 100755 web/images/icons/joystick_delete.png create mode 100755 web/images/icons/joystick_error.png create mode 100755 web/images/icons/key.png create mode 100755 web/images/icons/key_add.png create mode 100755 web/images/icons/key_delete.png create mode 100755 web/images/icons/key_go.png create mode 100755 web/images/icons/keyboard.png create mode 100755 web/images/icons/keyboard_add.png create mode 100755 web/images/icons/keyboard_delete.png create mode 100755 web/images/icons/keyboard_magnify.png create mode 100755 web/images/icons/layers.png create mode 100755 web/images/icons/layout.png create mode 100755 web/images/icons/layout_add.png create mode 100755 web/images/icons/layout_content.png create mode 100755 web/images/icons/layout_delete.png create mode 100755 web/images/icons/layout_edit.png create mode 100755 web/images/icons/layout_error.png create mode 100755 web/images/icons/layout_header.png create mode 100755 web/images/icons/layout_link.png create mode 100755 web/images/icons/layout_sidebar.png create mode 100755 web/images/icons/lightbulb.png create mode 100755 web/images/icons/lightbulb_add.png create mode 100755 web/images/icons/lightbulb_delete.png create mode 100755 web/images/icons/lightbulb_off.png create mode 100755 web/images/icons/lightning.png create mode 100755 web/images/icons/lightning_add.png create mode 100755 web/images/icons/lightning_delete.png create mode 100755 web/images/icons/lightning_go.png create mode 100755 web/images/icons/link.png create mode 100755 web/images/icons/link_add.png create mode 100755 web/images/icons/link_break.png create mode 100755 web/images/icons/link_delete.png create mode 100755 web/images/icons/link_edit.png create mode 100755 web/images/icons/link_error.png create mode 100755 web/images/icons/link_go.png create mode 100755 web/images/icons/lock.png create mode 100755 web/images/icons/lock_add.png create mode 100755 web/images/icons/lock_break.png create mode 100755 web/images/icons/lock_delete.png create mode 100755 web/images/icons/lock_edit.png create mode 100755 web/images/icons/lock_go.png create mode 100755 web/images/icons/lock_open.png create mode 100755 web/images/icons/lorry.png create mode 100755 web/images/icons/lorry_add.png create mode 100755 web/images/icons/lorry_delete.png create mode 100755 web/images/icons/lorry_error.png create mode 100755 web/images/icons/lorry_flatbed.png create mode 100755 web/images/icons/lorry_go.png create mode 100755 web/images/icons/lorry_link.png create mode 100755 web/images/icons/magifier_zoom_out.png create mode 100755 web/images/icons/magnifier.png create mode 100755 web/images/icons/magnifier_zoom_in.png create mode 100755 web/images/icons/male.png create mode 100755 web/images/icons/map.png create mode 100755 web/images/icons/map_add.png create mode 100755 web/images/icons/map_delete.png create mode 100755 web/images/icons/map_edit.png create mode 100755 web/images/icons/map_go.png create mode 100755 web/images/icons/map_magnify.png create mode 100755 web/images/icons/medal_bronze_1.png create mode 100755 web/images/icons/medal_bronze_2.png create mode 100755 web/images/icons/medal_bronze_3.png create mode 100755 web/images/icons/medal_bronze_add.png create mode 100755 web/images/icons/medal_bronze_delete.png create mode 100755 web/images/icons/medal_gold_1.png create mode 100755 web/images/icons/medal_gold_2.png create mode 100755 web/images/icons/medal_gold_3.png create mode 100755 web/images/icons/medal_gold_add.png create mode 100755 web/images/icons/medal_gold_delete.png create mode 100755 web/images/icons/medal_silver_1.png create mode 100755 web/images/icons/medal_silver_2.png create mode 100755 web/images/icons/medal_silver_3.png create mode 100755 web/images/icons/medal_silver_add.png create mode 100755 web/images/icons/medal_silver_delete.png create mode 100755 web/images/icons/money.png create mode 100755 web/images/icons/money_add.png create mode 100755 web/images/icons/money_delete.png create mode 100755 web/images/icons/money_dollar.png create mode 100755 web/images/icons/money_euro.png create mode 100755 web/images/icons/money_pound.png create mode 100755 web/images/icons/money_yen.png create mode 100755 web/images/icons/monitor.png create mode 100755 web/images/icons/monitor_add.png create mode 100755 web/images/icons/monitor_delete.png create mode 100755 web/images/icons/monitor_edit.png create mode 100755 web/images/icons/monitor_error.png create mode 100755 web/images/icons/monitor_go.png create mode 100755 web/images/icons/monitor_lightning.png create mode 100755 web/images/icons/monitor_link.png create mode 100755 web/images/icons/mouse.png create mode 100755 web/images/icons/mouse_add.png create mode 100755 web/images/icons/mouse_delete.png create mode 100755 web/images/icons/mouse_error.png create mode 100755 web/images/icons/music.png create mode 100755 web/images/icons/new.png create mode 100755 web/images/icons/newspaper.png create mode 100755 web/images/icons/newspaper_add.png create mode 100755 web/images/icons/newspaper_delete.png create mode 100755 web/images/icons/newspaper_go.png create mode 100755 web/images/icons/newspaper_link.png create mode 100755 web/images/icons/note.png create mode 100755 web/images/icons/note_add.png create mode 100755 web/images/icons/note_delete.png create mode 100755 web/images/icons/note_edit.png create mode 100755 web/images/icons/note_error.png create mode 100755 web/images/icons/note_go.png create mode 100755 web/images/icons/overlays.png create mode 100755 web/images/icons/package.png create mode 100755 web/images/icons/package_add.png create mode 100755 web/images/icons/package_delete.png create mode 100755 web/images/icons/package_go.png create mode 100755 web/images/icons/package_green.png create mode 100755 web/images/icons/package_link.png create mode 100755 web/images/icons/page.png create mode 100755 web/images/icons/page_add.png create mode 100755 web/images/icons/page_attach.png create mode 100755 web/images/icons/page_code.png create mode 100755 web/images/icons/page_copy.png create mode 100755 web/images/icons/page_delete.png create mode 100755 web/images/icons/page_edit.png create mode 100755 web/images/icons/page_error.png create mode 100755 web/images/icons/page_excel.png create mode 100755 web/images/icons/page_find.png create mode 100755 web/images/icons/page_gear.png create mode 100755 web/images/icons/page_go.png create mode 100755 web/images/icons/page_green.png create mode 100755 web/images/icons/page_key.png create mode 100755 web/images/icons/page_lightning.png create mode 100755 web/images/icons/page_link.png create mode 100755 web/images/icons/page_paintbrush.png create mode 100755 web/images/icons/page_paste.png create mode 100755 web/images/icons/page_red.png create mode 100755 web/images/icons/page_refresh.png create mode 100755 web/images/icons/page_save.png create mode 100755 web/images/icons/page_white.png create mode 100755 web/images/icons/page_white_acrobat.png create mode 100755 web/images/icons/page_white_actionscript.png create mode 100755 web/images/icons/page_white_add.png create mode 100755 web/images/icons/page_white_c.png create mode 100755 web/images/icons/page_white_camera.png create mode 100755 web/images/icons/page_white_cd.png create mode 100755 web/images/icons/page_white_code.png create mode 100755 web/images/icons/page_white_code_red.png create mode 100755 web/images/icons/page_white_coldfusion.png create mode 100755 web/images/icons/page_white_compressed.png create mode 100755 web/images/icons/page_white_copy.png create mode 100755 web/images/icons/page_white_cplusplus.png create mode 100755 web/images/icons/page_white_csharp.png create mode 100755 web/images/icons/page_white_cup.png create mode 100755 web/images/icons/page_white_database.png create mode 100755 web/images/icons/page_white_delete.png create mode 100755 web/images/icons/page_white_dvd.png create mode 100755 web/images/icons/page_white_edit.png create mode 100755 web/images/icons/page_white_error.png create mode 100755 web/images/icons/page_white_excel.png create mode 100755 web/images/icons/page_white_find.png create mode 100755 web/images/icons/page_white_flash.png create mode 100755 web/images/icons/page_white_freehand.png create mode 100755 web/images/icons/page_white_gear.png create mode 100755 web/images/icons/page_white_get.png create mode 100755 web/images/icons/page_white_go.png create mode 100755 web/images/icons/page_white_h.png create mode 100755 web/images/icons/page_white_horizontal.png create mode 100755 web/images/icons/page_white_key.png create mode 100755 web/images/icons/page_white_lightning.png create mode 100755 web/images/icons/page_white_link.png create mode 100755 web/images/icons/page_white_magnify.png create mode 100755 web/images/icons/page_white_medal.png create mode 100755 web/images/icons/page_white_office.png create mode 100755 web/images/icons/page_white_paint.png create mode 100755 web/images/icons/page_white_paintbrush.png create mode 100755 web/images/icons/page_white_paste.png create mode 100755 web/images/icons/page_white_php.png create mode 100755 web/images/icons/page_white_picture.png create mode 100755 web/images/icons/page_white_powerpoint.png create mode 100755 web/images/icons/page_white_put.png create mode 100755 web/images/icons/page_white_ruby.png create mode 100755 web/images/icons/page_white_stack.png create mode 100755 web/images/icons/page_white_star.png create mode 100755 web/images/icons/page_white_swoosh.png create mode 100755 web/images/icons/page_white_text.png create mode 100755 web/images/icons/page_white_text_width.png create mode 100755 web/images/icons/page_white_tux.png create mode 100755 web/images/icons/page_white_vector.png create mode 100755 web/images/icons/page_white_visualstudio.png create mode 100755 web/images/icons/page_white_width.png create mode 100755 web/images/icons/page_white_word.png create mode 100755 web/images/icons/page_white_world.png create mode 100755 web/images/icons/page_white_wrench.png create mode 100755 web/images/icons/page_white_zip.png create mode 100755 web/images/icons/page_word.png create mode 100755 web/images/icons/page_world.png create mode 100755 web/images/icons/paintbrush.png create mode 100755 web/images/icons/paintcan.png create mode 100755 web/images/icons/palette.png create mode 100755 web/images/icons/paste_plain.png create mode 100755 web/images/icons/paste_word.png create mode 100755 web/images/icons/pencil.png create mode 100755 web/images/icons/pencil_add.png create mode 100755 web/images/icons/pencil_delete.png create mode 100755 web/images/icons/pencil_go.png create mode 100755 web/images/icons/phone.png create mode 100755 web/images/icons/phone_add.png create mode 100755 web/images/icons/phone_delete.png create mode 100755 web/images/icons/phone_sound.png create mode 100755 web/images/icons/photo.png create mode 100755 web/images/icons/photo_add.png create mode 100755 web/images/icons/photo_delete.png create mode 100755 web/images/icons/photo_link.png create mode 100755 web/images/icons/photos.png create mode 100755 web/images/icons/picture.png create mode 100755 web/images/icons/picture_add.png create mode 100755 web/images/icons/picture_delete.png create mode 100755 web/images/icons/picture_edit.png create mode 100755 web/images/icons/picture_empty.png create mode 100755 web/images/icons/picture_error.png create mode 100755 web/images/icons/picture_go.png create mode 100755 web/images/icons/picture_key.png create mode 100755 web/images/icons/picture_link.png create mode 100755 web/images/icons/picture_save.png create mode 100755 web/images/icons/pictures.png create mode 100755 web/images/icons/pilcrow.png create mode 100755 web/images/icons/pill.png create mode 100755 web/images/icons/pill_add.png create mode 100755 web/images/icons/pill_delete.png create mode 100755 web/images/icons/pill_go.png create mode 100755 web/images/icons/plugin.png create mode 100755 web/images/icons/plugin_add.png create mode 100755 web/images/icons/plugin_delete.png create mode 100755 web/images/icons/plugin_disabled.png create mode 100755 web/images/icons/plugin_edit.png create mode 100755 web/images/icons/plugin_error.png create mode 100755 web/images/icons/plugin_go.png create mode 100755 web/images/icons/plugin_link.png create mode 100755 web/images/icons/printer.png create mode 100755 web/images/icons/printer_delete.png create mode 100755 web/images/icons/printer_empty.png create mode 100755 web/images/icons/printer_error.png create mode 100755 web/images/icons/rainbow.png create mode 100755 web/images/icons/report.png create mode 100755 web/images/icons/report_add.png create mode 100755 web/images/icons/report_delete.png create mode 100755 web/images/icons/report_disk.png create mode 100755 web/images/icons/report_edit.png create mode 100755 web/images/icons/report_go.png create mode 100755 web/images/icons/report_key.png create mode 100755 web/images/icons/report_link.png create mode 100755 web/images/icons/report_magnify.png create mode 100755 web/images/icons/report_picture.png create mode 100755 web/images/icons/report_user.png create mode 100755 web/images/icons/report_word.png create mode 100755 web/images/icons/resultset_first.png create mode 100755 web/images/icons/resultset_last.png create mode 100755 web/images/icons/resultset_next.png create mode 100755 web/images/icons/resultset_previous.png create mode 100755 web/images/icons/rosette.png create mode 100755 web/images/icons/rss.png create mode 100755 web/images/icons/rss_add.png create mode 100755 web/images/icons/rss_delete.png create mode 100755 web/images/icons/rss_go.png create mode 100755 web/images/icons/rss_valid.png create mode 100755 web/images/icons/ruby.png create mode 100755 web/images/icons/ruby_add.png create mode 100755 web/images/icons/ruby_delete.png create mode 100755 web/images/icons/ruby_gear.png create mode 100755 web/images/icons/ruby_get.png create mode 100755 web/images/icons/ruby_go.png create mode 100755 web/images/icons/ruby_key.png create mode 100755 web/images/icons/ruby_link.png create mode 100755 web/images/icons/ruby_put.png create mode 100755 web/images/icons/script.png create mode 100755 web/images/icons/script_add.png create mode 100755 web/images/icons/script_code.png create mode 100755 web/images/icons/script_code_red.png create mode 100755 web/images/icons/script_delete.png create mode 100755 web/images/icons/script_edit.png create mode 100755 web/images/icons/script_error.png create mode 100755 web/images/icons/script_gear.png create mode 100755 web/images/icons/script_go.png create mode 100755 web/images/icons/script_key.png create mode 100755 web/images/icons/script_lightning.png create mode 100755 web/images/icons/script_link.png create mode 100755 web/images/icons/script_palette.png create mode 100755 web/images/icons/script_save.png create mode 100755 web/images/icons/server.png create mode 100755 web/images/icons/server_add.png create mode 100755 web/images/icons/server_chart.png create mode 100755 web/images/icons/server_compressed.png create mode 100755 web/images/icons/server_connect.png create mode 100755 web/images/icons/server_database.png create mode 100755 web/images/icons/server_delete.png create mode 100755 web/images/icons/server_edit.png create mode 100755 web/images/icons/server_error.png create mode 100755 web/images/icons/server_go.png create mode 100755 web/images/icons/server_key.png create mode 100755 web/images/icons/server_lightning.png create mode 100755 web/images/icons/server_link.png create mode 100755 web/images/icons/server_uncompressed.png create mode 100755 web/images/icons/shading.png create mode 100755 web/images/icons/shape_align_bottom.png create mode 100755 web/images/icons/shape_align_center.png create mode 100755 web/images/icons/shape_align_left.png create mode 100755 web/images/icons/shape_align_middle.png create mode 100755 web/images/icons/shape_align_right.png create mode 100755 web/images/icons/shape_align_top.png create mode 100755 web/images/icons/shape_flip_horizontal.png create mode 100755 web/images/icons/shape_flip_vertical.png create mode 100755 web/images/icons/shape_group.png create mode 100755 web/images/icons/shape_handles.png create mode 100755 web/images/icons/shape_move_back.png create mode 100755 web/images/icons/shape_move_backwards.png create mode 100755 web/images/icons/shape_move_forwards.png create mode 100755 web/images/icons/shape_move_front.png create mode 100755 web/images/icons/shape_rotate_anticlockwise.png create mode 100755 web/images/icons/shape_rotate_clockwise.png create mode 100755 web/images/icons/shape_square.png create mode 100755 web/images/icons/shape_square_add.png create mode 100755 web/images/icons/shape_square_delete.png create mode 100755 web/images/icons/shape_square_edit.png create mode 100755 web/images/icons/shape_square_error.png create mode 100755 web/images/icons/shape_square_go.png create mode 100755 web/images/icons/shape_square_key.png create mode 100755 web/images/icons/shape_square_link.png create mode 100755 web/images/icons/shape_ungroup.png create mode 100755 web/images/icons/shield.png create mode 100755 web/images/icons/shield_add.png create mode 100755 web/images/icons/shield_delete.png create mode 100755 web/images/icons/shield_go.png create mode 100755 web/images/icons/sitemap.png create mode 100755 web/images/icons/sitemap_color.png create mode 100755 web/images/icons/sound.png create mode 100755 web/images/icons/sound_add.png create mode 100755 web/images/icons/sound_delete.png create mode 100755 web/images/icons/sound_low.png create mode 100755 web/images/icons/sound_mute.png create mode 100755 web/images/icons/sound_none.png create mode 100755 web/images/icons/spellcheck.png create mode 100755 web/images/icons/sport_8ball.png create mode 100755 web/images/icons/sport_basketball.png create mode 100755 web/images/icons/sport_football.png create mode 100755 web/images/icons/sport_golf.png create mode 100755 web/images/icons/sport_raquet.png create mode 100755 web/images/icons/sport_shuttlecock.png create mode 100755 web/images/icons/sport_soccer.png create mode 100755 web/images/icons/sport_tennis.png create mode 100755 web/images/icons/star.png create mode 100755 web/images/icons/status_away.png create mode 100755 web/images/icons/status_busy.png create mode 100755 web/images/icons/status_offline.png create mode 100755 web/images/icons/status_online.png create mode 100755 web/images/icons/stop.png create mode 100755 web/images/icons/style.png create mode 100755 web/images/icons/style_add.png create mode 100755 web/images/icons/style_delete.png create mode 100755 web/images/icons/style_edit.png create mode 100755 web/images/icons/style_go.png create mode 100755 web/images/icons/sum.png create mode 100755 web/images/icons/tab.png create mode 100755 web/images/icons/tab_add.png create mode 100755 web/images/icons/tab_delete.png create mode 100755 web/images/icons/tab_edit.png create mode 100755 web/images/icons/tab_go.png create mode 100755 web/images/icons/table.png create mode 100755 web/images/icons/table_add.png create mode 100755 web/images/icons/table_delete.png create mode 100755 web/images/icons/table_edit.png create mode 100755 web/images/icons/table_error.png create mode 100755 web/images/icons/table_gear.png create mode 100755 web/images/icons/table_go.png create mode 100755 web/images/icons/table_key.png create mode 100755 web/images/icons/table_lightning.png create mode 100755 web/images/icons/table_link.png create mode 100755 web/images/icons/table_multiple.png create mode 100755 web/images/icons/table_refresh.png create mode 100755 web/images/icons/table_relationship.png create mode 100755 web/images/icons/table_row_delete.png create mode 100755 web/images/icons/table_row_insert.png create mode 100755 web/images/icons/table_save.png create mode 100755 web/images/icons/table_sort.png create mode 100755 web/images/icons/tag.png create mode 100755 web/images/icons/tag_blue.png create mode 100755 web/images/icons/tag_blue_add.png create mode 100755 web/images/icons/tag_blue_delete.png create mode 100755 web/images/icons/tag_blue_edit.png create mode 100755 web/images/icons/tag_green.png create mode 100755 web/images/icons/tag_orange.png create mode 100755 web/images/icons/tag_pink.png create mode 100755 web/images/icons/tag_purple.png create mode 100755 web/images/icons/tag_red.png create mode 100755 web/images/icons/tag_yellow.png create mode 100755 web/images/icons/telephone.png create mode 100755 web/images/icons/telephone_add.png create mode 100755 web/images/icons/telephone_delete.png create mode 100755 web/images/icons/telephone_edit.png create mode 100755 web/images/icons/telephone_error.png create mode 100755 web/images/icons/telephone_go.png create mode 100755 web/images/icons/telephone_key.png create mode 100755 web/images/icons/telephone_link.png create mode 100755 web/images/icons/television.png create mode 100755 web/images/icons/television_add.png create mode 100755 web/images/icons/television_delete.png create mode 100755 web/images/icons/text_align_center.png create mode 100755 web/images/icons/text_align_justify.png create mode 100755 web/images/icons/text_align_left.png create mode 100755 web/images/icons/text_align_right.png create mode 100755 web/images/icons/text_allcaps.png create mode 100755 web/images/icons/text_bold.png create mode 100755 web/images/icons/text_columns.png create mode 100755 web/images/icons/text_dropcaps.png create mode 100755 web/images/icons/text_heading_1.png create mode 100755 web/images/icons/text_heading_2.png create mode 100755 web/images/icons/text_heading_3.png create mode 100755 web/images/icons/text_heading_4.png create mode 100755 web/images/icons/text_heading_5.png create mode 100755 web/images/icons/text_heading_6.png create mode 100755 web/images/icons/text_horizontalrule.png create mode 100755 web/images/icons/text_indent.png create mode 100755 web/images/icons/text_indent_remove.png create mode 100755 web/images/icons/text_italic.png create mode 100755 web/images/icons/text_kerning.png create mode 100755 web/images/icons/text_letter_omega.png create mode 100755 web/images/icons/text_letterspacing.png create mode 100755 web/images/icons/text_linespacing.png create mode 100755 web/images/icons/text_list_bullets.png create mode 100755 web/images/icons/text_list_numbers.png create mode 100755 web/images/icons/text_lowercase.png create mode 100755 web/images/icons/text_padding_bottom.png create mode 100755 web/images/icons/text_padding_left.png create mode 100755 web/images/icons/text_padding_right.png create mode 100755 web/images/icons/text_padding_top.png create mode 100755 web/images/icons/text_replace.png create mode 100755 web/images/icons/text_signature.png create mode 100755 web/images/icons/text_smallcaps.png create mode 100755 web/images/icons/text_strikethrough.png create mode 100755 web/images/icons/text_subscript.png create mode 100755 web/images/icons/text_superscript.png create mode 100755 web/images/icons/text_underline.png create mode 100755 web/images/icons/text_uppercase.png create mode 100755 web/images/icons/textfield.png create mode 100755 web/images/icons/textfield_add.png create mode 100755 web/images/icons/textfield_delete.png create mode 100755 web/images/icons/textfield_key.png create mode 100755 web/images/icons/textfield_rename.png create mode 100755 web/images/icons/thumb_down.png create mode 100755 web/images/icons/thumb_up.png create mode 100755 web/images/icons/tick.png create mode 100755 web/images/icons/time.png create mode 100755 web/images/icons/time_add.png create mode 100755 web/images/icons/time_delete.png create mode 100755 web/images/icons/time_go.png create mode 100755 web/images/icons/timeline_marker.png create mode 100755 web/images/icons/transmit.png create mode 100755 web/images/icons/transmit_add.png create mode 100755 web/images/icons/transmit_blue.png create mode 100755 web/images/icons/transmit_delete.png create mode 100755 web/images/icons/transmit_edit.png create mode 100755 web/images/icons/transmit_error.png create mode 100755 web/images/icons/transmit_go.png create mode 100755 web/images/icons/tux.png create mode 100755 web/images/icons/urgent.png create mode 100755 web/images/icons/user.png create mode 100755 web/images/icons/user_add.png create mode 100755 web/images/icons/user_comment.png create mode 100755 web/images/icons/user_delete.png create mode 100755 web/images/icons/user_edit.png create mode 100755 web/images/icons/user_female.png create mode 100755 web/images/icons/user_go.png create mode 100755 web/images/icons/user_gray.png create mode 100755 web/images/icons/user_green.png create mode 100755 web/images/icons/user_orange.png create mode 100755 web/images/icons/user_red.png create mode 100755 web/images/icons/user_suit.png create mode 100755 web/images/icons/vcard.png create mode 100755 web/images/icons/vcard_add.png create mode 100755 web/images/icons/vcard_delete.png create mode 100755 web/images/icons/vcard_edit.png create mode 100755 web/images/icons/vector.png create mode 100755 web/images/icons/vector_add.png create mode 100755 web/images/icons/vector_delete.png create mode 100755 web/images/icons/wand.png create mode 100755 web/images/icons/weather_clouds.png create mode 100755 web/images/icons/weather_cloudy.png create mode 100755 web/images/icons/weather_lightning.png create mode 100755 web/images/icons/weather_rain.png create mode 100755 web/images/icons/weather_snow.png create mode 100755 web/images/icons/weather_sun.png create mode 100755 web/images/icons/webcam.png create mode 100755 web/images/icons/webcam_add.png create mode 100755 web/images/icons/webcam_delete.png create mode 100755 web/images/icons/webcam_error.png create mode 100755 web/images/icons/world.png create mode 100755 web/images/icons/world_add.png create mode 100755 web/images/icons/world_delete.png create mode 100755 web/images/icons/world_edit.png create mode 100755 web/images/icons/world_go.png create mode 100755 web/images/icons/world_link.png create mode 100755 web/images/icons/wrench.png create mode 100755 web/images/icons/wrench_orange.png create mode 100755 web/images/icons/xhtml.png create mode 100755 web/images/icons/xhtml_add.png create mode 100755 web/images/icons/xhtml_delete.png create mode 100755 web/images/icons/xhtml_go.png create mode 100755 web/images/icons/xhtml_valid.png create mode 100755 web/images/icons/zoom.png create mode 100755 web/images/icons/zoom_in.png create mode 100755 web/images/icons/zoom_out.png create mode 100755 web/images/todo.png create mode 100755 web/index.php create mode 100755 web/js/CLEditor/images/buttons.gif create mode 100755 web/js/CLEditor/images/toolbar.gif create mode 100755 web/js/CLEditor/jquery.cleditor.css create mode 100755 web/js/CLEditor/jquery.cleditor.js create mode 100755 web/js/CLEditor/jquery.cleditor.min.js create mode 100755 web/js/CLEditor/jquery.cleditor.xhtml.js create mode 100755 web/js/CLEditor/jquery.cleditor.xhtml.min.js create mode 100755 web/js/jquery-ui.min.js create mode 100755 web/js/jquery.html5form-min.js create mode 100755 web/js/jquery.js create mode 100755 web/js/todo.js create mode 100755 web/min/index.php create mode 100755 web/min/lib/FirePHP.php create mode 100755 web/min/lib/HTTP/ConditionalGet.php create mode 100755 web/min/lib/HTTP/Encoder.php create mode 100755 web/min/lib/JSMin.php create mode 100755 web/min/lib/JSMinPlus.php create mode 100755 web/min/lib/Minify.php create mode 100755 web/min/lib/Minify/Build.php create mode 100755 web/min/lib/Minify/CSS.php create mode 100755 web/min/lib/Minify/CSS/Compressor.php create mode 100755 web/min/lib/Minify/CSS/UriRewriter.php create mode 100755 web/min/lib/Minify/Cache/APC.php create mode 100755 web/min/lib/Minify/Cache/File.php create mode 100755 web/min/lib/Minify/Cache/Memcache.php create mode 100755 web/min/lib/Minify/CommentPreserver.php create mode 100755 web/min/lib/Minify/Controller/Base.php create mode 100755 web/min/lib/Minify/Controller/Files.php create mode 100755 web/min/lib/Minify/Controller/Groups.php create mode 100755 web/min/lib/Minify/Controller/MinApp.php create mode 100755 web/min/lib/Minify/Controller/Page.php create mode 100755 web/min/lib/Minify/Controller/Version1.php create mode 100755 web/min/lib/Minify/HTML.php create mode 100755 web/min/lib/Minify/ImportProcessor.php create mode 100755 web/min/lib/Minify/Lines.php create mode 100755 web/min/lib/Minify/Logger.php create mode 100755 web/min/lib/Minify/Packer.php create mode 100755 web/min/lib/Minify/Source.php create mode 100755 web/min/lib/Minify/YUICompressor.php create mode 100755 web/min/lib/Solar/Dir.php create mode 100755 web/min/utils.php create mode 100755 web/robots.txt diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..e411b2c --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +web/cron.log +application/logs/*.php +application/cache/* +web/coverage/* +vendor/* +composer.lock diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/application/config/autoload.php b/application/config/autoload.php new file mode 100755 index 0000000..467aaa6 --- /dev/null +++ b/application/config/autoload.php @@ -0,0 +1,123 @@ + [ + 'hostname' => 'localhost', + 'username' => 'todo', + 'password' => 'todo', + 'database' => 'todo', + 'dbdriver' => 'postgre', + 'dbprefix' => 'todo_', + 'pconnect' => TRUE, + 'db_debug' => TRUE, + 'cache_on' => FALSE, + 'cachedir' => '', + 'char_set' => 'utf8', + 'dbcollat' => 'utf8_general_ci', + 'swap_pre' => '', + 'autoinit' => TRUE, + 'stricton' => FALSE + ], +]; + + +/* End of file database.php */ +/* Location: ./system/application/config/database.php */ \ No newline at end of file diff --git a/application/config/doctypes.php b/application/config/doctypes.php new file mode 100755 index 0000000..f742db8 --- /dev/null +++ b/application/config/doctypes.php @@ -0,0 +1,17 @@ + '', + 'xhtml11svg' => '', + + 'xhtml1-strict' => '', + 'xhtml1-trans' => '', + 'xhtml1-frame' => '', + 'html5' => '', + 'html4-strict' => '', + 'html4-trans' => '', + 'html4-frame' => '' + ); + +/* End of file doctypes.php */ +/* Location: application/config/doctypes.php */ \ No newline at end of file diff --git a/application/config/form_validation.php b/application/config/form_validation.php new file mode 100755 index 0000000..69807c6 --- /dev/null +++ b/application/config/form_validation.php @@ -0,0 +1,67 @@ + [ + [ + 'field' => 'title', + 'label' => 'Title', + 'rules' => 'required|min_length[1]|max_length[255]|xss_clean' + ], + [ + 'field' => 'desc', + 'label' => 'Description', + 'rules' => 'required|min_length[1]|xss_clean' + ], + [ + 'field' => 'category', + 'label' => 'Category', + 'rules' => 'required|is_natural_no_zero' + ], + [ + 'field' => 'priority', + 'label' => 'Priority', + 'rules' => 'required|is_natural' + ], + [ + 'field' => 'due_hour', + 'label' => 'Due Hour', + 'rules' => 'min_length[1]|less_than[24]|is_natural' + ], + [ + 'field' => 'due_minute', + 'label' => 'Due Minute', + 'rules' => 'min_length[1]|less_than[61]|is_natural' + ], + [ + 'field' => 'due', + 'label' => 'Due Date', + 'rules' => 'callback_validate[due_date]' + ], + [ + 'field' => 'reminder', + 'label' => 'Reminder', + 'rules' => '' + ] + ], + 'login/register' => [ + [ + 'field' => 'email', + 'label' => 'Email Address', + 'rules' => 'required|callback_validate[valid_email]|is_unique[user.email]' + ], + [ + 'field' => 'user', + 'label' => 'Username', + 'rules' => 'required|is_unique[user.username]' + ], + [ + 'field' => 'pass', + 'label' => 'Password', + 'rules' => 'required', + ], + [ + 'field' => 'pass1', + 'label' => 'Password Confirmation', + 'rules' => 'required|matches[pass]', + ] + ] +]; \ No newline at end of file diff --git a/application/config/hooks.php b/application/config/hooks.php new file mode 100755 index 0000000..b232cb0 --- /dev/null +++ b/application/config/hooks.php @@ -0,0 +1,23 @@ + '', + 'function' => 'check_session', + 'filename' => 'pre-controller.php', + 'filepath' => 'hooks' +); + + + +/* End of file hooks.php */ +/* Location: ./system/application/config/hooks.php */ \ No newline at end of file diff --git a/application/config/index.html b/application/config/index.html new file mode 100755 index 0000000..c942a79 --- /dev/null +++ b/application/config/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + \ No newline at end of file diff --git a/application/config/mimes.php b/application/config/mimes.php new file mode 100755 index 0000000..438f610 --- /dev/null +++ b/application/config/mimes.php @@ -0,0 +1,105 @@ + 'application/mac-binhex40', + 'cpt' => 'application/mac-compactpro', + 'csv' => array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel'), + 'bin' => 'application/macbinary', + 'dms' => 'application/octet-stream', + 'lha' => 'application/octet-stream', + 'lzh' => 'application/octet-stream', + 'exe' => 'application/octet-stream', + 'class' => 'application/octet-stream', + 'psd' => 'application/x-photoshop', + 'so' => 'application/octet-stream', + 'sea' => 'application/octet-stream', + 'dll' => 'application/octet-stream', + 'oda' => 'application/oda', + 'pdf' => array('application/pdf', 'application/x-download'), + 'ai' => 'application/postscript', + 'eps' => 'application/postscript', + 'ps' => 'application/postscript', + 'smi' => 'application/smil', + 'smil' => 'application/smil', + 'mif' => 'application/vnd.mif', + 'xls' => array('application/excel', 'application/vnd.ms-excel', 'application/msexcel'), + 'ppt' => array('application/powerpoint', 'application/vnd.ms-powerpoint'), + 'wbxml' => 'application/wbxml', + 'wmlc' => 'application/wmlc', + 'dcr' => 'application/x-director', + 'dir' => 'application/x-director', + 'dxr' => 'application/x-director', + 'dvi' => 'application/x-dvi', + 'gtar' => 'application/x-gtar', + 'gz' => 'application/x-gzip', + 'php' => 'application/x-httpd-php', + 'php4' => 'application/x-httpd-php', + 'php3' => 'application/x-httpd-php', + 'phtml' => 'application/x-httpd-php', + 'phps' => 'application/x-httpd-php-source', + 'js' => 'application/x-javascript', + 'swf' => 'application/x-shockwave-flash', + 'sit' => 'application/x-stuffit', + 'tar' => 'application/x-tar', + 'tgz' => 'application/x-tar', + 'xhtml' => 'application/xhtml+xml', + 'xht' => 'application/xhtml+xml', + 'zip' => array('application/x-zip', 'application/zip', 'application/x-zip-compressed'), + 'mid' => 'audio/midi', + 'midi' => 'audio/midi', + 'mpga' => 'audio/mpeg', + 'mp2' => 'audio/mpeg', + 'mp3' => array('audio/mpeg', 'audio/mpg'), + 'aif' => 'audio/x-aiff', + 'aiff' => 'audio/x-aiff', + 'aifc' => 'audio/x-aiff', + 'ram' => 'audio/x-pn-realaudio', + 'rm' => 'audio/x-pn-realaudio', + 'rpm' => 'audio/x-pn-realaudio-plugin', + 'ra' => 'audio/x-realaudio', + 'rv' => 'video/vnd.rn-realvideo', + 'wav' => 'audio/x-wav', + 'bmp' => 'image/bmp', + 'gif' => 'image/gif', + 'jpeg' => array('image/jpeg', 'image/pjpeg'), + 'jpg' => array('image/jpeg', 'image/pjpeg'), + 'jpe' => array('image/jpeg', 'image/pjpeg'), + 'png' => array('image/png', 'image/x-png'), + 'tiff' => 'image/tiff', + 'tif' => 'image/tiff', + 'css' => 'text/css', + 'html' => 'text/html', + 'htm' => 'text/html', + 'shtml' => 'text/html', + 'txt' => 'text/plain', + 'text' => 'text/plain', + 'log' => array('text/plain', 'text/x-log'), + 'rtx' => 'text/richtext', + 'rtf' => 'text/rtf', + 'xml' => 'text/xml', + 'xsl' => 'text/xml', + 'mpeg' => 'video/mpeg', + 'mpg' => 'video/mpeg', + 'mpe' => 'video/mpeg', + 'qt' => 'video/quicktime', + 'mov' => 'video/quicktime', + 'avi' => 'video/x-msvideo', + 'movie' => 'video/x-sgi-movie', + 'doc' => 'application/msword', + 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'word' => array('application/msword', 'application/octet-stream'), + 'xl' => 'application/excel', + 'eml' => 'message/rfc822' + ); + + +/* End of file mimes.php */ +/* Location: ./system/application/config/mimes.php */ \ No newline at end of file diff --git a/application/config/min_config.php b/application/config/min_config.php new file mode 100755 index 0000000..e967d17 --- /dev/null +++ b/application/config/min_config.php @@ -0,0 +1,144 @@ + + * array('//symlink' => '/real/target/path') // unix + * array('//static' => 'D:\\staticStorage') // Windows + * + */ +$min_symlinks = array( + +); + + +/** + * If you upload files from Windows to a non-Windows server, Windows may report + * incorrect mtimes for the files. This may cause Minify to keep serving stale + * cache files when source file changes are made too frequently (e.g. more than + * once an hour). + * + * Immediately after modifying and uploading a file, use the touch command to + * update the mtime on the server. If the mtime jumps ahead by a number of hours, + * set this variable to that number. If the mtime moves back, this should not be + * needed. + * + * In the Windows SFTP client WinSCP, there's an option that may fix this + * issue without changing the variable below. Under login > environment, + * select the option "Adjust remote timestamp with DST". + * @link http://winscp.net/eng/docs/ui_login_environment#daylight_saving_time + */ +$min_uploaderHoursBehind = 0; + + +// try to disable output_compression (may not have an effect) +ini_set('zlib.output_compression', '0'); + +//Use JSMin+ +$min_serveOptions['minifiers']['application/x-javascript'] = array('JSMinPlus', 'minify'); diff --git a/application/config/min_groupsConfig.php b/application/config/min_groupsConfig.php new file mode 100755 index 0000000..5d0b300 --- /dev/null +++ b/application/config/min_groupsConfig.php @@ -0,0 +1,36 @@ + array( + $root. 'fonts/Puritan/stylesheet.css', + $root. 'css/todo.css', + $root. 'css/message.css', + $root. 'js/CLEditor/jquery.cleditor.css', + $root. 'css/jquery-ui.min.css' + ), + + /*----- + Javascript + -----*/ + 'js' => array( + $root. 'js/CLEditor/jquery.cleditor.js', + $root. 'js/CLEditor/jquery.cleditor.xhtml.js', + $root. 'js/todo.js', + ), + + 'js_mobile' => array( + $root. 'js/todo.js', + ), + +); \ No newline at end of file diff --git a/application/config/profiler.php b/application/config/profiler.php new file mode 100755 index 0000000..6e8748b --- /dev/null +++ b/application/config/profiler.php @@ -0,0 +1,53 @@ + 'login', + + 'logout' => 'login/logout', + 'login' => 'login/do_login', + 'register' => 'login/register', + 'task/list' => 'task/list_tasks', + 'friend/list' => 'friend/friend_list', + 'category/list' => 'category/category_list', + 'task/category/list' => 'category/category_list', + 'task/calendar' => 'calendar/index', + 'task/calendar/:any' => 'calendar/index', + 'task/archive/:num' => 'task/archive', + + '404_overide' => '' +]; + +/* End of file routes.php */ +/* Location: ./system/application/config/routes.php */ \ No newline at end of file diff --git a/application/config/sites.php b/application/config/sites.php new file mode 100755 index 0000000..9d8b288 --- /dev/null +++ b/application/config/sites.php @@ -0,0 +1,119 @@ + array('grin.gif', '19', '19', 'grin'), + ':lol:' => array('lol.gif', '19', '19', 'LOL'), + ':cheese:' => array('cheese.gif', '19', '19', 'cheese'), + ':)' => array('smile.gif', '19', '19', 'smile'), + ';-)' => array('wink.gif', '19', '19', 'wink'), + ';)' => array('wink.gif', '19', '19', 'wink'), + ':smirk:' => array('smirk.gif', '19', '19', 'smirk'), + ':roll:' => array('rolleyes.gif', '19', '19', 'rolleyes'), + ':-S' => array('confused.gif', '19', '19', 'confused'), + ':wow:' => array('surprise.gif', '19', '19', 'surprised'), + ':bug:' => array('bigsurprise.gif', '19', '19', 'big surprise'), + ':-P' => array('tongue_laugh.gif', '19', '19', 'tongue laugh'), + '%-P' => array('tongue_rolleye.gif', '19', '19', 'tongue rolleye'), + ';-P' => array('tongue_wink.gif', '19', '19', 'tongue wink'), + ':P' => array('raspberry.gif', '19', '19', 'raspberry'), + ':blank:' => array('blank.gif', '19', '19', 'blank stare'), + ':long:' => array('longface.gif', '19', '19', 'long face'), + ':ohh:' => array('ohh.gif', '19', '19', 'ohh'), + ':grrr:' => array('grrr.gif', '19', '19', 'grrr'), + ':gulp:' => array('gulp.gif', '19', '19', 'gulp'), + '8-/' => array('ohoh.gif', '19', '19', 'oh oh'), + ':down:' => array('downer.gif', '19', '19', 'downer'), + ':red:' => array('embarrassed.gif', '19', '19', 'red face'), + ':sick:' => array('sick.gif', '19', '19', 'sick'), + ':shut:' => array('shuteye.gif', '19', '19', 'shut eye'), + ':-/' => array('hmm.gif', '19', '19', 'hmmm'), + '>:(' => array('mad.gif', '19', '19', 'mad'), + ':mad:' => array('mad.gif', '19', '19', 'mad'), + '>:-(' => array('angry.gif', '19', '19', 'angry'), + ':angry:' => array('angry.gif', '19', '19', 'angry'), + ':zip:' => array('zip.gif', '19', '19', 'zipper'), + ':kiss:' => array('kiss.gif', '19', '19', 'kiss'), + ':ahhh:' => array('shock.gif', '19', '19', 'shock'), + ':coolsmile:' => array('shade_smile.gif', '19', '19', 'cool smile'), + ':coolsmirk:' => array('shade_smirk.gif', '19', '19', 'cool smirk'), + ':coolgrin:' => array('shade_grin.gif', '19', '19', 'cool grin'), + ':coolhmm:' => array('shade_hmm.gif', '19', '19', 'cool hmm'), + ':coolmad:' => array('shade_mad.gif', '19', '19', 'cool mad'), + ':coolcheese:' => array('shade_cheese.gif', '19', '19', 'cool cheese'), + ':vampire:' => array('vampire.gif', '19', '19', 'vampire'), + ':snake:' => array('snake.gif', '19', '19', 'snake'), + ':exclaim:' => array('exclaim.gif', '19', '19', 'excaim'), + ':question:' => array('question.gif', '19', '19', 'question') // no comma after last item + + ); + +/* End of file smileys.php */ +/* Location: ./system/application/config/smileys.php */ \ No newline at end of file diff --git a/application/config/testing/database.php b/application/config/testing/database.php new file mode 100755 index 0000000..ac09b79 --- /dev/null +++ b/application/config/testing/database.php @@ -0,0 +1,62 @@ + [ + 'hostname' => 'localhost', + 'username' => 'todo_test', + 'password' => 'test', + 'database' => 'todo_test', + 'dbdriver' => 'postgre', + 'dbprefix' => 'todo_', + 'pconnect' => FALSE, + 'db_debug' => TRUE, + 'cache_on' => FALSE, + 'cachedir' => '', + 'char_set' => 'utf8', + 'dbcollat' => 'utf8_general_ci', + 'swap_pre' => '', + 'autoinit' => FALSE, + 'stricton' => FALSE + ] +]; + + +/* End of file database.php */ +/* Location: ./system/application/config/database.php */ \ No newline at end of file diff --git a/application/config/user_agents.php b/application/config/user_agents.php new file mode 100755 index 0000000..f15b007 --- /dev/null +++ b/application/config/user_agents.php @@ -0,0 +1,175 @@ + 'Windows Longhorn', + 'windows nt 5.2' => 'Windows 2003', + 'windows nt 5.0' => 'Windows 2000', + 'windows nt 5.1' => 'Windows XP', + 'windows nt 4.0' => 'Windows NT 4.0', + 'winnt4.0' => 'Windows NT 4.0', + 'winnt 4.0' => 'Windows NT', + 'winnt' => 'Windows NT', + 'windows 98' => 'Windows 98', + 'win98' => 'Windows 98', + 'windows 95' => 'Windows 95', + 'win95' => 'Windows 95', + 'windows' => 'Unknown Windows OS', + 'os x' => 'Mac OS X', + 'ppc mac' => 'Power PC Mac', + 'freebsd' => 'FreeBSD', + 'ppc' => 'Macintosh', + 'linux' => 'Linux', + 'debian' => 'Debian', + 'sunos' => 'Sun Solaris', + 'beos' => 'BeOS', + 'apachebench' => 'ApacheBench', + 'aix' => 'AIX', + 'irix' => 'Irix', + 'osf' => 'DEC OSF', + 'hp-ux' => 'HP-UX', + 'netbsd' => 'NetBSD', + 'bsdi' => 'BSDi', + 'openbsd' => 'OpenBSD', + 'gnu' => 'GNU/Linux', + 'unix' => 'Unknown Unix OS' + ); + + +// The order of this array should NOT be changed. Many browsers return +// multiple browser types so we want to identify the sub-type first. +$browsers = array( + 'Opera' => 'Opera', + 'MSIE' => 'Internet Explorer', + 'Internet Explorer' => 'Internet Explorer', + 'Shiira' => 'Shiira', + 'Firefox' => 'Firefox', + 'Chimera' => 'Chimera', + 'Phoenix' => 'Phoenix', + 'Firebird' => 'Firebird', + 'Camino' => 'Camino', + 'Netscape' => 'Netscape', + 'OmniWeb' => 'OmniWeb', + 'Safari' => 'Safari', + 'Mozilla' => 'Mozilla', + 'Konqueror' => 'Konqueror', + 'icab' => 'iCab', + 'Lynx' => 'Lynx', + 'Links' => 'Links', + 'hotjava' => 'HotJava', + 'amaya' => 'Amaya', + 'IBrowse' => 'IBrowse' + ); + +$mobiles = array( + // legacy array, old values commented out + 'mobileexplorer' => 'Mobile Explorer', +// 'openwave' => 'Open Wave', +// 'opera mini' => 'Opera Mini', +// 'operamini' => 'Opera Mini', +// 'elaine' => 'Palm', + 'palmsource' => 'Palm', +// 'digital paths' => 'Palm', +// 'avantgo' => 'Avantgo', +// 'xiino' => 'Xiino', + 'palmscape' => 'Palmscape', +// 'nokia' => 'Nokia', +// 'ericsson' => 'Ericsson', +// 'blackberry' => 'BlackBerry', +// 'motorola' => 'Motorola' + + // Phones and Manufacturers + 'motorola' => "Motorola", + 'nokia' => "Nokia", + 'palm' => "Palm", + 'iphone' => "Apple iPhone", + 'ipod' => "Apple iPod Touch", + 'sony' => "Sony Ericsson", + 'ericsson' => "Sony Ericsson", + 'blackberry' => "BlackBerry", + 'cocoon' => "O2 Cocoon", + 'blazer' => "Treo", + 'lg' => "LG", + 'amoi' => "Amoi", + 'xda' => "XDA", + 'mda' => "MDA", + 'vario' => "Vario", + 'htc' => "HTC", + 'samsung' => "Samsung", + 'sharp' => "Sharp", + 'sie-' => "Siemens", + 'alcatel' => "Alcatel", + 'benq' => "BenQ", + 'ipaq' => "HP iPaq", + 'mot-' => "Motorola", + 'playstation portable' => "PlayStation Portable", + 'hiptop' => "Danger Hiptop", + 'nec-' => "NEC", + 'panasonic' => "Panasonic", + 'philips' => "Philips", + 'sagem' => "Sagem", + 'sanyo' => "Sanyo", + 'spv' => "SPV", + 'zte' => "ZTE", + 'sendo' => "Sendo", + + // Operating Systems + 'symbian' => "Symbian", + 'SymbianOS' => "SymbianOS", + 'elaine' => "Palm", + 'palm' => "Palm", + 'series60' => "Symbian S60", + 'windows ce' => "Windows CE", + + // Browsers + 'obigo' => "Obigo", + 'netfront' => "Netfront Browser", + 'openwave' => "Openwave Browser", + 'mobilexplorer' => "Mobile Explorer", + 'operamini' => "Opera Mini", + 'opera mini' => "Opera Mini", + + // Other + 'digital paths' => "Digital Paths", + 'avantgo' => "AvantGo", + 'xiino' => "Xiino", + 'novarra' => "Novarra Transcoder", + 'vodafone' => "Vodafone", + 'docomo' => "NTT DoCoMo", + 'o2' => "O2", + + // Fallback + 'mobile' => "Generic Mobile", + 'wireless' => "Generic Mobile", + 'j2me' => "Generic Mobile", + 'midp' => "Generic Mobile", + 'cldc' => "Generic Mobile", + 'up.link' => "Generic Mobile", + 'up.browser' => "Generic Mobile", + 'smartphone' => "Generic Mobile", + 'cellphone' => "Generic Mobile" + ); + +// There are hundreds of bots but these are the most common. +$robots = array( + 'googlebot' => 'Googlebot', + 'msnbot' => 'MSNBot', + 'slurp' => 'Inktomi Slurp', + 'yahoo' => 'Yahoo', + 'askjeeves' => 'AskJeeves', + 'fastcrawler' => 'FastCrawler', + 'infoseek' => 'InfoSeek Robot 1.0', + 'lycos' => 'Lycos' + ); + +/* End of file user_agents.php */ +/* Location: ./system/application/config/user_agents.php */ \ No newline at end of file diff --git a/application/controllers/account.php b/application/controllers/account.php new file mode 100755 index 0000000..bcae238 --- /dev/null +++ b/application/controllers/account.php @@ -0,0 +1,103 @@ +page->set_foot_js_group('js'); + $this->page->set_title('Account'); + } + + // -------------------------------------------------------------------------- + + /** + * Dashboard + */ + public function index() + { + $data = $this->todo->get_user_account_by_id($this->session->userdata('uid')); + $this->page->build('account/status', $data); + } + + // -------------------------------------------------------------------------- + + /** + * Password change form + */ + public function password() + { + //Don't let the guest change the password + if($this->session->userdata('username') == 'guest') + { + $this->todo->redirect_303('account'); + return; + } + + if($this->input->post('pass_sub') == "Change Password") + { + $val = $this->todo->validate_pass(); + if($val === TRUE) + { + $this->todo->update_pass(); + //Redirect to index + $this->todo->redirect_303('task/list'); + } + else + { + $data['err'] = $val; + $this->page->build('account/password', $data); + } + } + else + { + $this->page->build('account/password'); + } + } + + // -------------------------------------------------------------------------- + + /** + * Timezone update + */ + public function update_tz() + { + $timezone = $this->input->post('timezone'); + + $this->db->set('timezone', $timezone) + ->where('id', $this->session->userdata('uid')) + ->update('user'); + + if($this->db->affected_rows() == 1) + { + $this->output->set_output('1'); + } + } + + // -------------------------------------------------------------------------- + + /** + * Number format update + */ + public function update_nf() + { + $num_format = (int)$this->input->post('num_format'); + + $this->db->set('num_format', $num_format) + ->where('id', $this->session->userdata('uid')) + ->update('user'); + + if($this->db->affected_rows() == 1) + { + $this->session->set_userdata('num_format', $num_format); + $this->output->set_output('1'); + } + } +} +// End of controllers/account.php \ No newline at end of file diff --git a/application/controllers/calendar.php b/application/controllers/calendar.php new file mode 100755 index 0000000..8e77ff3 --- /dev/null +++ b/application/controllers/calendar.php @@ -0,0 +1,133 @@ +load->library('calendar'); + $this->load->model('task_model'); + + } + + /** + * Calendar View + */ + public function index() + { + //Output + $this->page->build('task/calendar', $this->get_calendar_data()); + } + + /** + * Get the data for the calendar display + * + * @return mixed + */ + protected function get_calendar_data() + { + //Offset time for custom months + if($this->uri->segment(3) && $this->uri->segment(4)) + { + $year = $this->uri->segment(3); + $month = $this->uri->segment(4); + } + + $_months = array( + 01 => 'January', 02 => 'February', + 03 => 'March', 04 => 'April', + 05 => 'May', 06 => 'June', + 07 => 'July', 08 => 'August', + 09 => 'September', 10 => 'October', + 11 => 'November', 12 => 'December', + 1 => 'January', 2 => 'February', + 3 => 'March', 4 => 'April', + 5 => 'May', 6 => 'June', + 7 => 'July', 8 => 'August', + 9 => 'September', + ); + + $year = (isset($year)) ? $year : date('Y'); + $month = (isset($month)) ? $month : date('m'); + + $local_time = time(); + + $data['month'] = $_months[(int)$month].' '.$year; + $data['calendar'] = array(); + $data['today'] = getdate(); + + $days_in_month = $this->calendar->get_total_days($month, $year); + + // Set the starting day number + $local_date = mktime(0, 0, 0, $month, 1, $year); + $month_end = mktime(0, 0, 0, $month, $days_in_month, $year); + $date = getdate($local_date); + $day = 0 + 1 - $date["wday"]; + + //Get tasks for each day + $content = $this->task_model->get_day_task_list($local_date, $month_end, $days_in_month); + + // Set the current month/year/day + // We use this to determine the "today" date + $cur_year = date("Y", $local_time); + $cur_month = date("m", $local_time); + $cur_day = date("j", $local_time); + + $is_current_month = ($cur_year == $year AND $cur_month == $month); + + $out = null; + + while ($day <= $days_in_month) + { + for ($i = 0; $i < 7; $i++) + { + if($i == 0) + { + $out .= ''; + } + + if ($day > 0 AND $day <= $days_in_month) + { + if (isset($content[$day])) + { + // Cells with content + $out .= ($is_current_month == TRUE AND $day == $cur_day) ? '' : ''; + $out .= '
'.$day.'
'; + } + else + { + // Cells with no content + $out .= ($is_current_month == TRUE AND $day == $cur_day) ? '' : ''; + $out .= '
'.$day.' 
'; + } + } + else + { + // Blank cells + $out .= ' '; + } + + + $day++; + + if($i == 6) + { + $out .= ''; + } + } + + + } + + $data['calendar'] = $out; + + return $data; + } + +} \ No newline at end of file diff --git a/application/controllers/category.php b/application/controllers/category.php new file mode 100755 index 0000000..6b36cef --- /dev/null +++ b/application/controllers/category.php @@ -0,0 +1,86 @@ +page->set_foot_js_group('js'); + $this->page->set_title('Categories'); + + } + + /** + * Redirect to list + */ + public function index() + { + $this->todo->redirect_303(site_url('category/list')); + } + + /** + * List of categories + */ + public function category_list() + { + $data['category'] = $this->todo->get_category_list(); + $this->page->set_title("Category List"); + $this->page->build('task/cat_list', $data); + } + + /** + * Add a category + */ + public function add_sub() + { + if($this->input->post('add_sub') != FALSE) + { + $this->todo->add_category(); + $this->todo->redirect_303(site_url('category/list')); + } + } + + /** + * Category edit form + */ + public function edit($cat_id) + { + $data['cat'] = $this->todo->get_category((int) $cat_id); + $this->page->set_title("Edit Category"); + $this->page->build('task/cat_add', $data); + } + + /** + * Update the category + */ + public function edit_sub() + { + $title = $this->input->post('title', TRUE); + $desc = $this->input->post('desc', TRUE); + $cat_id = (int) $this->input->post('id'); + $group_id = $this->todo->get_user_group(); + + $this->db->set('title', $title) + ->set('description', $desc) + ->where('group_id', $group_id) + ->where('id', $cat_id) + ->update('category'); + + $this->todo->redirect_303('category/list'); + } + + /** + * Delete a category + */ + public function del_sub($cat_id) + { + $this->output->set_output($this->todo->del_cat((int) $cat_id)); + } +} +// End of controllers/category.php \ No newline at end of file diff --git a/application/controllers/friend.php b/application/controllers/friend.php new file mode 100755 index 0000000..bf4eeb3 --- /dev/null +++ b/application/controllers/friend.php @@ -0,0 +1,99 @@ +load->model('friend_model'); + + $this->page->set_title('Friends'); + $this->page->set_foot_js_group('js'); + } + + /** + * Alias for friend list + */ + public function index() + { + $this->friend_list(); + return; + } + + /** + * Get the users's friends + */ + public function friend_list() + { + $data = array(); + $data['friend_list'] = $this->friend_model->get_friends(); + $this->page->set_title('Friends List'); + $this->page->build('friend/list', $data); + } + + /** + * Friend finder form + */ + public function find() + { + $data['results'] = null; + $this->page->set_title('Find Friends'); + $this->page->build('friend/search', $data); + } + + /** + * Send a friend request + */ + public function add_request() + { + $friend_id = (int) $this->input->post('fid'); + $this->output->set_output($this->friend_model->send_request($friend_id)); + } + + /** + * Accept a friend request + */ + public function accept_request() + { + $aid = xss_clean($this->input->post('aid')); + $this->output->set_output($this->friend_model->accept_request($aid)); + } + + /** + * Reject a friend request + */ + public function reject_request() + { + $rid = xss_clean($this->input->post('rid')); + $this->output->set_output($this->friend_model->reject_request($rid)); + } + + /** + * Get list of friend requests + */ + public function requests() + { + $data['request_list'] = $this->friend_model->get_requests(); + $this->page->set_title('Friend Reqests'); + $this->page->build('friend/requests', $data); + } + + /** + * Get results for friend finder + */ + public function ajax_search() + { + $data['results'] = $this->friend_model->find_friends(); + $this->load->view('friend/ajax_search', $data); + } + + +} +// End of controllers/friend.php \ No newline at end of file diff --git a/application/controllers/group.php b/application/controllers/group.php new file mode 100755 index 0000000..5155bdb --- /dev/null +++ b/application/controllers/group.php @@ -0,0 +1,95 @@ +page->set_foot_js_group('js'); + $this->page->set_title('Groups'); + } + + /** + * Redirect to group list + */ + public function index() + { + //303 Redirect + $this->todo->redirect_303('groups/list'); + } + + /** + * List of user's groups + */ + public function group_list() + { + $data['group'] = $this->todo->get_group_list((int) $this->session->userdata('uid')); + $this->page->set_title("Group List"); + $this->page->build('friend/group_list', $data); + } + + /** + * Add a new group + */ + public function add_sub() + { + if($this->input->post('add_sub') != FALSE) + { + $this->todo->add_group(); + + //Redirect to the group list + $this->todo->redirect_303('group/manage'); + } + } + + /** + * Delete a group + */ + public function del_group() + { + $group_id = (int) $this->uri->segment('3'); + $this->output->set_output($this->todo->del_group($group_id)); + } + + /** + * Add/Edit a group + */ + public function manage($group_id = NULL) + { + if(is_null($group_id)) + { + $this->group_list(); + return; + } + + if($this->input->post('friends')) + { + $this->todo->update_group(); + } + + $group_id = (int) $group_id; + + $friends_array = array(); + $array = $this->todo->get_friends_in_group($group_id); + + foreach($array as $a) + { + $friends_array[] = $a['user_id']; + } + + $data['group_name'] = $this->todo->get_group_name_by_id($group_id); + $data['friends'] = $this->todo->get_friend_list(); + $data['selected_friends'] = $friends_array; + $data['group_perms'] = array(); + + $this->page->set_title("Manage Group"); + $this->page->build('friend/manage', $data); + } +} +// End of controllers/group.php \ No newline at end of file diff --git a/application/controllers/login.php b/application/controllers/login.php new file mode 100755 index 0000000..f7f8839 --- /dev/null +++ b/application/controllers/login.php @@ -0,0 +1,114 @@ +page->set_meta(array('name' =>'google-site-verification', 'content' => 'yuoqLwe6b0rP9DhTbOjuQVPRFl7RY2swO6blPPJWdMQ')); + $this->page->set_meta(array('name' => 'description', 'content' => 'Free online social task manager')); + } + + // -------------------------------------------------------------------------- + + /** + * Alias of 'do_login' + */ + public function index() + { + if($this->session->userdata('uid') === FALSE) + { + $this->do_login(); + return; + } + + $this->todo->redirect_303('task/list'); + } + + // -------------------------------------------------------------------------- + + /** + * Default method of application + */ + public function do_login() + { + $data['err'] = array(); + + if($this->input->post('login_sub') != FALSE) + { + $res = $this->todo->verify_user(); + + if($res === TRUE) + { + //Redirect to the tasklist or page at before login + $login_referer = $this->session->userdata('login_referer'); + $url = ($login_referer !== FALSE) ? $login_referer : 'task/list'; + + //Unset this for now + $this->session->unset_userdata('login_referer'); + $this->todo->redirect_303($url); + } + else + { + $data['err'][] = $res; + } + } + $this->page->set_body_id('home'); + $this->page->build('login/login', $data); + } + + // -------------------------------------------------------------------------- + + /** + * Registration form and submission + */ + public function register() + { + $data = array(); + if ($this->input->post('reg_sub') !== FALSE) + { + if($this->form_validation->run('login/register') === TRUE) + { + $res = $this->todo->add_reg(); + + if ($res == 1) + { + //Redirect to index + $this->todo->redirect_303('login'); + } + show_error("Error saving registration"); + } + else + { + $data['err'] = $this->form_validation->get_error_array(); + $this->page->build('login/register', $data); + } + } + else + { + $data['err']=''; + $this->page->build('login/register', $data); + } + } + + // -------------------------------------------------------------------------- + + /** + * Logout action + */ + public function logout() + { + //Destroy Session + $this->session->sess_destroy(); + + //Redirect to index + $this->todo->redirect_303('login'); + } +} +// End of controllers/login.php \ No newline at end of file diff --git a/application/controllers/reminder.php b/application/controllers/reminder.php new file mode 100755 index 0000000..437d926 --- /dev/null +++ b/application/controllers/reminder.php @@ -0,0 +1,40 @@ +load->library('email'); + $this->load->model('mail_model'); + + } + + /** + * Redirect for snoops + */ + public function index() + { + //303 Redirect + $this->todo->redirect_303('task/list'); + } + + /** + * Check the database for reminder status + */ + public function check_reminder() + { + if(!defined('CRON')) + $this->todo->redirect_303('task/list'); + + //Do all the fun stuff + $this->output->set_output($this->mail_model->check_db()); + } +} +// End of controllers/reminder.php \ No newline at end of file diff --git a/application/controllers/task.php b/application/controllers/task.php new file mode 100755 index 0000000..96d6722 --- /dev/null +++ b/application/controllers/task.php @@ -0,0 +1,349 @@ +load->model('task_model'); + $this->load->library('pagination'); + $this->page->set_title('Tasks'); + $this->page->set_foot_js_group('js'); + } + + // -------------------------------------------------------------------------- + + /** + * Redirect to task list + */ + public function index() + { + $this->todo->redirect_303('task/list'); + } + + // -------------------------------------------------------------------------- + + /** + * List shared tasks + */ + public function shared() + { + $this->page->set_title("Shared Tasks"); + $tasks = $this->task_model->get_shared_task_list(); + $data['task_list'] = $tasks; + $data['list_type'] = "shared"; + + $this->page->build('task/list', $data); + } + + // -------------------------------------------------------------------------- + + /** + * Get the main task view + */ + public function list_tasks() + { + $this->page->set_title("View Tasks"); + $tasks = $this->task_model->get_task_list(); + $data['task_list'] = $tasks; + $data['list_type'] = 'active'; + + $this->page->build('task/list', $data); + } + + // -------------------------------------------------------------------------- + + /** + * List archived tasks + */ + public function archive($page = 1) + { + $per_page = 10; + $this->page->set_title("Archived Tasks"); + $page = (int) $page; + $tasks = $this->task_model->get_archived_task_list($page, $per_page); + + // Pagination preferences + $config = [ + 'base_url' => 'https://todo.timshomepage.net/task/archive/', + 'total_rows' => $tasks['num_rows'], + 'per_page' => $per_page, + 'uri_segment' => 3, + 'num_links' => 3, + 'full_tag_open' => '

', + 'full_tag_close' => '

', + 'cur_tag_open' => '', + 'cur_tag_close' => '' + ]; + + $this->pagination->initialize($config); + + $data['task_list'] = $tasks; + $data['list_type'] = 'archived'; + $data['pagination'] = $this->pagination->create_links(); + + $this->page->build('task/list', $data); + } + + // -------------------------------------------------------------------------- + + /** + * List overdue tasks + */ + public function overdue() + { + $this->page->set_title("Overdue Tasks"); + $tasks = $this->task_model->get_overdue_task_list(); + $data['task_list'] = $tasks; + $data['list_type'] = 'overdue'; + + $this->page->build('task/list', $data); + } + + // -------------------------------------------------------------------------- + + /** + * Add a task + */ + public function add() + { + $data = array(); + $data['err'] = ''; + $data['cat_list'] = $this->todo->get_category_select(); + $data['pri_list'] = $this->todo->get_priority_select(); + $data['group_perms'] = ''; + $data['groups'] = $this->todo->get_group_list($this->session->userdata('uid')); + $data['task_title'] = ''; + $data['description'] = ''; + $data['due'] = mktime(12, 00, 00); + $data['title'] = ''; + $data['rem_hours'] = 0; + $data['rem_minutes'] = 30; + $data['reminder'] = FALSE; + $data['friends'] = $this->todo->get_friend_list(); + + + if ($this->input->post('add_sub') == 'Add Task') + { + $val = $this->task_model->validate_task(); + + if($val === TRUE) + { + $done = $this->task_model->add_task(); + + if ($done === TRUE) + { + //Redirect to task list + $this->todo->redirect_303('task/list'); + } + else + { + $data['err'][] = "Database Error, Please try again later."; + } + } + else + { + //Get form values + $data = array_merge($data, $this->task_model->form_vals); + $data['err'] = $val; + + } + + } + + $this->page->set_title("Add Task"); + $this->page->build('task/add', $data); + } + + // -------------------------------------------------------------------------- + + /** + * Edit a task + * + * @param int $task_id + */ + public function edit($task_id) + { + $task_id = (int) $task_id; + $data = $this->task_model->get_task_by_id($task_id); + $data['cat_list'] = $this->task_model->get_category_select($task_id); + $data['pri_list'] = $this->task_model->get_priority_select($task_id); + $data['stat_list'] = $this->task_model->get_status_select($task_id); + $data['comments'] = $this->task_model->get_task_comments($task_id); + $data['groups'] = $this->todo->get_group_list($this->session->userdata('uid')); + $data['friends'] = $this->todo->get_friend_list(); + $data['checklist'] = $this->task_model->get_checklist($task_id); + + if ($this->input->post('edit_sub') == 'Update Task') + { + $val = $this->task_model->validate_task(); + + if($val === TRUE) + { + $done = $this->task_model->update_task(); + + if ($done === TRUE) + { + //Redirect to task list + $this->session->set_flashdata([ + 'message_type' => 'success', + 'message' => 'Task was updated successfully.' + ]); + + $this->todo->redirect_303(site_url('task/list')); + } + else + { + $data['err'][] = "Database Error, Please try again later."; + } + } + else + { + $data['err'] = $val; + } + + } + + $this->page->set_title("Edit Task"); + $this->page->build('task/edit', $data); + } + + // -------------------------------------------------------------------------- + + /** + * View an individual task + * + * @param int $task_id + */ + public function view($task_id = NULL) + { + if( ! is_numeric($task_id)) + { + show_404(); + return; + } + + $task_id = (int)$task_id; + $data = $this->task_model->get_task_by_id($task_id); + $data['comments'] = $this->task_model->get_task_comments($task_id); + $data['status_id'] = $this->task_model->get_current_status_id($task_id); + $data['status'] = $this->task_model->get_status_select($task_id, $data['status_id']); + $data['category'] = $this->task_model->get_category_select($task_id); + $data['checklist'] = $this->task_model->get_checklist($task_id); + $data['task'] = $task_id; + + + $this->page->set_title("View Task"); + $this->page->set_body_id("task_details"); + $this->page->build('task/view', $data); + } + + // -------------------------------------------------------------------------- + + /** + * Delete a task + */ + public function delete($task_id) + { + $this->task_model->delete_task((int) $task_id); + } + + // -------------------------------------------------------------------------- + + /** + * Add a task comment + */ + public function add_task_comment() + { + $res = $this->task_model->add_task_comment($this->input->post('task_id')); + $this->output->set_output($res); + } + + // -------------------------------------------------------------------------- + + /** + * Get a list of comments for the task + */ + public function get_task_comments() + { + $task_id = $this->input->get('task_id'); + $data['comments'] = $this->task_model->get_task_comments($task_id); + $this->load->view('task/comments_view', $data); + } + + // -------------------------------------------------------------------------- + + /** + * Delete a task comment + */ + public function del_task_comment() + { + $cid = (int) $this->input->post('comment_id'); + $this->output->set_output($this->task_model->delete_comment($cid)); + } + + // -------------------------------------------------------------------------- + + /** + * Update the status of a task + */ + public function update_status() + { + $output = $this->task_model->update_status(); + $this->output->set_output($output); + } + + // -------------------------------------------------------------------------- + + /** + * Update the category that the task belongs to. + */ + public function update_category() + { + $output = $this->task_model->quick_update_category(); + $this->output->set_output($output); + } + + // -------------------------------------------------------------------------- + + /** + * Add a checklist item to the task + */ + public function add_checklist_item() + { + $data = $this->task_model->add_checklist_item(); + + if($data == FALSE) + { + $this->output->set_output(0); + } + else if(is_array($data)) + { + $this->load->view('task/ajax_checklist', $data); + } + else + { + $this->output->set_output(-1); + } + } + + // -------------------------------------------------------------------------- + + /** + * Update a task checklist item + */ + public function update_checklist_item() + { + $check_id = $this->input->post('check_id'); + $checked = $this->input->post('checked'); + + $this->output->set_output($this->task_model->update_checklist($check_id, $checked)); + } +} +// End of controllers/task.php \ No newline at end of file diff --git a/application/core/MY_Controller.php b/application/core/MY_Controller.php new file mode 100755 index 0000000..4d86930 --- /dev/null +++ b/application/core/MY_Controller.php @@ -0,0 +1,36 @@ +validation_callbacks, $rule_name)) + { + return $this->validation_callbacks->$rule_name($str); + } + + throw new InvalidArgumentException("Validation callback '{$rule_name}' does not exist"); + } +} +// End of core/MY_Controller.php \ No newline at end of file diff --git a/application/errors/error_404.php b/application/errors/error_404.php new file mode 100755 index 0000000..1073fc1 --- /dev/null +++ b/application/errors/error_404.php @@ -0,0 +1,3 @@ + + + +Database Error + + + +
+
+ Tim's ToDo +
Tim's Todo
+
+
+
+ +

+


+ Go back' : '' ?>

+
+ + \ No newline at end of file diff --git a/application/errors/error_general.php b/application/errors/error_general.php new file mode 100755 index 0000000..ed874b6 --- /dev/null +++ b/application/errors/error_general.php @@ -0,0 +1,61 @@ + + + +Error + + + +
+
+ Tim's ToDo +
Tim's Todo
+
+
+
+ +

+


+ Go back' : '' ?>

+
+ + \ No newline at end of file diff --git a/application/errors/error_php.php b/application/errors/error_php.php new file mode 100755 index 0000000..9d6cfb3 --- /dev/null +++ b/application/errors/error_php.php @@ -0,0 +1,10 @@ +
+ +

A PHP Error was encountered

+ +

Severity:

+

Message:

+

Filename:

+

Line Number:

+ +
\ No newline at end of file diff --git a/application/hooks/pre-controller.php b/application/hooks/pre-controller.php new file mode 100755 index 0000000..79ee26e --- /dev/null +++ b/application/hooks/pre-controller.php @@ -0,0 +1,32 @@ +session->userdata('uid') == FALSE) + { + $referer = $CI->uri->uri_string(); + + $white_list = [ + 'login', + 'login/register', + 'register', + 'reminder/check_reminder', + ]; + + if ( ! in_array($referer, $white_list)) + { + //Redirect to login + $CI->session->set_userdata('login_referer', $referer); + $CI->todo->redirect_303('login'); + } + } +} \ No newline at end of file diff --git a/application/language/english/index.html b/application/language/english/index.html new file mode 100755 index 0000000..c942a79 --- /dev/null +++ b/application/language/english/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + \ No newline at end of file diff --git a/application/libraries/MY_Form_validation.php b/application/libraries/MY_Form_validation.php new file mode 100644 index 0000000..74a8c5b --- /dev/null +++ b/application/libraries/MY_Form_validation.php @@ -0,0 +1,34 @@ +_error_array); + } + + /** + * Clears out object data + * + * @return void + */ + public function reset() + { + foreach([ + '_field_data', + '_error_array', + '_error_messages' + ] as $var) { + $this->$var = array(); + } + } +} +// End of libraries/MY_Form_validation.php \ No newline at end of file diff --git a/application/libraries/MY_Session.php b/application/libraries/MY_Session.php new file mode 100755 index 0000000..25f98a9 --- /dev/null +++ b/application/libraries/MY_Session.php @@ -0,0 +1,81 @@ +sess_destroy(); + return FALSE; + } + + return TRUE; + } + + /** + * Fetch/validate the current session data + * + * @return bool + */ + public function sess_read() + { + return ($this->session_valid()) ? parent::sess_read() : FALSE; + } + + /** + * Validate the session before creation + */ + public function sess_create() + { + return ($this->session_valid()) ? parent::sess_create() : FALSE; + } + + /** + * Serialize the session data to JSON + * + * @param array $data + * @return string + */ + public function _serialize($data) + { + return json_encode($data); + } + + /** + * Unserialize the session data + * + * @param string $data + * @return mixed + */ + public function _unserialize($data) + { + return json_decode($data, TRUE); + } +} +/* End of file MY_Session.php */ +/* Location: ./application/libraries/MY_Session.php */ \ No newline at end of file diff --git a/application/libraries/Page.php b/application/libraries/Page.php new file mode 100755 index 0000000..b1b85e3 --- /dev/null +++ b/application/libraries/Page.php @@ -0,0 +1,297 @@ + + * + * All methods are chainable, with the exception of the constructor, + * build_header(), build_footer(), and _headers() methods. + */ +class Page { + + private static $meta, $head_js, $foot_js, $css, $title, + $head_tags, $body_id; + + /** + * Current Controller Instance + * + * @var CI_Controller + */ + private $CI; + + /** + * Constructor + */ + public function __construct() + { + $this->meta = ""; + $this->head_js = ""; + $this->foot_js = ""; + $this->css = ""; + $this->title = ""; + $this->head_tags = ""; + $this->body_id = ""; + $this->CI =& get_instance(); + } + + // -------------------------------------------------------------------------- + + /** + * Sets server headers and doctype + * + * Also sets page mime type, based on if sent as + * html or xhtml, and what the target browser + * supports + * + * @return Page + */ + private function _headers() + { + $this->CI->output->set_header("Cache-Control: must-revalidate, public"); + $this->CI->output->set_header("Vary: Accept"); + + //Predefine charset and mime + $charset = "UTF-8"; + $mime = "text/html"; + + $doctype_string = doctype('html5') . "\n"; + + // finally, output the mime type and prolog type + $this->CI->output->set_header("Content-Type: $mime;charset=$charset"); + $this->CI->output->set_header("X-UA-Compatible: chrome=1"); + $this->CI->output->set_output($doctype_string); + + return $this; + } + + // -------------------------------------------------------------------------- + + /** + * Set Meta + * + * Sets meta tags, with codeigniter native meta tag helper + * + * @param array $meta + * @return Page + */ + public function set_meta($meta) + { + $this->meta .= T1.meta($meta).NL; + return $this; + } + + // -------------------------------------------------------------------------- + + /** + * Sets minified javascript group in header + * @param string $group + * @param bool $debug + * @return Page + */ + public function set_head_js_group($group, $debug=FALSE) + { + $file = $this->CI->config->item('group_style_path') . $group; + $file .= ($debug == TRUE) ? "/debug/1" : ""; + $this->head_js .= $this->script_tag($file, FALSE); + return $this; + } + + // -------------------------------------------------------------------------- + + /** + * Sets a minified css group + * @param string $group + * @return Page + */ + public function set_css_group($group) + { + $link = array( + 'href' => $this->CI->config->item('group_style_path') . $group, + 'rel' => 'stylesheet', + 'type' => 'text/css', + ); + $this->css .= T1.link_tag($link).NL; + + return $this; + } + + // -------------------------------------------------------------------------- + + /** + * Sets a minified javascript group for the page footer + * @param string $group + * @return Page + */ + public function set_foot_js_group($group, $debug=FALSE) + { + $file = $this->CI->config->item('group_style_path') . $group; + $file .= ($debug == TRUE) ? "/debug/1" : ""; + $this->foot_js .= $this->script_tag($file, FALSE); + return $this; + } + + // -------------------------------------------------------------------------- + + /** + * Sets html title string + * @param string $title + * @return Page + */ + public function set_title($title="") + { + $title = ($title == "") ? + $this->CI->config->item('default_title') : $title; + + $this->title = $title; + + return $this; + } + + // -------------------------------------------------------------------------- + + /** + * Sets custom body id + * @param string $id + * @return Page + */ + public function set_body_id($page_id="") + { + $this->body_id = $page_id; + return $this; + } + + // -------------------------------------------------------------------------- + + /** + * Sets custom page header + * @return $this + */ + public function build_header() + { + $data = array(); + + //Set Meta Tags + $this->meta = T1.''.NL. $this->meta; + $data['meta'] = $this->meta; + + //Set CSS + if ($this->css != "") + { + $data['css'] = $this->css; + } + else + { + //Set default CSS group + $this->set_css_group($this->CI->config->item('default_css_group')); + $data['css'] = $this->css; + } + + //Set head javascript + $data['head_js'] = ( ! empty($this->head_js)) ? $this->head_js : ""; + + //Set Page Title + $data['title'] = ( ! empty($this->title)) ? $this->title : $this->CI->config->item('default_title'); + + //Set Body Id + $data['body_id'] = $this->body_id; + + //Set Server Headers and Doctype + $this->_headers(); + + //Output Header + $this->CI->load->view('header', $data); + + return $this; + } + + // -------------------------------------------------------------------------- + + /** + * Shortcut method to cut down on boilerplate + * + * @param string $view + * @param array|object $data + * @return void + */ + public function build($view, $data = array()) + { + $this->build_header(); + $this->CI->load->view($view, $data); + $this->build_footer(); + } + + // -------------------------------------------------------------------------- + + /** + * Builds common footer with any additional js + */ + public function build_footer() + { + $data = array(); + + $data['foot_js'] = ($this->foot_js != "") ? + $this->foot_js : ''; + + $this->CI->load->view('footer', $data); + } + + // -------------------------------------------------------------------------- + + /** + * Script Tag + * + * Helper function for making script tags + * + * @param string $js + * @param bool $domain + * @return string + */ + private function script_tag($javascript, $domain=TRUE) + { + $path = $this->CI->config->item('content_domain'); + $js_file = $path . "/js/" . $javascript . ".js"; + + if ($domain == FALSE) + $js_file = $javascript; + + $tag = ''.NL; + + return $tag; + } + + // -------------------------------------------------------------------------- + + /** + * Num Queries + * + * Returns number of queries run on a page + * + * @return int + */ + public function num_queries() + { + return (isset($this->CI->db)) ? count($this->CI->db->queries) : 0; + } + + // -------------------------------------------------------------------------- + + /** + * Set Message + * + * Adds a message to the page + * @param string $type + * @param string $message + * @param bool $return + * @return mixed + */ + public function set_message($type, $message, $return = FALSE) + { + $data['stat_type'] = $type; + $data['message'] = $message; + + return $this->CI->load->view('message', $data, $return); + } +} + + diff --git a/application/libraries/Todo.php b/application/libraries/Todo.php new file mode 100755 index 0000000..2d33dab --- /dev/null +++ b/application/libraries/Todo.php @@ -0,0 +1,843 @@ +CI =& get_instance(); + } + + // -------------------------------------------------------------------------- + + /** + * Get User From Id + * + * Retrieve a user's username from their userid + * @param int $user_id + * @return string + */ + public function get_user_from_id($user_id) + { + $this->CI->db->select('id, username') + ->from('todo_user') + ->where('id', (int) $user_id); + + $res = $this->CI->db->get(); + $row = $res->row(); + return $row->username; + } + + // -------------------------------------------------------------------------- + + /** + * Crypt Pass + * + * Hashes passwords + * @param string $password + * @return string + */ + public function crypt_pass($password) + { + return password_hash($password, PASSWORD_BCRYPT); + } + + // -------------------------------------------------------------------------- + + /** + * Add Reg + * + * Submits a new user to the database + * @return integer + */ + public function add_reg() + { + $user = $this->CI->input->post('user', TRUE); + $pass = $this->crypt_pass($this->CI->input->post('pass', TRUE)); + $email = $this->CI->input->post('email', TRUE); + + $this->CI->db->set('username', $user) + ->set('password', $pass) + ->set('email', $email); + $this->CI->db->insert('user'); + + //Get affected rows + $affected_rows = $this->CI->db->affected_rows(); + + //Get the userid of the latest user + $res = $this->CI->db->select('MAX(id) as id') + ->from('user') + ->get(); + + $row = $res->row(); + $this->uid = $row->id; + + //Add a group with the same name as the user + $this->CI->db->set('name', $user) + ->insert('group'); + + //Get the groupid of the latest group + $res2 = $this->CI->db->select('MAX(id) as id') + ->from('group') + ->get(); + + $row = $res2->row(); + $g_id = $row->id; + + //Set that user as the admin of that group + $this->CI->db->set('group_id', $g_id) + ->set('user_id', $this->uid) + ->set('is_admin', 1) + ->insert('group_users_link'); + + //Return affected rows + return $affected_rows; + } + + // -------------------------------------------------------------------------- + + /** + * Get Categories + * + * Retrieves list of category types from the database + * @return array + */ + public function get_category_list() + { + $user_group_id = $this->get_user_group(); + $cat = $this->CI->db->select('id,title,description,group_id') + ->from('category') + ->where('group_id', $user_group_id) + ->or_where('group_id', 0) + ->order_by('group_id', 'desc') + ->order_by('title', 'asc') + ->get(); + + return $cat->result_array(); + } + + // -------------------------------------------------------------------------- + + /** + * Get Group List + * + * An alias for the private get_groups method + * @param int + * @return array + */ + public function get_group_list($user_id) + { + return $this->get_groups($user_id); + } + + // -------------------------------------------------------------------------- + + /** + * Add Category + * + * Submits a new category to the database + * @return bool + */ + public function add_category() + { + if($this->CI->input->post('title') == FALSE || $this->CI->input->post('desc') == FALSE) + { + show_error('You must put a title and description!'); + return false; + } + + $title = $this->CI->input->post('title', TRUE); + $desc = $this->CI->input->post('desc', TRUE); + + //Check for the current category + $this->CI->db->select('title') + ->from('category') + ->where('title', $title); + + $res = $this->CI->db->get(); + + if($res->num_rows() == 0) + { + //Get the current user's primary group + $group_id = $this->get_user_group(); + + //print_r($group_id); + + $this->CI->db->set('title', $title) + ->set('description', $desc) + ->set('group_id', $group_id); + + //Insert the new record + $this->CI->db->insert('category'); + $this->CI->session->flashdata('message', 'Successfully added new category.'); + return true; + } + else + { + show_error('This category already exists!'); + return false; + } + + + } + + // -------------------------------------------------------------------------- + + /** + * Add Group + * + * Submits a new group to the database + * @return bool + */ + public function add_group() + { + if($this->CI->input->post('name') == FALSE) + { + show_error('You must have a name for your new group!'); + return false; + } + + $name = $this->CI->input->post('name'); + + //Add group + $this->CI->db->set("name", $name)->insert('group'); + + //Get the groupid of the latest group + $res = $this->CI->db->select('MAX(id) as id') + ->from('group') + ->get(); + + $row = $res->row(); + $g_id = $row->id; + + //Set that user as the admin of that group + $this->CI->db->set('group_id', $g_id) + ->set('user_id', $this->CI->session->userdata('uid')) + ->set('is_admin', 1) + ->insert('group_users_link'); + + } + + // -------------------------------------------------------------------------- + + /** + * Get Category Select + * + * Generates select options for categories when adding a new task + * @return string + */ + public function get_category_select() + { + $select_array = $this->get_category_list(); + $html = ''; + + foreach($select_array as $r) + { + $html .= T4.''. "\n"; + } + + return $html; + } + + // -------------------------------------------------------------------------- + + /** + * Get Priority Select + * + * Generates select options for priorities when adding a new task + * @return string + */ + public function get_priority_select() + { + $select_array = $this->get_priorities(); + $html = ''; + + foreach($select_array as $r) + { + $html .= T4.''. "\n"; + } + + return $html; + } + + // -------------------------------------------------------------------------- + + /** + * Get Group Select + * + * Generates select options for groups when adding a friend + * @param int $user_id + * @return string + */ + public function get_group_select($user_id) + { + $select_array = $this->get_groups($user_id); + $html = ''; + + foreach($select_array as $r) + { + $html .= T4.''. "\n"; + } + + return $html; + } + + // -------------------------------------------------------------------------- + + /** + * Validate Pass + * + * Validate Password Change + * @return mixed + */ + public function validate_pass() + { + $err = array(); + $user = $this->CI->session->userdata('uid'); + $pass = $this->CI->input->post('pass'); + $pass1 = $this->CI->input->post('pass1'); + $old_pass = $this->CI->input->post('old_pass'); + + if($pass != $pass1) + $err[] = "Passwords do not match."; + + //Check for current password in the database + $user_check = $this->CI->db->select('password') + ->from('user') + ->get(); + + $row = $user_check->row(); + + if ( ! password_verify($old_pass, $row->password)) + { + $err[] = "Wrong password"; + } + + $res = (empty($err)) ? true : $err; + + if($res == TRUE) + { + $this->user = $user; + $this->pass = $pass; + } + + return $res; + } + + // -------------------------------------------------------------------------- + + /** + * Update Pass + * + * Updates user's password in the database + */ + public function update_pass() + { + $pass = $this->crypt_pass($this->pass); + $this->CI->db->set('password', $pass) + ->where('id', $this->user) + ->update('user'); + } + + // -------------------------------------------------------------------------- + + /** + * Redirect 303 + * + * Shortcut function for 303 redirect + * @param string $url + */ + public function redirect_303($url) + { + if (stripos($url, 'http') === FALSE) + { + $url = site_url($url); + } + + $this->CI->output->set_header("HTTP/1.1 303 See Other"); + $this->CI->output->set_header("Location:" . $url); + } + + // -------------------------------------------------------------------------- + + /** + * Set Timezone + * + * Sets the timezone based on the user's settings + * @param int $uid + * @param string $timezone + * @return bool + */ + public function set_timezone($uid, $timezone) + { + $this->db->set('timezone', $timezone) + ->where('id', $uid) + ->update('user'); + + return ($this->db->affected_rows == 1); + } + + // -------------------------------------------------------------------------- + + /** + * Get Priorities + * + * Retreives list of priority types from the database + * @return array + */ + public function get_priorities() + { + $pri = $this->CI->db->select('id,value') + ->from('priority') + ->order_by('id', 'asc') + ->get(); + + return $pri->result_array(); + } + + // -------------------------------------------------------------------------- + + /** + * Get Groups + * + * Retrieves user's groups from db + * @param int $user_id + * @return array + */ + private function get_groups($user_id) + { + $username = $this->get_user_from_id($user_id); + $groups = $this->CI->db->select("group.id, name") + ->from('group') + ->join('group_users_link', 'group.id = group_users_link.group_id', 'inner') + ->where('user_id', $user_id) + ->where('name !=', $username) + ->where('is_admin', 1) + ->get(); + + return $groups->result_array(); + } + + // -------------------------------------------------------------------------- + + /** + * Get User Account By Id + * + * Retrieves user's account info from db + * @param int $user_id + * @return array + */ + public function get_user_account_by_id($user_id) + { + $user_account = array(); + + //Get the user + $user_query = $this->CI->db->from('user') + ->where('id', (int) $user_id) + ->get(); + + $user = $user_query->row(); + + $user_account['timezone'] = $user->timezone; + $user_account['user'] = $user->username; + $user_account['email'] = $user->email; + $user_account['num_format'] = $user->num_format; + + return $user_account; + } + + // -------------------------------------------------------------------------- + + /** + * Get User Group + * + * Gets the current user's primary group + * @return int + */ + public function get_user_group() + { + $user_id = $this->CI->session->userdata('uid'); + + //Get the username + $uname = $this->get_user_from_id($user_id); + + $group_query = $this->CI->db->select('group.id as group_id') + ->from('group') + ->where('name', $uname) + ->limit(1) + ->get(); + + $group = $group_query->row(); + $group_id = $group->group_id; + + return $group_id; + } + + // -------------------------------------------------------------------------- + + /** + * Get Friend List + * + * Gets the friends of the current user + * @return array + */ + public function get_friend_list() + { + $user_id = $this->CI->session->userdata('uid'); + + //Get the current user's username + $uname = $this->CI->db->select('username') + ->from('user') + ->where('id', $user_id) + ->get(); + + $user_n = $uname->row(); + + $username = $user_n->username; + + //Get the list of friends + $friends = $this->CI->db + ->select('user_friend_id,user_friend_link.user_id as uid,user.username') + ->from('todo_user_friend_link') + ->join('user', 'user.id=user_friend_link.user_friend_id OR "todo_user"."id"="todo_user_friend_link"."user_id"', 'inner') + ->where('confirmed', FRIEND_CONFIRMED) + ->where('username !=', $username) + + ->group_start() + ->where_in('todo_user_friend_link.user_id', $user_id) + ->or_where_in('todo_user_friend_link.user_friend_id', $user_id) + ->group_end() + + ->order_by('username', 'asc') + ->get(); + + return $friends->result_array(); + + } + + // -------------------------------------------------------------------------- + + /** + * Get Friends in Group + * + * Returns members of a group + * @param int $group_id + * @return array + */ + public function get_friends_in_group($group_id) + { + $friends = $this->CI->db + ->select('user_id') + ->from('group_users_link') + ->where('group_id', $group_id) + ->get(); + + return $friends->result_array(); + } + + // -------------------------------------------------------------------------- + + /** + * Update group + * + * Updates a group's membership + */ + public function update_group() + { + $friends = $this->CI->input->post('friends'); + $group_name = $this->CI->input->post('group_name'); + $group_id = (int)$this->CI->uri->segment('3'); + + //Drop members in group except the creator + $this->CI->db->where('group_id', $group_id) + ->where('is_admin', 0) + ->delete('group_users_link'); + + //Update the group name + $this->CI->db->set('name', $group_name) + ->where('id', $group_id) + ->update('group'); + + foreach ($friends as $friend) + { + //Insert new friends + $this->CI->db->set('group_id', $group_id) + ->set('user_id', (int) $friend) + ->set('is_admin', 0) + ->insert('group_users_link'); + } + + return 1; + } + + // -------------------------------------------------------------------------- + + /** + * Del group + * + * Deletes a friend group + * @param int $group_id + * @return int + */ + public function del_group($group_id) + { + //Check if the current user is group admin + $is_admin = $this->CI->db->from('group_users_link') + ->where('group_id', $group_id) + ->where('is_admin', 1) + ->get(); + + //The user is admin + if($is_admin->num_rows() > 0) + { + //Delete the related records + $this->CI->db->where('group_id', $group_id) + ->delete('group_users_link'); + $this->CI->db->where('group_id', $group_id) + ->delete('group_task_link'); + + //Delete the group + $this->CI->db->where('id', $group_id) + ->delete('group'); + + return 1; + } + else + { + return -1; + } + } + + // -------------------------------------------------------------------------- + + /** + * Del Cat + * + * Deletes a task category + * @param int $cat_id + * @return int + */ + public function del_cat($cat_id) + { + //Get the user group id + $gid = $this->get_user_group(); + + //Delete the category that matches the cat_id and gid + $this->CI->db->where('group_id', $gid) + ->where('id', $cat_id) + ->delete('category'); + + if($this->CI->db->affected_rows() > 0) + { + return $this->CI->db->affected_rows(); + } + else + { + return -1; + } + } + + // -------------------------------------------------------------------------- + + /** + * Get group name by id + * + * Gets a group name from the group id + * @param int $group_id + * @return string + */ + public function get_group_name_by_id($group_id) + { + $query = $this->CI->db->select('name') + ->from('group') + ->where('id', $group_id) + ->get(); + + $qrow = $query->row(); + + $name = $qrow->name; + + return $name; + } + + + // -------------------------------------------------------------------------- + + /** + * Kanji Num + * + * Converts arabic to chinese number + * @param int $number + * @return string + */ + public function kanji_num($orig_number) + { + $kanji_num = ''; + $number = (int) $orig_number; + + // Return early on a zero + if ($number === 0) return ZERO; + + // Map variables to their values and characters + $meta_map = [ + 100000000 => HUNDRED_MILLION, + 10000 => TEN_THOUSAND, + 1000 => THOUSAND, + 100 => HUNDRED, + 10 => TEN + ]; + + // Map values to their kanji equivalent + $char_map = [ + 1 => ONE, + 2 => TWO, + 3 => THREE, + 4 => FOUR, + 5 => FIVE, + 6 => SIX, + 7 => SEVEN, + 8 => EIGHT, + 9 => NINE, + ]; + + // Go through each place value + // to get the kanji equivalent of + foreach($meta_map as $value => $char) + { + if ($number < $value) continue; + + // Calculate the place value variable + $place_value = floor($number / $value); + + // Get the remainder for the next place value; + $number = $number - ($place_value * $value); + + // Recurse if the number is between 11,000 + // and 100,000,000 to get the proper prefix, + // which can be up to 9,999 + if ($orig_number > 10000 && $place_value > 9) + { + $kanji_num .= $this->kanji_num($place_value); + $place_value = 1; + } + + // Add place value character and + // place value to the output string, + // skipping zero and one. A zero value + // hides the place value character, and one + // value is implied if there is no value + // prefixing the place value character + $kanji_num .= ($place_value > 1) + ? $char_map[$place_value] . $char + : $char; + } + + // Add the smallest place value last, as a + // one value is significant here + $kanji_num .= ($number > 0) ? $char_map[$number] : ''; + + return $kanji_num; + } + + // -------------------------------------------------------------------------- + + /** + * Get Category + * + * Returns a category from id + * @param int $cat_id + * @return array + */ + public function get_category($cat_id) + { + $cats = $this->CI->db->select('title, description') + ->from('category') + ->where('id', $cat_id) + ->limit('1') + ->get(); + + $cat = $cats->row_array(); + + return $cat; + } + + // -------------------------------------------------------------------------- + + /** + * Get Friend Requests + * + * Retrieves number of friend requests for the current user + * @return int + */ + public function get_friend_requests() + { + static $requests = NULL; + + if (is_null($requests)) + { + //Get friend requests for the current user + $requests = $this->CI->db->select('user_id') + ->distinct() + ->from('user_friend_link') + ->where('user_friend_id', $this->CI->session->userdata('uid')) + ->where('confirmed', -1) + ->get() + ->num_rows(); + } + + return $requests; + } + + /** + * Authenticate the user + * + * @return string + */ + public function verify_user() + { + $user = $this->CI->input->post('user'); + $pass = $this->CI->input->post('pass'); + + //Check for the user in the database + $uid_check = $this->CI->db->select('id, username, email, password, timezone, num_format') + ->from('user') + ->group_start() + ->where('email', $user) + ->or_where('username', $user) + ->group_end() + ->get(); + + $row = $uid_check->row(); + + if (password_verify($pass, $row->password)) + { + $this->CI->session->set_userdata('uid', $row->id); + $this->CI->session->set_userdata('num_format', $row->num_format); + $this->CI->session->set_userdata('username', $row->username); + //Set Timezone + $zone = $row->timezone; + $tz_set = date_default_timezone_set($zone); + + if($tz_set == FALSE) display_error('Could not set timezone'); + + //Redirect to task list + return TRUE; + } + else + { + return "Invalid username or password"; + } + } +} +// End of libraries/Todo.php \ No newline at end of file diff --git a/application/libraries/Validation_callbacks.php b/application/libraries/Validation_callbacks.php new file mode 100755 index 0000000..33a40eb --- /dev/null +++ b/application/libraries/Validation_callbacks.php @@ -0,0 +1,61 @@ +CI =& get_instance(); + } + + /** + * Validate the format of the due date field + * + * @param string $due + * @return bool + */ + public function due_date($due) + { + //Verify date format + $date_pattern = '/(20|1[0-9])[0-9]{2}\-(1[0-2]|0[1-9])\-(3[0-1]|2[0-8]|1[0-9]|0[1-9])/'; + + if ( ! (bool) preg_match($date_pattern, $due)) + { + $this->CI->form_validation->set_message('validate', 'You must enter a due date in YYYY-MM-DD format.'); + return FALSE; + } + + return TRUE; + } + + /** + * Verify that an email address is valid + * + * @param string $email + * @return bool + */ + public function valid_email($email) + { + $valid = filter_var($email, FILTER_VALIDATE_EMAIL); + + if ( ! $valid) + { + $this->CI->form_validation->set_message('validate', 'You must enter a valid email address.'); + } + + return $valid; + } +} +// End of libraries/Validation_callbacks.php \ No newline at end of file diff --git a/application/logs/index.html b/application/logs/index.html new file mode 100755 index 0000000..c942a79 --- /dev/null +++ b/application/logs/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + \ No newline at end of file diff --git a/application/models/friend_model.php b/application/models/friend_model.php new file mode 100755 index 0000000..b945398 --- /dev/null +++ b/application/models/friend_model.php @@ -0,0 +1,283 @@ +session->userdata('uid'); + + //Get the list of friends + $friends = $this->db + ->select('user_friend_id,user_friend_link.user_id as uid,user.username,user.email') + ->from('todo_user_friend_link') + ->join('user', 'user.id=user_friend_link.user_friend_id OR "todo_user"."id"="todo_user_friend_link"."user_id"', 'inner') + + ->group_start() + ->where_in('todo_user_friend_link.user_id', $user_id) + ->or_where_in('todo_user_friend_link.user_friend_id', $user_id) + ->group_end() + + ->where('confirmed', FRIEND_CONFIRMED) + ->where('user.id !=', $user_id) + ->order_by('username', 'asc') + ->get(); + + if($friends->num_rows() > 0) //Retrieve friends + { + $res_array = array(); + $friend_list = array(); + + foreach ($friends->result_array() as $friend) + { + $friend_id = ($friend['uid'] !== $user_id) + ? $friend['uid'] + : $friend['user_friend_id']; + + $res_array[$friend_id] = $friend; + + $friend_list[] = $friend_id; + + } + + //Get each user's groups + $groups = $this->db->select('user_id, name as group_name') + ->distinct() + ->from('group') + ->join('group_users_link', 'group_users_link.group_id=group.id', 'inner') + ->where_in('todo_group_users_link.user_id', $friend_list) + ->order_by('user_id, group_name', 'asc') + ->get(); + + if($groups->num_rows() > 0) + { + foreach($groups->result_array() as $group) + { + $res_array[$group['user_id']]['groups'][] = $group['group_name']; + } + } + + return $res_array; + + } + else + { + return FALSE; + } + } + + // -------------------------------------------------------------------------- + + /** + * Find Friends + * + * Gets list of possible friends from search query + * @return mixed + */ + public function find_friends() + { + $query = $this->input->get('q', TRUE); + $user_id = (int) $this->session->userdata('uid'); + + // Don't allow empty searches to reach the database + if (empty($query)) return []; + + //Loosely match usernames and emails to query + $res = $this->db->select('id, username, email') + ->from('user') + ->like('username', $query, 'after') + ->or_like('email', $query, 'after') + ->order_by('username', 'asc') + ->get(); + + if($res->num_rows() > 0) + { + $return = array(); + + foreach($res->result_array() as $friend) + { + //This person is already a friend + if($this->_check_friend($friend['id']) == TRUE) + continue; + + //If the person is you :/ + if($user_id == $friend['id']) + continue; + + $return[] = $friend; + } + + return $return; + } + + return (isset($return)) ? $return : []; + } + + // -------------------------------------------------------------------------- + + /** + * Get Request + * + * Gets friend requests to the current user + * @return mixed + */ + public function get_requests() + { + $user_id = $this->session->userdata('uid'); + + //Get the list of requests + $requests = $this->db->select('user_id, username, email') + ->from('user_friend_link') + ->where('user_friend_id', $user_id) + ->where('confirmed', -1) + ->join('user', 'user.id=user_friend_link.user_id') + ->get(); + + if($requests->num_rows() > 0) + { + return $requests->result_array(); + } + else + { + return false; + } + } + + // -------------------------------------------------------------------------- + + /** + * Send Request + * + * Sends a friend request, or confirms a mutual friend request + * + * @param int $friend_id + * @return int + */ + public function send_request($friend_id) + { + $user_id = (int) $this->session->userdata('uid'); + + //Check for request from the user + $friend_check = $this->db->select('user_id') + ->from('user_friend_link') + ->where('user_id', $friend_id) + ->where('user_friend_id', $user_id) + ->get(); + + if($friend_check->num_rows() > 0) + { + // Accept the friend request + // Allows the user to add a friend they ignored + // in their requests + $this->db->set('confirmed', FRIEND_CONFIRMED) + ->where('user_id', $friend_id) + ->where('user_friend_id', $user_id) + ->where('confirmed', FRIEND_NOT_CONFIRMED) + ->update('user_friend_link'); + } + else + { + //Check if the request already exists + $request_check = $this->db->from('user_friend_link') + ->where('user_friend_id', $friend_id) + ->where('user_id', $user_id) + ->get(); + + if($request_check->num_rows() > 0) return -1; + + //Add a friend request only if it doesn't already exist + $this->db->set('user_id', $user_id) + ->set('user_friend_id', $friend_id) + ->insert('user_friend_link'); + } + + return $this->db->affected_rows(); + } + + // -------------------------------------------------------------------------- + + /** + * Accept Request + * + * Accept a friend request + * @param int $request_id + * @return int + */ + public function accept_request($request_id) + { + $this->db->set('confirmed', FRIEND_CONFIRMED) + ->where('user_id', (int)$request_id) + ->where('confirmed', FRIEND_NOT_CONFIRMED) + ->update('user_friend_link'); + + return $this->db->affected_rows(); + } + + // -------------------------------------------------------------------------- + + /** + * Reject Request + * + * Reject a friend request + * @param int $request_id + * @return int + */ + public function reject_request($request_id) + { + $this->db->set('confirmed', FRIEND_REJECTED) + ->where('user_id', (int)$request_id) + ->where('confirmed', FRIEND_NOT_CONFIRMED) + ->update('user_friend_link'); + + return $this->db->affected_rows(); + } + + // -------------------------------------------------------------------------- + + /** + * Check Friend + * + * Check if a user is already a friend + * @param int $friend_id + * @return bool + */ + public function _check_friend($friend_id) + { + $user_id = $this->session->userdata('uid'); + + if($user_id == $friend_id) + return FALSE; + + $friend = $this->db->select('user_id, user_friend_id') + ->from('user_friend_link') + ->where('user_id', $user_id) + ->where('user_friend_id', $friend_id) + ->where('confirmed', FRIEND_CONFIRMED) + ->or_where('user_id', $friend_id) + ->where('user_friend_id', $user_id) + ->where('confirmed', FRIEND_CONFIRMED) + ->get(); + + return (bool)($friend->num_rows() > 0); + + } +} +// End of models/friend_model.php \ No newline at end of file diff --git a/application/models/mail_model.php b/application/models/mail_model.php new file mode 100755 index 0000000..0912ecc --- /dev/null +++ b/application/models/mail_model.php @@ -0,0 +1,147 @@ +load->library('email'); + + //Set email config + $config = array( + 'useragent' => "Tim's Todo", + 'protocol' => 'mail', + 'mailtype' => 'text', + 'charset' => 'utf-8', + 'validate' => 'true', + 'priority' => '3', + ); + + $this->email->initialize($config); + } + + // -------------------------------------------------------------------------- + + /** + * Check what reminders need to be sent out for the current run + * + * @return mixed + */ + public function check_db() + { + //Get the current time + $now = time(); + + //Get two minuts from now + $interval_new = $now + 900; + + //Get reminders within two minutes of now, that have not been sent + $this->db->select('reminder.id as rem_id, todo_item.id as task_num, + reminder_time, due, sent, title, email, username') + ->from('reminder') + ->join('item', 'todo_item.id = todo_reminder.task_id', 'inner') + ->join('user', 'todo_user.id = todo_reminder.user_id', 'inner') + ->where('reminder_time <', $interval_new) + ->where('sent', 0); + + $query = $this->db->get(); + + //If no results, return + if($query->num_rows() == 0) + return; + + //Format, then send the email + $this->_format_email($query); + + //Return debugging info + $return = $this->email->print_debugger(); + + //Log debugging info + log_message('debug', $return); + + //Clear the email object for the next loop + $this->email->clear(); + + return $return; + } + + // -------------------------------------------------------------------------- + + /** + * Format the email to send for a reminder + * + * @param $query + */ + private function _format_email($query) + { + foreach($query->result() as $row) + { + $due = $row->due; + $due_reminder = $row->reminder_time; + + //Time until task is due, in seconds + $until_due = $due - $due_reminder; + + //In hours + $until_hours = ($until_due >= 3600) ? floor((int)$until_due / 3600) : 0; + + //In additional minutes + $um = (int)$until_due - ($until_hours * 3600); + $until_minutes = (int)($um / 60); + + $user = $row->username; + $task_num = $row->task_num; + $task = $row->title; + $to = $row->email; + + $rem_id = $row->rem_id; + + $due_time = date('D M d, Y g:iA T', $due); + + $subject = "Tim's Todo Reminder: '" . $task . "' is due soon"; + $message = $user . ",\r\n". + "This is a reminder that task #". $task_num .", '".$task."' is due in ". + $until_hours." hours and ".$until_minutes." minutes, at " . $due_time; + + //Set email parameters + $this->email->to($to); + $this->email->from('noreply@timshomepage.net', "Tim's Todo"); + $this->email->message($message); + $this->email->subject($subject); + + $this->_send($rem_id); + + } + } + + // -------------------------------------------------------------------------- + + /** + * Send a reminder, and mark the reminder as sent + * + * @param $rem_id + */ + private function _send($rem_id) + { + $result = $this->email->send(); + + echo (int) $result . "\n"; + + if($result != FALSE) + { + //Set as set in the database + $this->db->set('sent', 1) + ->where('id', $rem_id) + ->update('reminder'); + } + } +} +// End of models/mail_model.php \ No newline at end of file diff --git a/application/models/task_model.php b/application/models/task_model.php new file mode 100755 index 0000000..cfd5a9e --- /dev/null +++ b/application/models/task_model.php @@ -0,0 +1,1597 @@ +session->userdata('uid'); + + //Get user's tasks + $user_sql = $this->db->select('item.title, item.id, item.due') + ->from('item') + ->where('user_id', $uid) + ->where_not_in('status', [STATUS_COMPLETED, STATUS_CANCELED]) + ->where('due >=', $start) + ->where('due <=', $end) + ->get_compiled_select(); + + //Get group-shared tasks + $group_sql = $this->db->select('item.title, item.id, item.due') + ->from('user') + ->join('group_users_link', 'group_users_link.user_id=user.id', 'inner') + ->join('group_task_link', 'group_task_link.group_id=group_users_link.group_id', 'inner') + ->join('item', 'item.id=group_task_link.task_id', 'inner') + ->where('todo_user.id', $uid) + ->where_not_in('status', [STATUS_COMPLETED, STATUS_CANCELED]) + ->where('due >=', $start) + ->where('due <=', $end) + ->where('todo_group_task_link.permissions !=', PERM_NO_ACCESS) + ->get_compiled_select(); + + //Get friend-shared tasks + $friend_sql = $this->db->select('item.title, item.id, item.due') + ->from('user') + ->join('user_task_link', 'user_task_link.user_id=user.id', 'inner') + ->join('item', 'item.id=user_task_link.task_id', 'inner') + ->where('todo_user.id', $uid) + ->where_not_in('status', [STATUS_COMPLETED, STATUS_CANCELED]) + ->where('due >=', $start) + ->where('due <=', $end) + ->where('todo_user_task_link.permissions !=', PERM_NO_ACCESS) + ->get_compiled_select(); + + $sql = "{$user_sql}\nUNION\n{$group_sql}\nUNION\n{$friend_sql}"; + + $cal_query = $this->db->query($sql); + $task_array = $cal_query->result_array(); + + //Some loopy variables + $content = array(); + $due = $start; + $due_end = $due + 86399; + $day = 1; + + while($day <= $num_days) + { + foreach ($task_array as $task) + { + if($task['due'] >= $due && $task['due'] <= $due_end) + { + //@codeCoverageIgnoreStart + if(isset($content[$day])) + { + $content[$day] .= '
  • '.$task['title']. + '
    due '.date('h:i A', $task['due']).'
  • '; + } + //@codeCoverageIgnoreEnd + else + { + $content[$day] = '
  • '.$task['title']. + '
    due '.date('h:i A', $task['due']).'
  • '; + } + } + + } + + ++$day; + $due += 86400; + $due_end += 86400; + } + + return $content; + } + + // -------------------------------------------------------------------------- + + /** + * Get Checklist + * + * Returns Checklist for current task + * @param int task_id + * @return array + */ + public function get_checklist($task_id) + { + //Get the checklist for the current task from the database + $chk = $this->db->select('id, task_id, "desc", is_checked') + ->from('checklist') + ->where('task_id', $task_id) + ->order_by('is_checked', 'asc') + ->order_by('id') + ->get(); + + return ($chk->num_rows() > 0) ? $chk->result_array() : array(); + + } + + // -------------------------------------------------------------------------- + + /** + * Add Checklist Item + * + * Adds a checklist item to the current checklist + * @return mixed bool/array + */ + public function add_checklist_item() + { + $task_id = (int)$this->input->post('task_id'); + $desc = xss_clean($this->input->post('desc')); + + //Check if the current item already exists. + $exists = $this->db->select('task_id, "desc"') + ->from('checklist') + ->where('task_id', $task_id) + ->where('"desc"', $desc) + ->get(); + + if($exists->num_rows() < 1) + { + //Insert the item + $this->db->set('task_id', $task_id) + ->set('"desc"', $desc) + ->insert('checklist'); + + //Return the row + $return = $this->db->select('id, task_id, "desc", is_checked') + ->from('checklist') + ->where('task_id', $task_id) + ->where('"desc"', $desc) + ->get(); + + return $return->row_array(); + } + else + { + return FALSE; + } + } + + // -------------------------------------------------------------------------- + + /** + * Delete Comment + * + * Deletes a comment from a task + * @param int $c_id + * @return int + */ + public function delete_comment($c_id) + { + //Get the user group id + $uid = $this->session->userdata('uid'); + + //Delete the comment that matches the c_id and uid + $this->db->where('id', $c_id) + ->where('user_id', $uid) + ->delete('item_comments'); + + if($this->db->affected_rows() > 0) + { + return $this->db->affected_rows(); + } + else + { + return -1; + } + } + + // -------------------------------------------------------------------------- + + /** + * Get Task List + * + * Retrieves the user's tasks from the database + * @return mixed + */ + public function get_task_list() + { + $this->db->from('todo_task_view') + ->where('user_id', (int) $this->session->userdata('uid')) + ->where_not_in('status_id', [STATUS_COMPLETED, STATUS_CANCELED]); + + $res = $this->db->get(); + + if($res->num_rows()==0) return; + + $result_array = array(); + $i=1; + foreach($res->result_array() as $row) + { + $result_array[$i] = $row; + $result_array[$i]['overdue'] = ($row['due'] < time() && $row['due'] != 0 || $row['priority'] == "Immediate"); + $i++; + } + + return $result_array; + } + + // -------------------------------------------------------------------------- + + /** + * Get archived task list + * + * Retrieves the user's archived tasks from the database + * + * @param int $per_page + * @return array + */ + public function get_archived_task_list($page=0, $per_page=10) + { + $offset = ($page == 1) ? 0 : $page; + $limit = $per_page; + + // Get the number of tasks for pagination + $this->db->select('item.id, user_id, category_id') + ->from('item') + ->where('user_id', $this->session->userdata('uid')) + ->where_in('status', [STATUS_COMPLETED, STATUS_CANCELED]) + ->order_by('modified', 'desc'); + + $r_rows = $this->db->get(); + + $this->db->from('todo_task_view') + ->where('user_id', $this->session->userdata('uid')) + ->where_in('status_id', [STATUS_COMPLETED, STATUS_CANCELED]) + ->order_by('modified', 'desc') + ->limit($limit, $offset); + + $res = $this->db->get(); + + if($res->num_rows()==0) + return; + + $result_array = array(); + $i=1; + foreach($res->result_array() as $row) + { + $result_array[$i] = $row; + $result_array[$i]['overdue'] = FALSE; + $i++; + } + + $result_array['num_rows'] = $r_rows->num_rows(); + + return $result_array; + } + + // -------------------------------------------------------------------------- + + /** + * Get overdue task list + * + * Retrieves the user's overdue tasks from the database + * @return array + */ + public function get_overdue_task_list() + { + $this->db->select('item.id, user_id, category_id, item.priority, + status, item.title, due, modified, created, + category.title as category, priority.value as priority, + status.value as status') + ->from('item') + ->join('category', 'category.id=item.category_id', 'inner') + ->join('priority', 'priority.id=item.priority', 'inner') + ->join('status', 'status.id=item.status', 'inner') + ->where('user_id', (int)$this->session->userdata('uid')) + + ->group_start() + ->where('due <', time()) + ->or_where('item.priority', 9) + ->group_end() + + ->where_not_in('status', [STATUS_COMPLETED, STATUS_CANCELED]) + ->where('due !=', 0) + ->order_by('due', 'asc') + ->order_by('item.priority', 'desc'); + + $res = $this->db->get(); + + if($res->num_rows()==0) + return; + + $result_array = array(); + $i=1; + foreach($res->result_array() as $row) + { + $result_array[$i] = $row; + + // Overdue is set as false to cut down on visual noise. + // Since every task in the list is overdue, using the + // visual style is redundant + $result_array[$i]['overdue'] = FALSE; + $i++; + } + + return $result_array; + } + + /** + * Get shared task list + * + * returns a list of shared tasks + * @return array + */ + public function get_shared_task_list() + { + $user_id = (int) $this->session->userdata('uid'); + + $user_shared_sql = $this->db->select('item.id, user.id as user_id, category_id, item.priority, + status, item.title, due, modified, created, + category.title as category, priority.value as priority, + status.value as status, group_task_link.permissions as group_perms') + ->distinct() + ->from('user') + ->join('group_users_link', 'group_users_link.user_id=user.id', 'inner') + ->join('group_task_link', 'group_task_link.group_id=group_users_link.group_id', 'inner') + ->join('item', 'item.id=group_task_link.task_id', 'inner') + ->join('category', 'category.id=item.category_id', 'inner') + ->join('priority', 'priority.id=item.priority', 'inner') + ->join('status', 'status.id=item.status', 'inner') + ->where('todo_user.id', $user_id) + ->where_not_in('status', [STATUS_COMPLETED, STATUS_CANCELED]) + ->where('todo_group_task_link.permissions !=', PERM_NO_ACCESS) + ->get_compiled_select(); + + $group_shared_sql = $this->db->select('item.id, user.id as user_id, category_id, item.priority, + status, item.title, due, modified, created, + category.title as category, priority.value as priority, + status.value as status, user_task_link.permissions as user_perms') + ->distinct() + ->from('user') + ->join('user_task_link', 'user_task_link.user_id=user.id', 'inner') + ->join('item', 'item.id=user_task_link.task_id', 'inner') + ->join('category', 'category.id=item.category_id', 'inner') + ->join('priority', 'priority.id=item.priority', 'inner') + ->join('status', 'status.id=item.status', 'inner') + ->where('todo_user.id', $user_id) + ->where_not_in('status', [STATUS_COMPLETED, STATUS_CANCELED]) + ->where('todo_user_task_link.permissions !=', PERM_NO_ACCESS) + ->get_compiled_select(); + + $sql = "{$user_shared_sql}\nUNION ALL\n{$group_shared_sql}"; + + $res = $this->db->query($sql); + + $now = time(); + + $result_array = array(); + $i=1; + foreach($res->result_array() as $row) + { + $result_array[$i] = $row; + $result_array[$i]['overdue'] = ($result_array[$i]['due'] < $now && $result_array[$i]['due'] != 0); + $i++; + } + + return $result_array; + } + + // -------------------------------------------------------------------------- + + /** + * Validate Task + * + * Validates a new task before database submission. + * @return mixed + */ + public function validate_task() + { + // Clear previous validations + $this->form_vals = NULL; + + $title = $this->input->post('title', TRUE); + $desc = $this->input->post('desc', TRUE); + $category = (int) $this->input->post('category'); + $priority = (int) $this->input->post('priority'); + $due = $this->input->post('due', TRUE); + $due_hour = $this->input->post('due_hour', TRUE); + $due_minute = $this->input->post('due_minute', TRUE); + $status = ($this->input->post('status') == FALSE) ? 1 : $this->input->post('status'); + $created = time(); + + $err = array(); + + //Check title + if(strlen($title) < 1) + { + $err[] = "You must give the task a title"; + } + else + { + //Return form values + $this->form_vals['title'] = $title; + } + + //Check description + if(strlen($desc) < 1) + { + $err[] = "The task must have a description"; + } + else + { + //Return form values + $this->form_vals['description'] = $desc; + } + + //Check task category + if((int)$category < 1) + { + $err[] = "Select a task category"; + } + else + { + //Return form values + $this->form_vals['category'] = $category; + } + + //Check due date + if ($due != 0) + { + //Verify date format + $valid = $this->validation_callbacks->due_date($due); + + + if ( ! $valid) + { + $err[] = "You must enter a due date in YYYY-MM-DD format."; + return $err; + } + + $due_a = explode('-', $due); + $min = $due_minute; + $hour = $due_hour; + + $due_timestamp = mktime($hour,$min,0,$due_a[1],$due_a[2],$due_a[0]); + + //Return form values + $this->form_vals['due'] = $due_timestamp; + $this->form_vals['due_minute'] = $due_minute; + } + else + { + $due_timestamp = 0; + } + + //If there is an email reminder + if($this->input->post('reminder') == 'rem_true') + { + if($due == 0) + { + $err[] = "You must set a due date in order to get a reminder."; + } + + if(!is_numeric($this->input->post('rem_hours')) OR + !is_numeric($this->input->post('rem_minutes'))) + { + $err[] = "You must put numeric hours and minutes for a reminder time."; + } + else + { + $reminder_hour = (int)$this->input->post('rem_hours'); + $reminder_min = (int)$this->input->post('rem_minutes'); + + $seconds = ($reminder_hour * 3600)+($reminder_min * 60); + $reminder_time = $due_timestamp - $seconds; + + $this->reminder = TRUE; + $this->reminder_time = $reminder_time; + + //Return form values + $this->form_vals['reminder'] = TRUE; + $this->form_vals['rem_hours'] = $reminder_hour; + $this->form_vals['rem_minutes'] = $reminder_min; + } + } + else + { + $this->reminder = FALSE; + } + + $share_type = FALSE; + + //If the task is shared + if($this->input->post('share') !== FALSE) + { + $groups = $this->input->post('group', TRUE); + $group_perms = $this->input->post('group_perms', TRUE); + $friends = $this->input->post('friend', TRUE); + $friend_perms = $this->input->post('friend_perms', TRUE); + + if($groups != FALSE && $group_perms != FALSE) + { + $share_type = 'group'; + } + + if($friends != FALSE && $friend_perms != FALSE) + { + $share_type = 'friend'; + } + + } + + //If there aren't any errors + if(empty($err)) + { + $this->groups = ( ! empty($groups)) ? $groups : FALSE; + $this->friends = ( ! empty($friends)) ? $friends : FALSE; + $this->share_type = $share_type; + $this->title = $title; + $this->description = $desc; + $this->category = $category; + $this->priority = $priority; + $this->status = $status; + $this->created = $created; + $this->due = $due_timestamp; + $this->friend_perms = (isset($friend_perms)) ? $friend_perms : FALSE; + $this->group_perms = (isset($group_perms)) ? $group_perms : FALSE; + $this->user_id = $this->session->userdata('uid'); + $this->task_id = ($this->input->post('task_id') != FALSE) ? + $this->input->post('task_id') : + $this->db->count_all('item') + 1; + + return TRUE; + } + else //otherwise, return the errors + { + return $err; + } + } + + // -------------------------------------------------------------------------- + + /** + * Add Task + * + * Submits new task to database + * @return bool + */ + public function add_task() + { + $title = $this->title; + $desc = $this->description; + $category = $this->category; + $priority = $this->priority; + $status = $this->status; + $created = $this->created; + $due = $this->due; + $uid = $this->user_id; + + $this->db->set('user_id', $uid) + ->set('category_id', $category) + ->set('priority', $priority) + ->set('status', $status) + ->set('title', $title) + ->set('description', $desc) + ->set('due', $due) + ->set('created', $created) + ->set('modified', 0); + + $this->db->insert('item'); + + if($this->db->affected_rows() < 1) + return FALSE; + + //Get last inserted task + $query = $this->db->select('max(id) as id')->from('item')->get(); + $row = $query->row(); + $task_id = $row->id; + + //Get groups + if($this->groups != FALSE) + { + if($this->group_perms != FALSE) + { + foreach($this->groups as $group) + { + $this->db->set('group_id', $group) + ->set('task_id', $task_id) + ->set('permissions', $this->group_perms) + ->insert('group_task_link'); + } + } + } + + //Get friends + if($this->friends != FALSE) + { + if($this->friend_perms != FALSE) + { + foreach($this->friends as $friend) + { + $this->db->set('user_id', $friend) + ->set('task_id', $task_id) + ->set('permissions', $this->friend_perms) + ->insert('user_task_link'); + } + } + } + + + if($this->reminder == TRUE) + { + $reminder_time = $this->reminder_time; + $this->_add_reminder($task_id, $reminder_time); + } + + return TRUE; + + } + + // -------------------------------------------------------------------------- + + /** + * Update Task + * + * Updates current task + * @return bool + */ + public function update_task() + { + $title = $this->title; + $desc = str_replace('
    ', '
    ', $this->description); + $category = $this->category; + $priority = $this->priority; + $status = $this->status; + $due = $this->due; + $uid = $this->user_id; + $task_id = $this->task_id; + + $this->db->set('category_id', $category) + ->set('priority', $priority) + ->set('status', $status) + ->set('title', $title) + ->set('description', $desc) + ->set('due', $due) + ->set('modified', time()) + ->where('id', $task_id) + ->where('user_id', $uid); + + $this->db->update('item'); + + //Check the status separately, to account for email reminders + $this->update_status(); + + if($this->reminder == TRUE) + { + $reminder_time = $this->reminder_time; + $this->_add_reminder($task_id, $reminder_time); + } + else + { + // Delete old reminders + $this->db->where('task_id', $task_id) + ->delete('reminder'); + } + + // Remove old shared permissions + { + // Delete existing groups and users + $group_list = $this->_get_task_groups($task_id); + + // Delete groups + if ( ! empty($group_list)) + { + $this->db->where_in('group_id', $group_list) + ->where('task_id', $task_id) + ->delete('group_task_link'); + } + + // Delete friends + $friend_list = $this->_get_task_users($task_id); + + if ( ! empty($friend_list)) + { + $this->db->where_in('user_id', $friend_list) + ->where('task_id', $task_id) + ->or_where('user_id', (int) $this->session->userdata('uid')) + ->where('task_id', $task_id) + ->delete('user_task_link'); + } + + } + + + //Get groups + if($this->share_type == 'group') + { + if($this->group_perms !== FALSE) + { + foreach($this->groups as $group) + { + $this->db->set('group_id', $group) + ->set('task_id', $task_id) + ->set('permissions', $this->group_perms) + ->insert('group_task_link'); + } + } + } + + //Get friends + if($this->share_type == 'friend') + { + if($this->friend_perms !== FALSE) + { + foreach($this->friends as $friend) + { + $this->db->set('user_id', $friend) + ->set('task_id', $task_id) + ->set('permissions', $this->friend_perms) + ->insert('user_task_link'); + } + + if ($this->db->affected_rows() < 1) + {return false;} + + //Set current user too + $this->db->set('user_id', $this->session->userdata('uid')) + ->set('task_id', $task_id) + ->set('permissions', $this->friend_perms) + ->insert('user_task_link'); + } + } + + return true; + } + + // -------------------------------------------------------------------------- + + /** + * Get Task By Id + * + * Retreives task from database by task id + * @param int $task_id + * @return array + */ + public function get_task_by_id($task_id) + { + //Get the task + $task = $this->db->select( + 'item.id, + item.user_id, + item.priority, + item.title, + item.due, + item.modified, + item.created, + item.description, + user.username, + status.value as current_status, + priority.value as priority, + category.title as cat_name' + ) + ->from('item') + ->join('user', 'user.id=todo_item.user_id', 'inner') + ->join('category', 'category.id=todo_item.category_id', 'inner') + ->join('priority', 'priority.id=todo_item.priority', 'inner') + ->join('status', 'status.id=todo_item.status', 'inner') + ->where('todo_item.id', (int) $task_id) + ->get(); + + $task_array = $task->row_array(); + + //Get the task permissions + $result_array = array_merge($task_array, $this->_get_task_perms($task_id)); + + //Get selected groups + $result_array['selected_groups'] = $this->_get_task_groups($task_id); + + //Get selected friends + $result_array['selected_friends'] = $this->_get_task_users($task_id); + + //Get any related task reminders + $query2 = $this->db->select('task_id, reminder_time') + ->from('reminder') + ->where('task_id', $task_id) + ->where('user_id', $this->session->userdata('uid')) + ->get(); + + //If there aren't any reminders + if($query2->num_rows() < 1) + { + $result_array['reminder'] = FALSE; + $result_array['rem_hours'] = 0; + $result_array['rem_minutes'] = 30; + return $result_array; + } + else //There are reminders + { + $res2 = $query2->row(); + + $result_array['reminder'] = TRUE; + + //Time until task is due, in seconds + $until_due = $result_array['due'] - $res2->reminder_time; + + //In hours + $until_hours = ($until_due >= 3600) ? floor((int)$until_due / 3600) : 0; + + //In additional minutes + $until_seconds = (int)$until_due - ($until_hours * 3600); + $until_minutes = (int)($until_seconds / 60); + + $result_array['rem_hours'] = $until_hours; + $result_array['rem_minutes'] = $until_minutes; + + return $result_array; + } + } + + // -------------------------------------------------------------------------- + + /** + * Get the status id for the selected task + * + * @param int $task_id + * @return int + */ + public function get_current_status_id($task_id=0) + { + // @codeCoverageIgnoreStart + if($task_id==0) + { + $task_id=$this->uri->segment($this->uri->total_segments()); + } + // @codeCoverageIgnoreEnd + + //Get the status from the task + $task = $this->db->select('id, status') + ->from('item') + ->where('id', (int) $task_id) + ->get(); + + $trow = $task->row(); + $status_id = $trow->status; + + return $status_id; + } + + // -------------------------------------------------------------------------- + + /** + * Get Status Select + * + * Returns select options for task status + * @param int $task_id + * @param int $status_id + * @return string + */ + public function get_status_select($task_id=0, $status_id=NULL) + { + $html = ''; + + if (is_null($status_id)) + { + $status_id = $this->get_current_status_id($task_id); + } + + //Get the list of statuses + $query = $this->db->select('id, value as desc') + ->from('status') + ->get(); + + foreach($query->result() as $row) + { + $html .= T5.''.NL; + } + + return $html; + } + + // -------------------------------------------------------------------------- + + /** + * Get Priority Select + * + * Returns priority options for task status + * @param int $task_id + * @return string + */ + public function get_priority_select($task_id=0) + { + // @codeCoverageIgnoreStart + if($task_id==0) + $task_id=$this->uri->segment($this->uri->total_segments()); + // @codeCoverageIgnoreEnd + + $html = ''; + + //Get the status from the task + $task = $this->db->select('id, priority') + ->from('item') + ->where('id', $task_id) + ->order_by('id', 'asc') + ->get(); + + $trow = $task->row(); + $pri_id = $trow->priority; + + //Get the list of statuses + $query = $this->db->select('id, value as desc') + ->from('priority') + ->get(); + + foreach($query->result() as $row) + { + $html .= T5.''.NL; + } + + return $html; + } + + // -------------------------------------------------------------------------- + + /** + * Get Category Select + * + * Returns category options for task status + * @param int $id + * @return string + */ + public function get_category_select($task_id=0) + { + // @codeCoverageIgnoreStart + if($task_id==0) + $task_id=$this->uri->segment($this->uri->total_segments()); + // @codeCoverageIgnoreEnd + + $html = ''; + + //Get the user's category group + $user_group_id = $this->todo->get_user_group(); + + //Get the category from the task + $task = $this->db->select('id, category_id') + ->from('item') + ->where('id', $task_id) + ->get(); + + $trow = $task->row(); + $category_id = $trow->category_id; + + //Get the list of categories + $query = $this->db->select('id, title as desc') + ->from('category') + ->where('group_id', 0) + ->or_where('group_id', $user_group_id) + ->order_by('title', 'asc') + ->get(); + + foreach($query->result() as $row) + { + $html .= T5.''.NL; + } + + return $html; + } + + // -------------------------------------------------------------------------- + + /** + * Update Status + * + * Updates task status + * @return int + */ + public function update_status() + { + $new_status = (int)$this->input->post('status'); + $task_id = (int)$this->input->post('task_id'); + + //If you are marking it as complete + if($new_status == STATUS_COMPLETED) + { + //Check for reminders attached to that task + $rem_q = $this->db->select('id') + ->from('reminder') + ->where('task_id', $task_id) + ->where('sent', 0) + ->get(); + + //If there are reminders attached + if($rem_q->num_rows() > 0) + { + //Go through the results, and mark each as done + foreach($rem_q->result() as $reminder) + { + $this->db->set('sent', 1) + ->where('id', $reminder->id) + ->update('reminder'); + + } + } + } + else //Maybe it wasn't really complete yet + { + //Check if the task was marked complete + $stat_q = $this->db->select('status') + ->from('item') + ->where('id', $task_id) + ->where_in('status', [STATUS_COMPLETED, STATUS_CANCELED]) + ->get(); + + //if it was complete, check for associated reminders that are due in the future + if($stat_q->num_rows() > 0) + { + $now = time(); + + $rem_q = $this->db->select('id') + ->from('reminder') + ->where('task_id', $task_id) + ->where('reminder_time >', $now) + ->get(); + + //Update those reminders to be sent + foreach($rem_q->result() as $reminder) + { + $this->db->set('sent', 0) + ->where('id', $reminder->id) + ->update('reminder'); + } + } + } + + //I guess we should actually update the status + $this->db->set('status', $new_status) + ->set('modified', time()) + ->where('id', $task_id) + ->update('item'); + + return $this->db->affected_rows(); //'success'; + } + + // -------------------------------------------------------------------------- + + /** + * Quick Update Category + * + * Updates task category via ajax + * @return int + */ + public function quick_update_category() + { + $new_category = (int)$this->input->post('category'); + $task_id = (int)$this->input->post('task_id'); + + $this->db->set('category_id', $new_category) + ->where('id', $task_id) + ->update('item'); + + return $this->db->affected_rows(); //'success'; + } + + // -------------------------------------------------------------------------- + + /** + * Get task Comments + * + * Returns comments for the current task + * @param int $task_id + * @return array + */ + public function get_task_comments($task_id) + { + $comment_q = $this->db->select('item_comments.id, user_id, item_id, comment, time_posted, email, status.value as status') + ->from('item_comments') + ->join('user', 'item_comments.user_id=user.id', 'inner') + ->join('status', 'item_comments.status=status.id', 'inner') + ->where('item_id', (int) $task_id) + ->order_by('time_posted', 'desc') + ->get(); + + $result_array = $comment_q->result_array(); + return $result_array; + } + + // -------------------------------------------------------------------------- + + /** + * Add task comment + * + * Adds a task comment to the database + * @param int $task_id + * @return string + */ + public function add_task_comment($task_id) + { + $user_id = $this->session->userdata('uid'); + $comment = xss_clean($this->input->post('comment')); + $status = $this->input->post('status'); + $time = time(); + + //Insert the comment + $this->db->set('item_id', $task_id) + ->set('user_id', $user_id) + ->set('comment', $comment) + ->set('time_posted', $time) + ->set('status', $status) + ->insert('item_comments'); + + return $this->db->affected_rows(); + } + + // -------------------------------------------------------------------------- + + /** + * Delete Task + * + * Checks for permissions to delete a task + * @param int $task_id + * @return null + */ + public function delete_task($task_id) + { + $user = $this->session->userdata('uid'); + + //Check if the user is task admin + $user_perms = $this->db->select('item.id') + ->from('item') + ->where('user_id', $user) + ->get(); + + $admin = ($user_perms->num_rows() > 0) ? TRUE : FALSE; + + //Check if the user has permission to delete this task + $friend_perms = $this->db->select('user.id') + ->distinct() + ->from('user') + ->join('user_task_link', 'user_task_link.user_id=user.id', 'inner') + ->join('item', 'user_task_link.task_id=item.id', 'inner') + ->where('user.id', $user) + ->where('task_id', $task_id) + ->where('permissions', 9) + ->get(); + + $user_admin = ($friend_perms->num_rows() > 0) ? TRUE : FALSE; + + + //Check if the group this user is in has permission to delete this task + $group_perms = $this->db->select('user.id') + ->distinct() + ->from('user') + ->join('group_users_link', 'group_users_link.user_id=user.id', 'inner') + ->join('group_task_link', 'group_task_link.group_id=group_users_link.group_id', 'inner') + ->where('user.id', $user) + ->where('group_task_link.task_id', $task_id) + ->where('permissions', 9) + ->get(); + + $group_admin = ($group_perms->num_rows() > 0) ? TRUE : FALSE; + + + //Check if the user has permission + if($admin === TRUE) + { + $this->_remove_task($task_id); + return; + } + else if($user_admin === TRUE) + { + $this->_remove_task($task_id); + return; + } + else if($group_admin === TRUE) + { + $this->_remove_task($task_id); + return; + } + else + { + show_error('You do not have permission to delete this task.'); + return; + } + } + + // -------------------------------------------------------------------------- + + /** + * Update Checklist + * + * Updates a checklist + * + * @param int $check_id + * @param bit $checked + */ + public function update_checklist($check_id, $checked) + { + $task_id = $this->input->post('task_id'); + + //Get the task checklist items + $clq = $this->db->select('is_checked') + ->from('checklist') + ->where('task_id', $task_id) + ->get(); + + $checklist = $clq->result_array(); + + $num_items = count($checklist); + $num_checked = 0; + + //Count the number checked + foreach($checklist as $bit) + { + //if true, add 1, if false, add 0; + $num_checked += $bit['is_checked']; + } + + $unchecked = $num_items - $num_checked; + + if($checked == 1) //Checking another box + { + //Check if it's the first checkbox to be checked + $is_first = ($num_checked == 0) ? TRUE : FALSE; + + //Check if it's the last checkbox to be checked + $is_last = ($unchecked == 1) ? TRUE : FALSE; + + //Update the checklist item in db + $this->db->set('is_checked', 1) + ->where('id', $check_id) + ->update('checklist'); + + //if the checkbox doesn't update, show error + if($this->db->affected_rows() < 1) + { + return -1; + } + + //If it's the first item, set the status of the task to "In progress" + if($is_first == TRUE) + { + $this->db->set('status', 3) + ->where('id', $task_id) + ->update('item'); + + return ($this->db->affected_rows() > 0) ? "first" : -1; + } + + if($is_last == TRUE) //set status to "Completed" + { + $this->db->set('status', 2) + ->where('id', $task_id) + ->update('item'); + + return ($this->db->affected_rows() > 0) ? "last" : -1; + } + else + { + return 1; + } + + } + else if($checked == 0) //Unchecking a checkbox + { + $is_last = ($unchecked == 0) ? TRUE : FALSE; + + //Update the checklist item in db + $this->db->set('is_checked', 0) + ->where('id', $check_id) + ->update('checklist'); + + if($this->db->affected_rows() < 1) + return PERM_NO_ACCESS; + + //if unchecking the last item, set status as "In progress" + if($is_last == TRUE) + { + $this->db->set('status', 3) + ->where('id', $task_id) + ->update('item'); + + return ($this->db->affected_rows() > 0) ? "first" : -1; + } + } + } + + + // -------------------------------------------------------------------------- + + /** + * Add Reminder + * + * Adds reminder to the database + */ + private function _add_reminder($task_id, $reminder_time) + { + $user_id = (int) $this->session->userdata('uid'); + + //Check for a reminder with the current task id + $query = $this->db->select('task_id') + ->from('reminder') + ->where('task_id', $task_id) + ->get(); + + //Check if there is an existing reminder for this task + if($query->num_rows() < 1) + { + $this->db->set('task_id', $task_id) + ->set('reminder_time', $reminder_time) + ->set('user_id', $user_id) + ->insert('reminder'); + } + else //If there is, update it. + { + + $this->db->set('reminder_time', $reminder_time) + ->where('task_id', $task_id) + ->where('user_id', $user_id) + ->update('reminder'); + } + } + + // -------------------------------------------------------------------------- + + /** + * Get Task Groups + * + * Returns groups related to the current task + * @param int $task_id + * @return array + */ + private function _get_task_groups($task_id) + { + $groups = $this->db->select('group_id') + ->from('group_task_link') + ->where('permissions !=', PERM_NO_ACCESS) + ->where('task_id', $task_id) + ->get(); + + $group_list = $groups->result_array(); + $result_array = array(); + + if($groups->num_rows() < 1) + { + return FALSE; + } + + foreach($group_list as $group) + { + $result_array[] = $group['group_id']; + } + + return $result_array; + } + + // -------------------------------------------------------------------------- + + /** + * Get Task Users + * + * Returns users related to the current task + * @param int $task_id + * @return array + */ + private function _get_task_users($task_id) + { + $query = $this->db->select('user_id') + ->from('user_task_link') + ->where('permissions !=', PERM_NO_ACCESS) + ->where('task_id', $task_id) + ->get(); + + $friend_list = $query->result_array(); + $result_array = array(); + + if($query->num_rows() < 1) + { + return FALSE; + } + + foreach($friend_list as $friend) + { + $result_array[] = $friend['user_id']; + } + + return $result_array; + } + + // -------------------------------------------------------------------------- + + /** + * Get Task Perms + * + * Get the permissions of the current task + * @param int $id + * @return array + */ + private function _get_task_perms($task_id) + { + /** + * Get the task shared permissions + */ + + //Get groups associated with the task and user + $group_perms = $this->db->select('group_task_link.permissions') + ->from('user') + ->join('group_users_link', 'group_users_link.user_id=user.id', 'inner') + ->join('group_task_link', 'group_task_link.group_id=group_users_link.group_id', 'inner') + ->join('item', 'item.id=group_task_link.task_id', 'inner') + ->where('todo_item.id', (int) $task_id) + ->where('todo_group_task_link.permissions !=', PERM_NO_ACCESS) + ->where('todo_user.id', (int) $this->session->userdata('uid')) + ->limit(1) + ->get(); + + //Get friends associated with the task and user + $friend_perms = $this->db->select('user_task_link.permissions') + ->from('item') + ->join('user_task_link', 'user_task_link.task_id=item.id') + ->where('todo_user_task_link.permissions !=', PERM_NO_ACCESS) + ->where('todo_user_task_link.task_id', (int) $task_id) + ->where('todo_user_task_link.user_id', (int) $this->session->userdata('uid')) + ->limit(1) + ->get(); + + //Set permissions to no access as default + $result_array = array( + 'friend_perms' => PERM_NO_ACCESS, + 'group_perms' => PERM_NO_ACCESS, + 'user_perms' => PERM_NO_ACCESS + ); + + $resf = ($friend_perms->num_rows() == 1) ? $friend_perms->row_array() : array('permissions' => FALSE); + $resg = ($group_perms->num_rows() == 1) ? $group_perms->row_array() : array('permissions' => FALSE); + + //Group permissions are set + if($resg['permissions'] !== FALSE && $resf['permissions'] === FALSE) + { + //Return groups query + $result_array['group_perms'] = $resg['permissions']; + $result_array['friend_perms'] = PERM_NO_ACCESS; + + } + + //Group and friend permissions set + if($resg['permissions'] !== FALSE && $resf['permissions'] !== FALSE) + { + //Return groups query and friend_perms + $result_array['friend_perms'] = $resf['permissions']; + $result_array['group_perms'] = $resf['permissions']; + + } + + //Friend Permissions are set + if($resg['permissions'] === FALSE && $resf['permissions'] !== FALSE) + { + //Return user query + $result_array['friend_perms'] = $resf['permissions']; + $result_array['group_perms'] = PERM_NO_ACCESS; + } + + /** + * Get the current user's permissions from the database + */ + + //Check group permissions + $upG = $this->db->select('permissions') + ->from('user') + ->join('group_users_link', 'group_users_link.user_id=user.id', 'inner') + ->join('group_task_link', 'group_task_link.group_id=group_users_link.group_id', 'inner') + ->where('todo_group_users_link.user_id', (int) $this->session->userdata('uid')) + ->where('todo_group_task_link.task_id', (int) $task_id) + ->get(); + + //Check user permissions + $upU = $this->db->select('permissions') + ->from('user_task_link') + ->where('todo_user_task_link.user_id', (int) $this->session->userdata('uid')) + ->where('todo_user_task_link.task_id', $task_id) + ->get(); + + //Check if task admin + $upA = $this->db->select('id') + ->from('item') + ->where('id', (int) $task_id) + ->where('user_id', (int) $this->session->userdata('uid')) + ->get(); + + //Check for admin permissions + if($upA->num_rows() > 0) + { + $result_array['user_perms'] = 9; + return $result_array; + } + else //User is not admin + { + //Check group permissions + if($upG->num_rows() > 0) + { + $upG_row = $upG->row_array(); + $result_array['user_perms'] = $upG_row['permissions']; + } + + //Check individual user permissions + if($upU->num_rows() > 0) + { + $up_row = $upU->row_array(); + $result_array['user_perms'] = $up_row['permissions']; + } + + //Determine whether the current user can view and/or edit this task + if($result_array['user_perms'] == PERM_NO_ACCESS) + { + show_error('You do not have permission to view this task.'); + return; + } + else if($result_array['user_perms'] < PERM_WRITE_ACCESS && $this->uri->segment('2') == "edit") + { + show_error('You do not have permission to edit this task.'); + return; + } + + return $result_array; + } + } + + // -------------------------------------------------------------------------- + + /** + * Remove Task + * + * Delete a task from the database + * @param int $task_id + */ + private function _remove_task($task_id) + { + //Delete references from reminder + $this->db->where('task_id', $task_id) + ->delete('reminder'); + + //Delete references from group_task_link + $this->db->where('task_id', $task_id) + ->delete('group_task_link'); + + //Delete references from user_task_link + $this->db->where('task_id', $task_id) + ->delete('user_task_link'); + + //Delete task comments + $this->db->where('item_id', $task_id) + ->delete('item_comments'); + + //Delete checklists + $this->db->where('task_id', $task_id) + ->delete('checklist'); + + //Delete the task + $this->db->where('id', $task_id) + ->delete('item'); + + //Redirect to the task list + $this->todo->redirect_303(site_url('task/list')); + } +} \ No newline at end of file diff --git a/application/third_party/CIUnit/bootstrap_phpunit.php b/application/third_party/CIUnit/bootstrap_phpunit.php new file mode 100755 index 0000000..abf205d --- /dev/null +++ b/application/third_party/CIUnit/bootstrap_phpunit.php @@ -0,0 +1,278 @@ +'; +var_dump($GLOBALS); +echo ''; +exit; +*/ + +/* + * ------------------------------------------------------ + * CIUnit Version + * ------------------------------------------------------ + */ + define('CIUnit_Version', '0.18-dev_for_CI2.1.0'); + +/* + *--------------------------------------------------------------- + * APPLICATION ENVIRONMENT + *--------------------------------------------------------------- + * + * You can load different configurations depending on your + * current environment. Setting the environment also influences + * things like logging and error reporting. + * + * This can be set to anything, but default usage is: + * + * development + * testing + * production + * + * NOTE: If you change these, also change the error_reporting() code below + * + */ + define('ENVIRONMENT', 'testing'); +/* + *--------------------------------------------------------------- + * ERROR REPORTING + *--------------------------------------------------------------- + * + * By default CI runs with error reporting set to -1. + * + */ + + error_reporting(-1); + +/* + *--------------------------------------------------------------- + * 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! + * + * The test should be run from inside the tests folder. The assumption + * is that the tests folder is in the same directory path as system. If + * it is not, update the paths appropriately. + */ + $system_path = dirname(__FILE__) . '/../../../system'; + +/* + *--------------------------------------------------------------- + * APPLICATION FOLDER NAME + *--------------------------------------------------------------- + * + * If you want this front controller to use a different "application" + * folder then the default one you can set its name here. The folder + * can also be renamed or relocated anywhere on your server. If + * you do, use a full server path. For more info please see the user guide: + * http://codeigniter.com/user_guide/general/managing_apps.html + * + * NO TRAILING SLASH! + * + * The tests should be run from inside the tests folder. The assumption + * is that the tests folder is in the same directory as the application + * folder. If it is not, update the path accordingly. + */ + $application_folder = dirname(__FILE__) . '/../..'; + +/* + *--------------------------------------------------------------- + * VIEW FOLDER NAME + *--------------------------------------------------------------- + * + * If you want to move the view folder out of the application + * folder set the path to the folder here. The folder can be renamed + * and relocated anywhere on your server. If blank, it will default + * to the standard location inside your application folder. If you + * do move this, use the full server path to this folder + * + * NO TRAILING SLASH! + * + */ + $view_folder = ''; + + +/* + * ------------------------------------------------------------------- + * 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'; + + +/** + * -------------------------------------------------------------- + * CIUNIT FOLDER NAME + * -------------------------------------------------------------- + * + * Typically this folder will be within the application's third-party + * folder. However, you can place the folder in any directory. Just + * be sure to update this path. + * + * NO TRAILING SLASH! + * + */ + $ciunit_folder = dirname(__FILE__); + +/** + * -------------------------------------------------------------- + * UNIT TESTS FOLDER NAME + * -------------------------------------------------------------- + * + * This is the path to the tests folder. + */ + $tests_folder = dirname(__FILE__) . "/../../../tests"; + + + +// -------------------------------------------------------------------- +// END OF USER CONFIGURABLE SETTINGS. DO NOT EDIT BELOW THIS LINE +// -------------------------------------------------------------------- + +/* + * --------------------------------------------------------------- + * Resolve the system path for increased reliability + * --------------------------------------------------------------- + */ + +/* This chdir() causes error when run tests by folder. + // Set the current directory correctly for CLI requests + if (defined('STDIN')) + { + chdir(dirname(__FILE__)); + } +*/ + + if (realpath($system_path) !== FALSE) + { + $system_path = realpath($system_path).'/'; + } + + // ensure there's a trailing slash + $system_path = rtrim($system_path, '/').'/'; + + // Is the system path correct? + if ( ! is_dir($system_path)) + { + exit("Your system folder path does not appear to be set correctly. Please open the following file and correct this: ".pathinfo(__FILE__, PATHINFO_BASENAME)); + } + +/* + * ------------------------------------------------------------------- + * Now that we know the path, set the main path constants + * ------------------------------------------------------------------- + */ + // The name of THIS file + define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME)); + + // The PHP file extension + // this global constant is deprecated. + define('EXT', '.php'); + + // Path to the system folder + define('BASEPATH', str_replace("\\", "/", $system_path)); + + // Path to the front controller (this file) + define('FCPATH', str_replace(SELF, '', __FILE__)); + + // Name of the "system folder" + define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/')); + + + // The path to the "application" folder + if (is_dir($application_folder)) + { + define('APPPATH', realpath($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', realpath(BASEPATH.$application_folder) . '/'); + } + + // The path to the "views" folder + if (is_dir($view_folder)) + { + define ('VIEWPATH', $view_folder .'/'); + } + else + { + if ( ! is_dir(APPPATH.'views/')) + { + exit("Your view folder path does not appear to be set correctly. Please open the following file and correct this: ".SELF); + } + + define ('VIEWPATH', APPPATH.'views/' ); + } + + // The path to CIUnit + if (is_dir($ciunit_folder)) + { + define('CIUPATH', $ciunit_folder . '/'); + } + else + { + if ( ! is_dir(APPPATH . 'third_party/' . $ciunit_folder)) + { + exit("Your CIUnit folder path does not appear to be set correctly. Please open the following file and correct this: ".SELF); + } + + define ('CIUPATH', APPPATH . 'third_party/' . $ciunit_folder); + } + + + // The path to the Tests folder + define('TESTSPATH', realpath($tests_folder) . '/'); + +/* + * -------------------------------------------------------------------- + * LOAD THE BOOTSTRAP FILE + * -------------------------------------------------------------------- + * + * And away we go... + * + */ + +// Load the CIUnit CodeIgniter Core +require_once CIUPATH . 'core/CodeIgniter.php'; + +// Autoload the PHPUnit Framework +//require_once ('PHPUnit/Autoload.php'); + +// Load the CIUnit Framework +require_once CIUPATH. 'libraries/CIUnit.php'; + +//=== and off we go === +$CI =& set_controller('CIU_Controller', CIUPATH . 'core/'); +$CI->load->add_package_path(CIUPATH); + +require_once(CIUPATH . 'libraries/spyc/spyc.php'); + +CIUnit::$spyc = new Spyc(); + +require_once(CIUPATH . 'libraries/Fixture.php'); + +$CI->fixture = new Fixture(); +CIUnit::$fixture =& $CI->fixture; + +/* End of file bootstrap_phpunit.php */ +/* Location: ./application/third_party/CIUnit/bootstrap_phpunit.php */ \ No newline at end of file diff --git a/application/third_party/CIUnit/config/config.php b/application/third_party/CIUnit/config/config.php new file mode 100755 index 0000000..20bfd72 --- /dev/null +++ b/application/third_party/CIUnit/config/config.php @@ -0,0 +1,13 @@ +load->database('test'); + } + + public function index() + { + return; + } + +} + +/* End of file CIU_Controller.php */ +/* Location: ./application/third_party/CIUnit/core/CIU_Controller.php */ \ No newline at end of file diff --git a/application/third_party/CIUnit/core/CIU_Exceptions.php b/application/third_party/CIUnit/core/CIU_Exceptions.php new file mode 100755 index 0000000..cdccfe1 --- /dev/null +++ b/application/third_party/CIUnit/core/CIU_Exceptions.php @@ -0,0 +1,137 @@ +levels[$severity])) ? $severity : $this->levels[$severity]; + + log_message('error', 'Severity: '.$severity.' --> '.$message. ' '.$filepath.' '.$line, TRUE); + } + + // -------------------------------------------------------------------- + + /** + * 404 Page Not Found Handler + * + * @access private + * @param string + * @return string + */ + function show_404($page = '', $log_error = TRUE) + { + $heading = "404 Page Not Found"; + $message = "The page you requested was not found."; + + // By default we log this, but allow a dev to skip it + if ($log_error) + { + log_message('error', '404 Page Not Found --> '.$page); + } + + echo $this->show_error($heading, $message, 'error_404', 404); + exit; + } + + // -------------------------------------------------------------------- + + /** + * General Error Page + * + * This function takes an error message as input + * (either as a string or an array) and displays + * it using the specified template. + * + * @access private + * @param string the heading + * @param string the message + * @param string the template name + * @return string + */ + function show_error($heading, $message, $template = 'error_general', $status_code = 500) + { + $message = implode(' ', ( ! is_array($message)) ? array($message) : $message); + + if (ob_get_level() > $this->ob_level + 1) + { + ob_end_flush(); + } + + echo "[CIUnit] Error: $status_code Message: $message\n"; + return; + } + + // -------------------------------------------------------------------- + + /** + * Native PHP error handler + * + * @access private + * @param string the error severity + * @param string the error string + * @param string the error filepath + * @param string the error line number + * @return string + */ + function show_php_error($severity, $message, $filepath, $line) + { + $severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity]; + + $filepath = str_replace("\\", "/", $filepath); + + // For safety reasons we do not show the full file path + if (FALSE !== strpos($filepath, '/')) + { + $x = explode('/', $filepath); + $filepath = $x[count($x)-2].'/'.end($x); + } + + if (ob_get_level() > $this->ob_level + 1) + { + ob_end_flush(); + } + + echo "[CIUnit] PHP Error: $severity - $message File Path: $filepath (line: $line)\n"; + } + + +} + +/* End of file CIU_Exceptions.php */ +/* Location: ./application/third_party/CIUnit/core/CIU_Exceptions.php */ \ No newline at end of file diff --git a/application/third_party/CIUnit/core/CIU_Loader.php b/application/third_party/CIUnit/core/CIU_Loader.php new file mode 100755 index 0000000..453a9d6 --- /dev/null +++ b/application/third_party/CIUnit/core/CIU_Loader.php @@ -0,0 +1,437 @@ +_ci_loaded_files)) + { + // Before we deem this to be a duplicate request, let's see + // if a custom object name is being supplied. If so, we'll + // return a new instance of the object + if ( ! is_null($object_name)) + { + $CI =& get_instance(); + if ( ! isset($CI->$object_name)) + { + return $this->_ci_init_class($class, config_item('ciu_subclass_prefix'), $params, $object_name); + } + } + + $is_duplicate = TRUE; + log_message('debug', $class." class already loaded. Second attempt ignored."); + return; + } + + include_once($baseclass); + + if (file_exists($subclass)) + { + include_once($subclass); + } + + include_once($ciu_subclass); + $this->_ci_loaded_files[] = $ciu_subclass; + + return $this->_ci_init_class($class, config_item('ciu_subclass_prefix'), $params, $object_name); + } + + // Is this a class extension request? + if (file_exists($subclass)) + { + $baseclass = BASEPATH.'libraries/'.ucfirst($class).'.php'; + + if ( ! file_exists($baseclass)) + { + log_message('error', "Unable to load the requested class: ".$class); + show_error("Unable to load the requested class: ".$class); + } + + // Safety: Was the class already loaded by a previous call? + if (in_array($subclass, $this->_ci_loaded_files)) + { + // Before we deem this to be a duplicate request, let's see + // if a custom object name is being supplied. If so, we'll + // return a new instance of the object + if ( ! is_null($object_name)) + { + $CI =& get_instance(); + if ( ! isset($CI->$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($subclass); + $this->_ci_loaded_files[] = $subclass; + + 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; + foreach ($this->_ci_library_paths as $path) + { + $filepath = $path.'libraries/'.$subdir.$class.'.php'; + + // 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)) + { + // Before we deem this to be a duplicate request, let's see + // if a custom object name is being supplied. If so, we'll + // return a new instance of the object + if ( ! is_null($object_name)) + { + $CI =& get_instance(); + if ( ! isset($CI->$object_name)) + { + 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? + if ($subdir == '') + { + $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) + { + log_message('error', "Unable to load the requested class: ".$class); + show_error("Unable to load the requested class: ".$class); + } + } + + // -------------------------------------------------------------------- + + /** + * Instantiates a class + * + * @param string + * @param string + * @param string an optional object name + * @return null + */ + protected function _ci_init_class($class, $prefix = '', $config = FALSE, $object_name = NULL) + { + // Is there an associated config file for this class? Note: these should always be lowercase + if ($config === NULL) + { + // Fetch the config paths containing any package paths + $config_component = $this->_ci_get_component('config'); + + if (is_array($config_component->_config_paths)) + { + // 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. Check for environment + // first, global next + if (defined('ENVIRONMENT') AND file_exists($path .'config/'.ENVIRONMENT.'/'.strtolower($class).'.php')) + { + include($path .'config/'.ENVIRONMENT.'/'.strtolower($class).'.php'); + break; + } + elseif (defined('ENVIRONMENT') AND file_exists($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php')) + { + include($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php'); + break; + } + elseif (file_exists($path .'config/'.strtolower($class).'.php')) + { + include($path .'config/'.strtolower($class).'.php'); + break; + } + elseif (file_exists($path .'config/'.ucfirst(strtolower($class)).'.php')) + { + include($path .'config/'.ucfirst(strtolower($class)).'.php'); + break; + } + } + } + } + + if ($prefix == '') + { + if (class_exists('CI_'.$class)) + { + $name = 'CI_'.$class; + } + elseif (class_exists(config_item('subclass_prefix').$class)) + { + $name = config_item('subclass_prefix').$class; + } + else + { + $name = $class; + } + } + else + { + $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]; + } + else + { + $classvar = $object_name; + } + + // Save the class name and object name + $this->_ci_classes[$class] = $classvar; + // Instantiate the class + $CI =& get_instance(); + if ($config !== NULL) + { + if ( ! defined('CIUnit_Version')) + { + $CI->$classvar = new $name($config); + } + elseif ( ! isset($CI->$classvar)) + { + //redesignme: check if we have got one already.. + $CI->$classvar = new $name($config); + } + } + else + { + if ( ! defined('CIUnit_Version')) + { + $CI->$classvar = new $name; + } + elseif ( ! isset($CI->$classvar)) + { + //redesignme: check if we have got one already.. + $CI->$classvar = new $name; + } + } + } + + // -------------------------------------------------------------------- + + /** + * Load View + * + * This function is used to load a "view" file. It has three parameters: + * + * 1. The name of the "view" file to be included. + * 2. An associative array of data to be extracted for use in the view. + * 3. TRUE/FALSE - whether to return the data or load it. In + * some cases it's advantageous to be able to return data so that + * a developer can process it in some way. + * + * @param string + * @param array + * @param bool + * @return void + */ + public function view($view, $vars = array(), $return = FALSE) + { + if ($return === TRUE) + { + return parent::view($view, $vars, $return); + } + + $output = $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => TRUE)); + $CI =& get_instance(); + $CI->output->add_output($output); + } + + // -------------------------------------------------------------------- + + /** + * Load Helper + * + * This function loads the specified helper file. + * + * @param mixed + * @return void + */ + public function helper($helpers = array()) + { + foreach ($this->_ci_prep_filename($helpers, '_helper') as $helper) + { + if (isset($this->_ci_helpers[$helper])) + { + continue; + } + + $ciu_helper = CIUPATH.'helpers/'.config_item('ciu_subclass_prefix').$helper.'.php'; + + if (file_exists($ciu_helper)) + { + include_once($ciu_helper); + } + + $ext_helper = APPPATH.'helpers/'.config_item('subclass_prefix').$helper.'.php'; + + // Is this a helper extension request? + if (file_exists($ext_helper)) + { + $base_helper = BASEPATH.'helpers/'.$helper.'.php'; + + if ( ! file_exists($base_helper)) + { + show_error('Unable to load the requested file: helpers/'.$helper.'.php'); + } + + include_once($ext_helper); + include_once($base_helper); + + $this->_ci_helpers[$helper] = TRUE; + log_message('debug', 'Helper loaded: '.$helper); + continue; + } + + // Try to load the helper + foreach ($this->_ci_helper_paths as $path) + { + if (file_exists($path.'helpers/'.$helper.'.php')) + { + include_once($path.'helpers/'.$helper.'.php'); + + $this->_ci_helpers[$helper] = TRUE; + log_message('debug', 'Helper loaded: '.$helper); + break; + } + } + + // unable to load the helper + if ( ! isset($this->_ci_helpers[$helper])) + { + show_error('Unable to load the requested file: helpers/'.$helper.'.php'); + } + } + } + + // -------------------------------------------------------------------- + + /* + * Can load a view file from an absolute path and + * relative to the CodeIgniter index.php file + * Handy if you have views outside the usual CI views dir + */ + function viewfile($viewfile, $vars = array(), $return = FALSE) + { + return $this->_ci_load( + array('_ci_path' => $viewfile, + '_ci_vars' => $this->_ci_object_to_array($vars), + '_ci_return' => $return) + ); + } + + // -------------------------------------------------------------------- + + function reset() + { + $this->_ci_cached_vars = array(); + $this->_ci_classes = array(); + $this->_ci_loaded_files = array(); + $this->_ci_models = array(); + $this->_ci_helpers = array(); + } +} + +/* End of file CIU_Loader.php */ +/* Location: ./application/third_party/CIUnit/core/CIU_Loader.php */ \ No newline at end of file diff --git a/application/third_party/CIUnit/core/CIU_Output.php b/application/third_party/CIUnit/core/CIU_Output.php new file mode 100755 index 0000000..70d5ee6 --- /dev/null +++ b/application/third_party/CIUnit/core/CIU_Output.php @@ -0,0 +1,290 @@ +final_output = ''; //would be just set to 'null' in CI_Output + $this->_ci_ob_level = ob_get_level(); + $this->cookies = array(); + } + + /** + * store cookie headers + */ + function set_cookie($arr) + { + if ( ! is_array($arr)) + { + $arr = func_get_args(); + } + $this->cookies[] = $arr; + } + + /** + * Add to instead of replace final output + */ + function add_output($str) + { + $this->final_output .= $str; + } + + /** + * Pop Output + * + * The final output the output class has stringed together is returned and truncated + * + */ + function pop_output() + { + $output = $this->final_output; + $this->final_output = ""; + return $output; + } + + /** + * set_no_cache_headers + * called as a post controller construction hook + * should count therefore as controller duty + */ + function set_no_cache_headers() + { + //somehow $this can't be used as headers are not set in that case + $CI =& get_instance(); + $CI->output->soft_set_header('Content-type: text/html; charset=utf-8'); + $CI->output->soft_set_header('Cache-Control: no-cache'); + log_message('debug', 'no cache headers set in output class'); + } + + // -------------------------------------------------------------------- + + /** + * sets headers if not already set + */ + function soft_set_header($header) + { + $key = strtolower(array_shift(split(':', $header))); + $add = true; + foreach($this->headers as $hdr) + { + $h = split(':', $hdr); + if(strtolower(array_shift($h)) == $key) + { + $add = false; + } + } + $add ? ($this->headers[] = $header) : ''; + } + + /** + * get headers + */ + function get_headers() + { + return $this->headers; + } + + /** + * say + * like normal echo but puts it in the output_buffer first, so we still can set headers + * and post process it + */ + function say($str) + { + ob_start(); + echo $str; + $this->ob_flush_clean(); + } + + /** + * ob_flush_clean + * flushes or cleans the buffer depending on if we are finished outputting or still on a nested level + */ + function ob_flush_clean() + { + $CI =& get_instance(); + if (ob_get_level() > $this->_ci_ob_level + 1) + { + ob_end_flush(); + } + else + { + $this->add_output(ob_get_contents()); + @ob_end_clean(); + } + } + + /** + * Display Output + * + * All "view" data is automatically put into this variable by the controller class: + * + * $this->final_output + * + * This function sends the finalized output data to the browser along + * with any server headers and profile data. It also stops the + * benchmark timer so the page rendering speed and memory usage can be shown. + * + * @access public + * @return mixed + */ + function _display($output = '') + { + // Note: We use globals because we can't use $CI =& get_instance() + // since this function is sometimes called by the caching mechanism, + // which happens before the CI super object is available. + global $BM, $CFG; + + // Grab the super object if we can. + if (class_exists('CI_Controller')) + { + $CI =& get_instance(); + } + + // -------------------------------------------------------------------- + + // Set the output data + if ($output == '') + { + $output =& $this->final_output; + } + + // -------------------------------------------------------------------- + + // Do we need to write a cache file? Only if the controller does not have its + // own _output() method and we are not dealing with a cache file, which we + // can determine by the existence of the $CI object above + if ($this->cache_expiration > 0 && isset($CI) && ! method_exists($CI, '_output')) + { + $this->_write_cache($output); + } + + // -------------------------------------------------------------------- + + // Parse out the elapsed time and memory usage, + // then swap the pseudo-variables with the data + + $elapsed = $BM->elapsed_time('total_execution_time_start', 'total_execution_time_end'); + + if ($this->parse_exec_vars === TRUE) + { + $memory = ( ! function_exists('memory_get_usage')) ? '0' : round(memory_get_usage()/1024/1024, 2).'MB'; + + $output = str_replace('{elapsed_time}', $elapsed, $output); + $output = str_replace('{memory_usage}', $memory, $output); + } + + // -------------------------------------------------------------------- + + // Is compression requested? + if ($CFG->item('compress_output') === TRUE && $this->_zlib_oc == FALSE) + { + if (extension_loaded('zlib')) + { + if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) AND strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE) + { + ob_start('ob_gzhandler'); + } + } + } + + // -------------------------------------------------------------------- + + // Are there any server headers to send? + if (count($this->headers) > 0) + { + foreach ($this->headers as $header) + { + @header($header[0], $header[1]); + log_message('debug', "header '$header[0], $header[1]' set."); + } + } + + // -------------------------------------------------------------------- + + // Are there any cookies to set? + if (count($this->cookies) > 0) + { + foreach ($this->cookies as $cookie) + { + call_user_func_array ( 'setcookie' , $cookie ); + log_message('debug', "cookie '".join(', ', $cookie)."' set."); + } + } + + + // -------------------------------------------------------------------- + + // If not we know we are dealing with a cache file so we'll + // simply echo out the data and exit. + if ( ! isset($CI)) + { + echo $output; + log_message('debug', "Final output sent to browser"); + log_message('debug', "Total execution time: ".$elapsed); + return TRUE; + } + + // -------------------------------------------------------------------- + + // Do we need to generate profile data? + // If so, load the Profile class and run it. + if ($this->enable_profiler == TRUE) + { + $CI->load->library('profiler'); + + if ( ! empty($this->_profiler_sections)) + { + $CI->profiler->set_sections($this->_profiler_sections); + } + + // If the output data contains closing and tags + // we will remove them and add them back after we insert the profile data + if (preg_match("|.*?|is", $output)) + { + $output = preg_replace("|.*?|is", '', $output); + $output .= $CI->profiler->run(); + $output .= ''; + } + else + { + $output .= $CI->profiler->run(); + } + } + + // -------------------------------------------------------------------- + + // Does the controller contain a function named _output()? + // If so send the output there. Otherwise, echo it. + if (method_exists($CI, '_output')) + { + $CI->_output($output); + } + else + { + echo $output; // Send it to the browser! + } + + log_message('debug', "Final output sent to browser"); + log_message('debug', "Total execution time: ".$elapsed); + } + + // -------------------------------------------------------------------- +} + +/* End of file CIU_Output.php */ +/* Location: ./application/third_party/CIUnit/core/CIU_Output.php */ \ No newline at end of file diff --git a/application/third_party/CIUnit/core/CodeIgniter.php b/application/third_party/CIUnit/core/CodeIgniter.php new file mode 100755 index 0000000..e41ddee --- /dev/null +++ b/application/third_party/CIUnit/core/CodeIgniter.php @@ -0,0 +1,419 @@ + $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'); + $GLOBALS['BM'] =& $BM; + + $BM->mark('total_execution_time_start'); + $BM->mark('loading_time:_base_classes_start'); + +/* + * ------------------------------------------------------ + * Instantiate the hooks class + * ------------------------------------------------------ + */ + $EXT =& load_class('Hooks', 'core'); + $GLOBALS['EXT'] =& $EXT; + +/* + * ------------------------------------------------------ + * Is there a "pre_system" hook? + * ------------------------------------------------------ + */ + $EXT->_call_hook('pre_system'); + +/* + * ------------------------------------------------------ + * Instantiate the config class + * ------------------------------------------------------ + */ + $CFG =& load_class('Config', 'core'); + $GLOBALS['CFG'] =& $CFG; + + // 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'); + $GLOBALS['UNI'] =& $UNI; + +/* + * ------------------------------------------------------ + * Instantiate the URI class + * ------------------------------------------------------ + */ + $URI =& load_class('URI', 'core'); + $GLOBALS['URI'] =& $URI; + +/* + * ------------------------------------------------------ + * Instantiate the routing class and set the routing + * ------------------------------------------------------ + */ + $RTR =& load_class('Router', 'core'); + $GLOBALS['RTR'] =& $RTR; + //$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'); + $GLOBALS['OUT'] =& $OUT; + +/* + * ------------------------------------------------------ + * Is there a valid cache file? If so, we're done... + * ------------------------------------------------------ + */ + // I am not going to worry about a cache, right? + /* + if ($EXT->_call_hook('cache_override') === FALSE) + { + if ($OUT->_display_cache($CFG, $URI) == TRUE) + { + exit; + } + } + */ + +/* + * ----------------------------------------------------- + * Load the security class for xss and csrf support + * ----------------------------------------------------- + */ + $SEC =& load_class('Security', 'core'); + $GLOBALS['SEC'] =& $SEC; + +/* + * ------------------------------------------------------ + * Load the Input class and sanitize globals + * ------------------------------------------------------ + */ + $IN =& load_class('Input', 'core'); + $GLOBALS['IN'] =& $IN; + +/* + * ------------------------------------------------------ + * Load the Language class + * ------------------------------------------------------ + */ + $LANG =& load_class('Lang', 'core'); + +/* + * ------------------------------------------------------ + * Load the app controller and local controller + * ------------------------------------------------------ + * + */ + // Load the base controller class + require BASEPATH.'core/Controller.php'; + + function &get_instance() + { + return CI_Controller::get_instance(); + } + + + if (file_exists(APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php')) + { + require APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php'; + } + +if (defined('CIUnit_Version') === FALSE) +{ + // Load the local application controller + // Note: The Router class automatically validates the controller path using the router->_validate_request(). + // If this include fails it means that the default controller in the Routes.php file is not resolving to something valid. + if ( ! file_exists(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().'.php')) + { + show_error('Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.'); + } + + include(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().'.php'); + + // Set a mark point for benchmarking + $BM->mark('loading_time:_base_classes_end'); + +/* + * ------------------------------------------------------ + * Security check + * ------------------------------------------------------ + * + * None of the functions in the app controller or the + * loader class can be called via the URI, nor can + * controller functions that begin with an underscore + */ + $class = $RTR->fetch_class(); + $method = $RTR->fetch_method(); + + if ( ! class_exists($class) + OR strncmp($method, '_', 1) == 0 + OR in_array(strtolower($method), array_map('strtolower', get_class_methods('CI_Controller'))) + ) + { + if ( ! empty($RTR->routes['404_override'])) + { + $x = explode('/', $RTR->routes['404_override']); + $class = $x[0]; + $method = (isset($x[1]) ? $x[1] : 'index'); + if ( ! class_exists($class)) + { + if ( ! file_exists(APPPATH.'controllers/'.$class.'.php')) + { + show_404("{$class}/{$method}"); + } + + include_once(APPPATH.'controllers/'.$class.'.php'); + } + } + else + { + show_404("{$class}/{$method}"); + } + } + +/* + * ------------------------------------------------------ + * Is there a "pre_controller" hook? + * ------------------------------------------------------ + */ + $EXT->_call_hook('pre_controller'); + +/* + * ------------------------------------------------------ + * Instantiate the requested controller + * ------------------------------------------------------ + */ + // Mark a start point so we can benchmark the controller + $BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_start'); + + $CI = new $class(); + +/* + * ------------------------------------------------------ + * Is there a "post_controller_constructor" hook? + * ------------------------------------------------------ + */ + $EXT->_call_hook('post_controller_constructor'); + +/* + * ------------------------------------------------------ + * Call the requested method + * ------------------------------------------------------ + */ + // Is there a "remap" function? If so, we call it instead + if (method_exists($CI, '_remap')) + { + $CI->_remap($method, array_slice($URI->rsegments, 2)); + } + else + { + // is_callable() returns TRUE on some versions of PHP 5 for private and protected + // methods, so we'll use this workaround for consistent behavior + if ( ! in_array(strtolower($method), array_map('strtolower', get_class_methods($CI)))) + { + // Check and see if we are using a 404 override and use it. + if ( ! empty($RTR->routes['404_override'])) + { + $x = explode('/', $RTR->routes['404_override']); + $class = $x[0]; + $method = (isset($x[1]) ? $x[1] : 'index'); + if ( ! class_exists($class)) + { + if ( ! file_exists(APPPATH.'controllers/'.$class.'.php')) + { + show_404("{$class}/{$method}"); + } + + include_once(APPPATH.'controllers/'.$class.'.php'); + unset($CI); + $CI = new $class(); + } + } + else + { + show_404("{$class}/{$method}"); + } + } + + // Call the requested method. + // Any URI segments present (besides the class/function) will be passed to the method for convenience + call_user_func_array(array(&$CI, $method), array_slice($URI->rsegments, 2)); + } + + + // Mark a benchmark end point + $BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_end'); + +/* + * ------------------------------------------------------ + * Is there a "post_controller" hook? + * ------------------------------------------------------ + */ + $EXT->_call_hook('post_controller'); + +/* + * ------------------------------------------------------ + * Send the final rendered output to the browser + * ------------------------------------------------------ + */ + if ($EXT->_call_hook('display_override') === FALSE) + { + $OUT->_display(); + } + +/* + * ------------------------------------------------------ + * Is there a "post_system" hook? + * ------------------------------------------------------ + */ + $EXT->_call_hook('post_system'); + +/* + * ------------------------------------------------------ + * Close the DB connection if one exists + * ------------------------------------------------------ + */ + if (class_exists('CI_DB') AND isset($CI->db)) + { + $CI->db->close(); + } +} + + +/* End of file CodeIgniter.php */ +/* Location: ./application/third_party/CIUnit/core/CodeIgniter.php */ \ No newline at end of file diff --git a/application/third_party/CIUnit/core/Common.php b/application/third_party/CIUnit/core/Common.php new file mode 100755 index 0000000..6fefb10 --- /dev/null +++ b/application/third_party/CIUnit/core/Common.php @@ -0,0 +1,188 @@ + 0) + { + foreach ($replace as $key => $val) + { + if (isset($config[$key])) + { + $config[$key] = $val; + } + } + } + + return $_config[0] =& $config; + } +} + +/* End of file Common.php */ +/* Location: ./application/third_party/CIUnit/core/Common.php */ \ No newline at end of file diff --git a/application/third_party/CIUnit/core/README.txt b/application/third_party/CIUnit/core/README.txt new file mode 100755 index 0000000..0866757 --- /dev/null +++ b/application/third_party/CIUnit/core/README.txt @@ -0,0 +1,3 @@ +Overwriting some of the CodeIgniter base functionality. + +CLI is just different. \ No newline at end of file diff --git a/application/third_party/CIUnit/helpers/CIU_url_helper.php b/application/third_party/CIUnit/helpers/CIU_url_helper.php new file mode 100755 index 0000000..04fe7a5 --- /dev/null +++ b/application/third_party/CIUnit/helpers/CIU_url_helper.php @@ -0,0 +1,62 @@ +set_header("Refresh:0;url=".$uri); + break; + default : $GLOBALS['OUT']->set_header("Location: ".$uri, TRUE, $http_response_code); + break; + } + } +} + +/* End of file CIU_url_helper.php */ +/* Location: ./application/third_party/CIUnit/helpers/CIU_url_helper.php */ \ No newline at end of file diff --git a/application/third_party/CIUnit/index.html b/application/third_party/CIUnit/index.html new file mode 100755 index 0000000..233ae63 --- /dev/null +++ b/application/third_party/CIUnit/index.html @@ -0,0 +1,15 @@ + + + + +403 Forbidden + + + + + +

    Directory access is forbidden.

    + + + + \ No newline at end of file diff --git a/application/third_party/CIUnit/libraries/CIU_Session.php b/application/third_party/CIUnit/libraries/CIU_Session.php new file mode 100755 index 0000000..3fe576e --- /dev/null +++ b/application/third_party/CIUnit/libraries/CIU_Session.php @@ -0,0 +1,82 @@ +sess_use_database === TRUE AND isset($this->userdata['session_id'])) + { + $this->CI->db->where('session_id', $this->userdata['session_id']); + $this->CI->db->delete($this->sess_table_name); + } + + // Kill the cookie: modified for CIUnit + $array = array( + $this->sess_cookie_name, + addslashes(serialize(array())), + ($this->now - 31500000), + $this->cookie_path, + $this->cookie_domain, + 0 + ); + $this->CI->output->set_cookie($array); + } + + // -------------------------------------------------------------------- + + /** + * Write the session cookie + * + * @access public + * @return void + */ + function _set_cookie($cookie_data = NULL) + { + if (is_null($cookie_data)) + { + $cookie_data = $this->userdata; + } + + // Serialize the userdata for the cookie + $cookie_data = $this->_serialize($cookie_data); + + if ($this->sess_encrypt_cookie == TRUE) + { + $cookie_data = $this->CI->encrypt->encode($cookie_data); + } + else + { + // if encryption is not used, we provide an md5 hash to prevent userside tampering + $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: modified for CIUnit + $array = array( + $this->sess_cookie_name, + $cookie_data, + $expire, + $this->cookie_path, + $this->cookie_domain, + $this->cookie_secure + ); + $this->CI->output->set_cookie($array); + } +} + +/* End of file CIU_Session.php */ +/* Location: ./application/third_party/CIUnit/libraries/CIU_Session.php */ \ No newline at end of file diff --git a/application/third_party/CIUnit/libraries/CIUnit.php b/application/third_party/CIUnit/libraries/CIUnit.php new file mode 100755 index 0000000..4e94bcd --- /dev/null +++ b/application/third_party/CIUnit/libraries/CIUnit.php @@ -0,0 +1,256 @@ +CI = set_controller('controller_to_test'); +* to set a different CI controller active +* +* use your controller functions simply like: +* $this->CI->function(); +* +* created browser output is accessible like so +* $output = output(); +* this function yields only once and is then reset to an empty string +* +* template vars like so: +* $vars = viewvars(); +* they are also reset after this call +*/ +class CIUnit { + + private static $instance; + + public static $controller; + public static $current; + public static $controllers = array(); + + public static $spyc; + public static $fixture; + + /** + * If this class is suppose to be a Singleton shouldn't the constructor be private? + * Correct me if I am wrong but this doesn't prevent multiple instances of this class. + */ + public function __construct() + { + self::$instance =& $this; + } + + public function &get_CIU() + { + return self::$instance; + } + + public static function &set_controller($controller = 'CI_Controller', $path = FALSE) + { + $controller_name = array_pop(explode('/', $controller)); + //echo "\nc name ".$controller_name; + //is it the current controller? + if ($controller_name == self::$current) + { + //we have nothing to do, return current controller + //echo "current found!"; die(); + output(); + viewvars(); + return self::$controller; + } + + // the current controller must be archieved before littered + $loader =& load_class('Loader', 'core'); + + // reset all loaded data + $loader->reset(); + + //echo 'Var Dump of self::$controllers -- '; + //var_dump(self::$controllers); + + /* + ========================================================= + I don't understand this section of code. + self::$controllers[self::$current] is never set when testing + models. Maybe it will be set when testing controllers? + ========================================================= + if (isset(self::$controllers[self::$current])) + { + self::$controllers[self::$current]['models'] = $loader->_ci_models; + //this might be an update if it was there before + // FIXME, all additional properties of the loader / controllers + // that have to be reset must go in some test config file.. + //'components' => $loader->_ci_components, + //'classes' => $loader->_ci_classes + } + + =================================================== + I don't understand why this code is clearing out + all the loaded components such as autoloaded models + -- this is very frustrating + ================================================== + //clean up the current controllers mess + //reset models + $loader->_ci_models = array(); + //reset components + //$loader->_ci_components = array(); + //reset saved queries + self::$controller->db->queries = array(); + */ + + //clean output / viewvars as well; + if (isset(self::$controller->output)) + { + output(); + viewvars(); + } + + //the requested controller was loaded before? + if (isset(self::$controllers[$controller_name])) + { + //echo "saved found! $controller_name"; + //load it + $old =& self::$controllers[$controller_name]; + self::$controller =& $old['address']; + self::$current = $controller_name; + //$loader->_ci_models = $old['models']; + //$loader->_ci_components = $old['components']; + //$loader->_ci_classes = &$old['classes']; + } + else + { + //echo "load new $controller_name"; + //it was not loaded before + if ( ! class_exists($controller_name)) + { + if ($path && file_exists($path . $controller . EXT)) + { + include_once($path . $controller . EXT); + } + else + { + include_once(APPPATH . 'controllers/' . $controller . EXT); + } + } + + self::$current = $controller_name; + self::$controllers[$controller_name] = array( + 'address' => new $controller_name(), + 'models' => array() + ); + self::$controller =& self::$controllers[$controller_name]['address']; + } + +// var_dump(self::$controllers); die(); + + +// var_dump(self::$controller); die(); + + //CI_Base::$instance = &self::$controller; //so get_instance() provides the correct controller + return self::$controller; + } + + + public static function &get_controller() + { + return self::$controller; + } + + /** + * get filenames eg for running test suites + * $path is relative + */ + public static function files($pattern, $path = ".", $addpath = FALSE) + { + // Swap directory separators to Unix style for consistency + $path = str_replace("\\", "/", $path); + + if (substr($path, -1) !== "/") + { + $path .= "/"; + } + + $dir_handle = @opendir($path) or die("Unable to open $path"); + $outarr = array(); + + while ( false != ($file = readdir($dir_handle)) ) + { + if (preg_match($pattern, $file)) + { + if ($addpath) + { + $file = $path . $file; + } + $outarr[] = $file; + } + } + //could also use preg_grep! + closedir($dir_handle); + return $outarr; + } +} + +//=== convenience functions === +// instead of referring to CIUnit directly + +/** +* retrieves current CIUnit Class Singleton +*/ +function &get_CIU() +{ + return CIUnit::get_CIU(); +} + +/** +* sets CI controller +*/ +function &set_controller($controller = 'CI_Controller', $path = FALSE) +{ + return CIUnit::set_controller($controller, $path); +} + +/** +* retrieves current CI controller from CIUnit +*/ +function &get_controller() +{ + return CIUnit::get_controller(); +} + +/** +* retrieves the cached output from the output class +* and resets it +*/ +function output() +{ + return CIUnit::$controller->output->pop_output(); +} + +/** +* retrieves the cached template vars from the loader class (stored here for assignment to views) +* and resets them +*/ +function viewvars() +{ + if( isset(CIUnit::$controller->load->_ci_cached_vars) ) + { + $out = CIUnit::$controller->load->_ci_cached_vars; + CIUnit::$controller->load->_ci_cached_vars = array(); + return $out; + } + return array(); +} + +/* End of file CIUnit.php */ +/* Location: ./application/third_party/CIUnit/libraries/CIUnit.php */ \ No newline at end of file diff --git a/application/third_party/CIUnit/libraries/CIUnitTestCase.php b/application/third_party/CIUnit/libraries/CIUnitTestCase.php new file mode 100755 index 0000000..ffad1c6 --- /dev/null +++ b/application/third_party/CIUnit/libraries/CIUnitTestCase.php @@ -0,0 +1,222 @@ + 'group', + * 'user' => 'user', + * 'user_group' => 'user_group' + * 'table_a' => 'table_a_01' + * ); + * + * Note: To test different data scenarios for a single database, create + * different fixtures. + * + * For example: + * $tables = array( + * 'table_a' => 'table_a_02' + * ); + * + * @var array + */ + protected $tables = array(); + + // ------------------------------------------------------------------------ + + /** + * The CodeIgniter Framework Instance + * + * @var object + */ + public $CI; + + // ------------------------------------------------------------------------ + + /** + * Constructor + * + * @param string $name + * @param array $data + * @param string $dataName + */ + public function __construct($name = NULL, array $data = array(), $dataName = '') + { + parent::__construct($name, $data, $dataName); + $this->CI =& get_instance(); + + log_message('debug', get_class($this).' CIUnit_TestCase initialized'); + } + + /** + * Set Up + * + * This method will run before every test. + * + * @return void + * + * @author Eric Jones + */ + protected function setUp() + { + // Only run if the $tables attribute is set. + if ( ! empty($this->tables)) + { + $this->dbfixt($this->tables); + } + } + + /** + * Tear Down + * + * This method will run after every test. + * + * @return void + * + * @author Eric Jones + */ + protected function tearDown() + { + // Only run if the $tables attribute is set. + if ( ! empty($this->tables)) + { + $this->dbfixt_unload($this->tables); + } + } + + /** + * loads a database fixture + * for each given fixture, we look up the yaml file and insert that into the corresponding table + * names are by convention + * 'users' -> look for 'users_fixt.yml' fixture: 'fixtures/users_fixt.yml' + * table is assumed to be named 'users' + * dbfixt can have multiple strings as arguments, like so: + * $this->dbfixt('users', 'items', 'prices'); + */ + protected function dbfixt($table_fixtures) + { + if (is_array($table_fixtures)) + { + $this->load_fixt($table_fixtures); + } + else + { + $table_fixtures = func_get_args(); + $this->load_fixt($table_fixtures); + } + + /** + * This is to allow the Unit Tester to specifiy different fixutre files for + * a given table. An example would be the testing of two different senarios + * of data in the database. + * + * @see CIUnitTestCase::tables + */ + foreach($table_fixtures as $table => $fixt ) + { + $fixt_name = $fixt . '_fixt'; + $table = is_int($table) ? $fixt : $table; + + if (!empty($this->$fixt_name)) + { + CIUnit::$fixture->load($table, $this->$fixt_name); + } + else + { + die("The fixture {$fixt_name} failed to load properly\n"); + } + + } + + log_message('debug', 'Table fixtures "' . join('", "', $table_fixtures) . '" loaded'); + } + + /** + * DBFixt Unload + * + * Since there may be foreign key dependencies in the database, we can't just + * truncate tables in random order. This method attempts to truncate the + * tables by reversing the order of the $table attribute. + * + * @param array $table_fixtures Typically this will be the class attribute $table. + * @param boolean $reverse Should the method reverse the $table_fixtures array + * before the truncating the tables? + * + * @return void + * + * @see CIUnitTestCase::table + * + * @uses CIUnit::fixture + * @uses Fixture::unload() + * + * @author Eric Jones + */ + protected function dbfixt_unload(array $table_fixtures, $reverse = true) + { + // Should we reverse the order of loading? + // Helps with truncating tables with foreign key dependencies. + if ($reverse) + { + // Since the loading of tables took into account foreign key + // dependencies we should be able to just reverse the order + // of the database load. Right?? + $table_fixtures = array_reverse($table_fixtures, true); + } + + // Iterate over the array unloading the tables + foreach ($table_fixtures as $table => $fixture) + { + CIUnit::$fixture->unload($table); + log_message('debug', 'Table fixture "' . $fixture . '" unloaded'); + } + } + + /** + * fixture wrapper, for arbitrary number of arguments + */ + function fixt() + { + $fixts = func_get_args(); + $this->load_fixt($fixts); + } + + /** + * loads a fixture from a yaml file + */ + protected function load_fixt($fixts) + { + foreach ( $fixts as $fixt ) + { + $fixt_name = $fixt . '_fixt'; + + if (file_exists(TESTSPATH . 'fixtures/' . $fixt . '_fixt.yml')) { + $this->$fixt_name = CIUnit::$spyc->loadFile(TESTSPATH . 'fixtures/' . $fixt . '_fixt.yml'); + } + else + { + die('The file '. TESTSPATH . 'fixtures/' . $fixt . '_fixt.yml doesn\'t exist.'); + } + } + } +} + +/* End of file CIUnitTestCase.php */ +/* Location: ./application/third_party/CIUnit/libraries/CIUnitTestCase.php */ \ No newline at end of file diff --git a/application/third_party/CIUnit/libraries/Fixture.php b/application/third_party/CIUnit/libraries/Fixture.php new file mode 100755 index 0000000..429c82e --- /dev/null +++ b/application/third_party/CIUnit/libraries/Fixture.php @@ -0,0 +1,84 @@ +_assign_db(); + + // $fixt is supposed to be an associative array + // E.g. outputted by spyc from reading a YAML file + $this->CI->db->simple_query('truncate table ' . $table . ';'); + + if ( ! empty($fixt)) + { + $this->CI->db->insert_batch($table, $fixt); + } + + + $nbr_of_rows = sizeof($fixt); + log_message('debug', + "Data fixture for db table '$table' loaded - $nbr_of_rows rows"); + } + + public function unload($table) + { + $this->_assign_db(); + + $Q = TRUE; + //$Q = $this->CI->db->simple_query('truncate table ' . $table . ';'); + + if (!$Q) { + echo $this->CI->db->call_function('error', $this->CI->db->conn_id); + echo "\n"; + echo "Failed to truncate the table ".$table."\n\n"; + } + } + + + private function _assign_db() + { + if ( ! isset($this->CI->db) OR + ! isset($this->CI->db->database) ) + { + $this->CI =& get_instance(); + $this->CI->load->database(); + } + + //security measure 2: only load if used database ends on '_test' + $len = strlen($this->CI->db->database); + + if ( substr($this->CI->db->database, $len-5, $len) != '_test' ) + { + die("\nSorry, the name of your test database must end on '_test'.\n". + "This prevents deleting important data by accident.\n"); + } + } + +} + +/* End of file Fixture.php */ +/* Location: ./application/third_party/CIUnit/libraries/Fixture.php */ \ No newline at end of file diff --git a/application/third_party/CIUnit/libraries/Unit_test.php b/application/third_party/CIUnit/libraries/Unit_test.php new file mode 100755 index 0000000..11aefa6 --- /dev/null +++ b/application/third_party/CIUnit/libraries/Unit_test.php @@ -0,0 +1,434 @@ +_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 + * + * Runs the supplied tests + * + * @access public + * @param mixed + * @param mixed + * @param string + * @return string + */ + function run($test, $expected = TRUE, $test_name = 'undefined', $notes = '') + { + if ($this->active == FALSE) + { + return FALSE; + } + + 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; + $extype = str_replace(array('true', 'false'), 'bool', str_replace('is_', '', $expected)); + } + else + { + if ($this->strict == TRUE) + $result = ($test === $expected) ? TRUE : FALSE; + else + $result = ($test == $expected) ? TRUE : FALSE; + + $extype = gettype($expected); + } + + $back = $this->_backtrace(); + + $report[] = array ( + 'test_name' => $test_name, + 'test_datatype' => gettype($test), + 'res_datatype' => $extype, + 'result' => ($result === TRUE) ? 'passed' : 'failed', + 'file' => $back['file'], + 'line' => $back['line'], + 'notes' => $notes + ); + + $this->results[] = $report; + + return($this->report($this->result($report))); + } + + // -------------------------------------------------------------------- + + /** + * Generate a report + * + * Displays a table with the test data + * + * @access public + * @return string + */ + function report($result = array()) + { + if (count($result) == 0) + { + $result = $this->result(); + } + + $CI =& get_instance(); + + + $this->_parse_template(); + + $r = ''; + + if (php_sapi_name() !== 'cli') + { + $CI->load->language('unit_test'); + + foreach ($result as $res) + { + $table = ''; + + foreach ($res as $key => $val) + { + if ($key == $CI->lang->line('ut_result')) + { + if ($val == $CI->lang->line('ut_passed')) + { + $val = ''.$val.''; + } + elseif ($val == $CI->lang->line('ut_failed')) + { + $val = ''.$val.''; + } + } + + $temp = $this->_template_rows; + $temp = str_replace('{item}', $key, $temp); + $temp = str_replace('{result}', $val, $temp); + $table .= $temp; + } + + $r .= str_replace('{rows}', $table, $this->_template); + } + + return $r; + } + else + { + $CI->load->language('unit_test', 'english'); // force english + + $passed = 0; + $failed = 0; + $failed_test = array(); + $count = 0; + + foreach ($result as $res) + { + if ($res['Result'] == 'Passed') + { + $passed += 1; + $count += 1; + } + elseif ($res['Result'] == 'Failed') + { + $failed += 1; + $failed_test[] = $res['Test Name']; + $count += 1; + } + } + + $r1 = "Execute Unit Test!! \n\n"; + $r2 = sprintf("All:%s Passed:%s Failed:%s\n", $count, $passed, $failed); + + if (count($failed_test) > 0) + { + $r = $r1 . "\x1b[31m" . $r2 . "\x1b[0m" . sprintf("Failed Test: \n %s \n", implode("\n ", $failed_test)); + } + else + { + $r = $r1 . "\x1b[32m" . $r2 . "\x1b[0m"; + } + return $r; + } + } + + // -------------------------------------------------------------------- + + /** + * Use strict comparison + * + * Causes the evaluation to use === rather than == + * + * @access public + * @param bool + * @return null + */ + function use_strict($state = TRUE) + { + $this->strict = ($state == FALSE) ? FALSE : TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Make Unit testing active + * + * Enables/disables unit testing + * + * @access public + * @param bool + * @return null + */ + function active($state = TRUE) + { + $this->active = ($state == FALSE) ? FALSE : TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Result Array + * + * Returns the raw result data + * + * @access public + * @return array + */ + function result($results = array()) + { + $CI =& get_instance(); + + if (php_sapi_name() === 'cli') + { + $CI->load->language('unit_test', 'english'); // force english + } + else + { + $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) + { + if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$v)))) + { + $v = $line; + } + $temp[$CI->lang->line('ut_'.$k)] = $v; + } + } + else + { + if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$val)))) + { + $val = $line; + } + $temp[$CI->lang->line('ut_'.$key)] = $val; + } + } + + $retval[] = $temp; + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Set the template + * + * This lets us set the template to be used to display results + * + * @access public + * @param string + * @return void + */ + function set_template($template) + { + $this->_template = $template; + } + + // -------------------------------------------------------------------- + + /** + * Generate a backtrace + * + * This lets us show file names and line numbers + * + * @access private + * @return array + */ + function _backtrace() + { + if (function_exists('debug_backtrace')) + { + $back = debug_backtrace(); + + $file = ( ! isset($back['1']['file'])) ? '' : $back['1']['file']; + $line = ( ! isset($back['1']['line'])) ? '' : $back['1']['line']; + + return array('file' => $file, 'line' => $line); + } + return array('file' => 'Unknown', 'line' => 'Unknown'); + } + + // -------------------------------------------------------------------- + + /** + * Get Default Template + * + * @access private + * @return string + */ + function _default_template() + { + $this->_template = "\n".''; + $this->_template .= '{rows}'; + $this->_template .= "\n".'
    '; + + $this->_template_rows = "\n\t".''; + $this->_template_rows .= "\n\t\t".'{item}'; + $this->_template_rows .= "\n\t\t".'{result}'; + $this->_template_rows .= "\n\t".''; + } + + // -------------------------------------------------------------------- + + /** + * Parse Template + * + * Harvests the data within the template {pseudo-variables} + * + * @access private + * @return void + */ + function _parse_template() + { + if ( ! is_null($this->_template_rows)) + { + return; + } + + if (is_null($this->_template)) + { + $this->_default_template(); + return; + } + + if ( ! preg_match("/\{rows\}(.*?)\{\/rows\}/si", $this->_template, $match)) + { + $this->_default_template(); + return; + } + + $this->_template_rows = $match['1']; + $this->_template = str_replace($match['0'], '{rows}', $this->_template); + } + +} +// END Unit_test Class + +/** + * Helper functions to test boolean true/false + * + * + * @access private + * @return bool + */ +function is_true($test) +{ + return (is_bool($test) AND $test === TRUE) ? TRUE : FALSE; +} +function is_false($test) +{ + return (is_bool($test) AND $test === FALSE) ? TRUE : FALSE; +} + + +/* End of file Unit_test.php */ +/* Location: ./application/third_party/CIUnit/libraries/Unit_test.php */ \ No newline at end of file diff --git a/application/third_party/CIUnit/libraries/spyc/README b/application/third_party/CIUnit/libraries/spyc/README new file mode 100755 index 0000000..a8539bd --- /dev/null +++ b/application/third_party/CIUnit/libraries/spyc/README @@ -0,0 +1,159 @@ +# +# S P Y C +# a simple php yaml class +# +# Load this README! +# >> $readme = Spyc::YAMLLoad('README'); +# +--- %YAML:1.1 +title: Spyc -- a Simple PHP YAML Class +version: 0.4.5 +authors: [chris wanstrath (chris@ozmm.org), vlad andersen (vlad.andersen@gmail.com)] +websites: [http://www.yaml.org, http://spyc.sourceforge.net] +license: [MIT License, http://www.opensource.org/licenses/mit-license.php] +copyright: "(c) 2005-2006 Chris Wanstrath, 2006-2009 Vlad Andersen" +tested on: [php 5.2.x] + +installation: > + Copy spyc.php to a directory you can + access with your YAML-ready PHP script. + + That's it! + +about: > + From www.yaml.org: + + "YAML(tm) (rhymes with 'camel') is a human-friendly, cross language, + Unicode based data serialization language designed around the common + native data structures of agile programming languages. It is broadly + useful for programming needs ranging from configuration files to + Internet messaging to object persistence to data auditing. Together + with the Unicode standard for characters, the YAML specification provides + all the information necessary to understand YAML Version 1.1 and to + creating programs that process YAML information. + + YAML(tm) is a balance of the following design goals: + - YAML documents are very readable by humans. + - YAML interacts well with scripting languages. + - YAML uses host languages' native data structures. + - YAML has a consistent information model. + - YAML enables stream-based processing. + - YAML is expressive and extensible. + - YAML is easy to implement." + + YAML makes a lot of sense. It's easy to use, easy to learn, and cool. + As the lucky stiff named why once said, "YAML is a beacon of light." + + If you're new to YAML, may we suggest YAML In Five Minutes: + - http://yaml.kwiki.org/?YamlInFiveMinutes + + If you don't have five minutes, realize that this README is a completely + valid YAML document. Dig in, load this or any YAML file into an array + with Spyc and see how easy it is to translate friendly text into usable + data. + + The purpose of Spyc is to provide a pure PHP alternative to Syck, a + simple API for loading and dumping YAML documents, a YAML loader which + understands a usable subset of the YAML spec, and to further spread + the glory of YAML to the PHP masses. + + If you're at all hesitant ("usable subset of YAML?!"), navigate + http://yaml.org/start.html. Spyc completely understands the YAML + document shown there, a document which has features way beyond the + scope of what normal config files might require. Try it for yourself, + and then start enjoying the peace of mind YAML brings to your life. + +meat and a few potatoes: + - concept: Loading a YAML document into PHP + brief: > + $yaml will become an array of all the data in wicked.yaml + code: | + + include('spyc.php'); + + $yaml = Spyc::YAMLLoad('wicked.yaml'); + + - concept: Loading a YAML string into PHP + brief: > + $array will look like this: + array('A YAML','document in a','string') + code: | + + include('spyc.php'); + + $yaml = '- A YAML\n- document in a\n- string.'; + $array = Spyc::YAMLLoad($yaml); + + - concept: Dumping a PHP array to YAML + brief: > + $yaml will become a string of a YAML document created from + $array. + code: | + + include('spyc.php'); + + $array['name'] = 'chris'; + $array['sport'] = 'curbing'; + + $yaml = Spyc::YAMLDump($array); + +prior art: + - who: [Brian Ingerson, Clark Evans, Oren Ben-Kiki] + why?: > + The YAML spec is really a piece of work, and these guys + did a great job on it. A simple and elegant language like + YAML was a long time coming and it's refreshing to know + such able minded individuals took the task to heart and + executed it with cunning and strength. In addition to + their various noteworthy contributions to YAML parsers + and related projects, YAML.pm's README is a treasure trove + of information for knowledge seekers. Thanks, guys. + + - who: why the lucky stiff + why?: > + As the author of Syck, the code used in Ruby for the language's + YAML class and methods, why is indirectly (directly?) responsible + for my first exposure to YAML (as a config file in a Ruby web-app) + and the countless hours I spent playing with this sheik new data + format afterwards. Syck's README is a YAML file and thus the + inspiration for this file and, even, this very piece of software. + + - who: Steve Howell + why?: > + Python's YAML implementation. PyYAML's README file is also YAML, + so it too inspired the YAML format of this README file. + + - who: [Rasmus Lerdorf, Zeev Suraski, Andi Gutmans, et al] + why?: > + PHP is great at what it does best. It's also paid a lot of my bills. + Thanks. + +bugs: + report: > + Please see Spyc's Sourceforge project page for information on reporting bugs. + speed: > + This implementation was not designed for speed. Rather, it + was designed for those who need a pure PHP implementation of + a YAML parser and who are not overly concerned with performance. + If you want speed, check out Syck. + depth: > + This parser is by no means a comprehensive YAML parser. For supported + features and future plans, check the website. + unicode: > + YAML is supposed to be unicode, but for now we're just using ASCII. + PHP has crappy unicode support but who knows what the future holds. + +resources: + - http://www.yaml.org + - http://www.yaml.org/spec/ + - http://yaml.kwiki.org/?YamlInFiveMinutes + - http://www.whytheluckystiff.net/syck/ + - http://yaml4r.sourceforge.net/cookbook/ + +thanks: + - Adam Wood + - Daniel Ferreira + - Aaron Jensen + - Mike Thornton + - Fabien Potencier + - Mustafa Kumas \ No newline at end of file diff --git a/application/third_party/CIUnit/libraries/spyc/examples/yaml-dump.php b/application/third_party/CIUnit/libraries/spyc/examples/yaml-dump.php new file mode 100755 index 0000000..05a8a2f --- /dev/null +++ b/application/third_party/CIUnit/libraries/spyc/examples/yaml-dump.php @@ -0,0 +1,25 @@ + 'A sequence','second' => 'of mapped values'); +$array['Mapped'] = array('A sequence','which is mapped'); +$array['A Note'] = 'What if your text is too long?'; +$array['Another Note'] = 'If that is the case, the dumper will probably fold your text by using a block. Kinda like this.'; +$array['The trick?'] = 'The trick is that we overrode the default indent, 2, to 4 and the default wordwrap, 40, to 60.'; +$array['Old Dog'] = "And if you want\n to preserve line breaks, \ngo ahead!"; +$array['key:withcolon'] = "Should support this to"; + +$yaml = Spyc::YAMLDump($array,4,60); \ No newline at end of file diff --git a/application/third_party/CIUnit/libraries/spyc/examples/yaml-load.php b/application/third_party/CIUnit/libraries/spyc/examples/yaml-load.php new file mode 100755 index 0000000..3e1a4a7 --- /dev/null +++ b/application/third_party/CIUnit/libraries/spyc/examples/yaml-load.php @@ -0,0 +1,25 @@ +spyc.yaml loaded into PHP:
    '; +print_r($array); +echo ''; + + +echo '

    YAML Data dumped back:
    '; +echo Spyc::YAMLDump($array); +echo '
    '; diff --git a/application/third_party/CIUnit/libraries/spyc/php4/5to4.php b/application/third_party/CIUnit/libraries/spyc/php4/5to4.php new file mode 100755 index 0000000..2789620 --- /dev/null +++ b/application/third_party/CIUnit/libraries/spyc/php4/5to4.php @@ -0,0 +1,16 @@ +', $code); + $f = fopen ($dest, 'w'); + fwrite($f, $code); + fclose ($f); + print "Written to $dest.\n"; +} \ No newline at end of file diff --git a/application/third_party/CIUnit/libraries/spyc/php4/spyc.php4 b/application/third_party/CIUnit/libraries/spyc/php4/spyc.php4 new file mode 100755 index 0000000..73f08cc --- /dev/null +++ b/application/third_party/CIUnit/libraries/spyc/php4/spyc.php4 @@ -0,0 +1,1023 @@ + + * @author Chris Wanstrath + * @link http://code.google.com/p/spyc/ + * @copyright Copyright 2005-2006 Chris Wanstrath, 2006-2009 Vlad Andersen + * @license http://www.opensource.org/licenses/mit-license.php MIT License + * @package Spyc + */ + +if (!function_exists('spyc_load')) { + /** + * Parses YAML to array. + * @param string $string YAML string. + * @return array + */ + function spyc_load ($string) { + return Spyc::YAMLLoadString($string); + } +} + +if (!function_exists('spyc_load_file')) { + /** + * Parses YAML to array. + * @param string $file Path to YAML file. + * @return array + */ + function spyc_load_file ($file) { + return Spyc::YAMLLoad($file); + } +} + +/** + * The Simple PHP YAML Class. + * + * This class can be used to read a YAML file and convert its contents + * into a PHP array. It currently supports a very limited subsection of + * the YAML spec. + * + * Usage: + * + * $Spyc = new Spyc; + * $array = $Spyc->load($file); + * + * or: + * + * $array = Spyc::YAMLLoad($file); + * + * or: + * + * $array = spyc_load_file($file); + * + * @package Spyc + */ +class Spyc { + + // SETTINGS + + /** + * Setting this to true will force YAMLDump to enclose any string value in + * quotes. False by default. + * + * @var bool + */ + var $setting_dump_force_quotes = false; + + /** + * Setting this to true will forse YAMLLoad to use syck_load function when + * possible. False by default. + * @var bool + */ + var $setting_use_syck_is_possible = false; + + + + /**#@+ + * @access private + * @var mixed + */ + var $_dumpIndent; + var $_dumpWordWrap; + var $_containsGroupAnchor = false; + var $_containsGroupAlias = false; + var $path; + var $result; + var $LiteralPlaceHolder = '___YAML_Literal_Block___'; + var $SavedGroups = array(); + var $indent; + /** + * Path modifier that should be applied after adding current element. + * @var array + */ + var $delayedPath = array(); + + /**#@+ + * @access public + * @var mixed + */ + var $_nodeId; + +/** + * Load a valid YAML string to Spyc. + * @param string $input + * @return array + */ + function load ($input) { + return $this->__loadString($input); + } + + /** + * Load a valid YAML file to Spyc. + * @param string $file + * @return array + */ + function loadFile ($file) { + return $this->__load($file); + } + + /** + * Load YAML into a PHP array statically + * + * The load method, when supplied with a YAML stream (string or file), + * will do its best to convert YAML in a file into a PHP array. Pretty + * simple. + * Usage: + * + * $array = Spyc::YAMLLoad('lucky.yaml'); + * print_r($array); + * + * @access public + * @return array + * @param string $input Path of YAML file or string containing YAML + */ + function YAMLLoad($input) { + $Spyc = new Spyc; + return $Spyc->__load($input); + } + + /** + * Load a string of YAML into a PHP array statically + * + * The load method, when supplied with a YAML string, will do its best + * to convert YAML in a string into a PHP array. Pretty simple. + * + * Note: use this function if you don't want files from the file system + * loaded and processed as YAML. This is of interest to people concerned + * about security whose input is from a string. + * + * Usage: + * + * $array = Spyc::YAMLLoadString("---\n0: hello world\n"); + * print_r($array); + * + * @access public + * @return array + * @param string $input String containing YAML + */ + function YAMLLoadString($input) { + $Spyc = new Spyc; + return $Spyc->__loadString($input); + } + + /** + * Dump YAML from PHP array statically + * + * The dump method, when supplied with an array, will do its best + * to convert the array into friendly YAML. Pretty simple. Feel free to + * save the returned string as nothing.yaml and pass it around. + * + * Oh, and you can decide how big the indent is and what the wordwrap + * for folding is. Pretty cool -- just pass in 'false' for either if + * you want to use the default. + * + * Indent's default is 2 spaces, wordwrap's default is 40 characters. And + * you can turn off wordwrap by passing in 0. + * + * @access public + * @return string + * @param array $array PHP array + * @param int $indent Pass in false to use the default, which is 2 + * @param int $wordwrap Pass in 0 for no wordwrap, false for default (40) + */ + function YAMLDump($array,$indent = false,$wordwrap = false) { + $spyc = new Spyc; + return $spyc->dump($array,$indent,$wordwrap); + } + + + /** + * Dump PHP array to YAML + * + * The dump method, when supplied with an array, will do its best + * to convert the array into friendly YAML. Pretty simple. Feel free to + * save the returned string as tasteful.yaml and pass it around. + * + * Oh, and you can decide how big the indent is and what the wordwrap + * for folding is. Pretty cool -- just pass in 'false' for either if + * you want to use the default. + * + * Indent's default is 2 spaces, wordwrap's default is 40 characters. And + * you can turn off wordwrap by passing in 0. + * + * @access public + * @return string + * @param array $array PHP array + * @param int $indent Pass in false to use the default, which is 2 + * @param int $wordwrap Pass in 0 for no wordwrap, false for default (40) + */ + function dump($array,$indent = false,$wordwrap = false) { + // Dumps to some very clean YAML. We'll have to add some more features + // and options soon. And better support for folding. + + // New features and options. + if ($indent === false or !is_numeric($indent)) { + $this->_dumpIndent = 2; + } else { + $this->_dumpIndent = $indent; + } + + if ($wordwrap === false or !is_numeric($wordwrap)) { + $this->_dumpWordWrap = 40; + } else { + $this->_dumpWordWrap = $wordwrap; + } + + // New YAML document + $string = "---\n"; + + // Start at the base of the array and move through it. + if ($array) { + $array = (array)$array; + $first_key = key($array); + + $previous_key = -1; + foreach ($array as $key => $value) { + $string .= $this->_yamlize($key,$value,0,$previous_key, $first_key); + $previous_key = $key; + } + } + return $string; + } + + /** + * Attempts to convert a key / value array item to YAML + * @access private + * @return string + * @param $key The name of the key + * @param $value The value of the item + * @param $indent The indent of the current node + */ + function _yamlize($key,$value,$indent, $previous_key = -1, $first_key = 0) { + if (is_array($value)) { + if (empty ($value)) + return $this->_dumpNode($key, array(), $indent, $previous_key, $first_key); + // It has children. What to do? + // Make it the right kind of item + $string = $this->_dumpNode($key, NULL, $indent, $previous_key, $first_key); + // Add the indent + $indent += $this->_dumpIndent; + // Yamlize the array + $string .= $this->_yamlizeArray($value,$indent); + } elseif (!is_array($value)) { + // It doesn't have children. Yip. + $string = $this->_dumpNode($key, $value, $indent, $previous_key, $first_key); + } + return $string; + } + + /** + * Attempts to convert an array to YAML + * @access private + * @return string + * @param $array The array you want to convert + * @param $indent The indent of the current level + */ + function _yamlizeArray($array,$indent) { + if (is_array($array)) { + $string = ''; + $previous_key = -1; + $first_key = key($array); + foreach ($array as $key => $value) { + $string .= $this->_yamlize($key, $value, $indent, $previous_key, $first_key); + $previous_key = $key; + } + return $string; + } else { + return false; + } + } + + /** + * Returns YAML from a key and a value + * @access private + * @return string + * @param $key The name of the key + * @param $value The value of the item + * @param $indent The indent of the current node + */ + function _dumpNode($key, $value, $indent, $previous_key = -1, $first_key = 0) { + // do some folding here, for blocks + if (is_string ($value) && ((strpos($value,"\n") !== false || strpos($value,": ") !== false || strpos($value,"- ") !== false || + strpos($value,"*") !== false || strpos($value,"#") !== false || strpos($value,"<") !== false || strpos($value,">") !== false || + strpos($value,"[") !== false || strpos($value,"]") !== false || strpos($value,"{") !== false || strpos($value,"}") !== false) || substr ($value, -1, 1) == ':')) { + $value = $this->_doLiteralBlock($value,$indent); + } else { + $value = $this->_doFolding($value,$indent); + if (is_bool($value)) { + $value = ($value) ? "true" : "false"; + } + } + + if ($value === array()) $value = '[ ]'; + + $spaces = str_repeat(' ',$indent); + + if (is_int($key) && $key - 1 == $previous_key && $first_key===0) { + // It's a sequence + $string = $spaces.'- '.$value."\n"; + } else { + if ($first_key===0) throw new Exception('Keys are all screwy. The first one was zero, now it\'s "'. $key .'"'); + // It's mapped + if (strpos($key, ":") !== false) { $key = '"' . $key . '"'; } + $string = $spaces.$key.': '.$value."\n"; + } + return $string; + } + + /** + * Creates a literal block for dumping + * @access private + * @return string + * @param $value + * @param $indent int The value of the indent + */ + function _doLiteralBlock($value,$indent) { + if (strpos($value, "\n") === false && strpos($value, "'") === false) { + return sprintf ("'%s'", $value); + } + if (strpos($value, "\n") === false && strpos($value, '"') === false) { + return sprintf ('"%s"', $value); + } + $exploded = explode("\n",$value); + $newValue = '|'; + $indent += $this->_dumpIndent; + $spaces = str_repeat(' ',$indent); + foreach ($exploded as $line) { + $newValue .= "\n" . $spaces . trim($line); + } + return $newValue; + } + + /** + * Folds a string of text, if necessary + * @access private + * @return string + * @param $value The string you wish to fold + */ + function _doFolding($value,$indent) { + // Don't do anything if wordwrap is set to 0 + + if ($this->_dumpWordWrap !== 0 && is_string ($value) && strlen($value) > $this->_dumpWordWrap) { + $indent += $this->_dumpIndent; + $indent = str_repeat(' ',$indent); + $wrapped = wordwrap($value,$this->_dumpWordWrap,"\n$indent"); + $value = ">\n".$indent.$wrapped; + } else { + if ($this->setting_dump_force_quotes && is_string ($value)) + $value = '"' . $value . '"'; + } + + + return $value; + } + +// LOADING FUNCTIONS + + function __load($input) { + $Source = $this->loadFromSource($input); + return $this->loadWithSource($Source); + } + + function __loadString($input) { + $Source = $this->loadFromString($input); + return $this->loadWithSource($Source); + } + + function loadWithSource($Source) { + if (empty ($Source)) return array(); + if ($this->setting_use_syck_is_possible && function_exists ('syck_load')) { + $array = syck_load (implode ('', $Source)); + return is_array($array) ? $array : array(); + } + + $this->path = array(); + $this->result = array(); + + $cnt = count($Source); + for ($i = 0; $i < $cnt; $i++) { + $line = $Source[$i]; + + $this->indent = strlen($line) - strlen(ltrim($line)); + $tempPath = $this->getParentPathByIndent($this->indent); + $line = $this->stripIndent($line, $this->indent); + if ($this->isComment($line)) continue; + if ($this->isEmpty($line)) continue; + $this->path = $tempPath; + + $literalBlockStyle = $this->startsLiteralBlock($line); + if ($literalBlockStyle) { + $line = rtrim ($line, $literalBlockStyle . " \n"); + $literalBlock = ''; + $line .= $this->LiteralPlaceHolder; + + while (++$i < $cnt && $this->literalBlockContinues($Source[$i], $this->indent)) { + $literalBlock = $this->addLiteralLine($literalBlock, $Source[$i], $literalBlockStyle); + } + $i--; + } + + while (++$i < $cnt && $this->greedilyNeedNextLine($line)) { + $line = rtrim ($line, " \n\t\r") . ' ' . ltrim ($Source[$i], " \t"); + } + $i--; + + + + if (strpos ($line, '#')) { + if (strpos ($line, '"') === false && strpos ($line, "'") === false) + $line = preg_replace('/\s+#(.+)$/','',$line); + } + + $lineArray = $this->_parseLine($line); + + if ($literalBlockStyle) + $lineArray = $this->revertLiteralPlaceHolder ($lineArray, $literalBlock); + + $this->addArray($lineArray, $this->indent); + + foreach ($this->delayedPath as $indent => $delayedPath) + $this->path[$indent] = $delayedPath; + + $this->delayedPath = array(); + + } + return $this->result; + } + + function loadFromSource ($input) { + if (!empty($input) && strpos($input, "\n") === false && file_exists($input)) + return file($input); + + return $this->loadFromString($input); + } + + function loadFromString ($input) { + $lines = explode("\n",$input); + foreach ($lines as $k => $_) { + $lines[$k] = rtrim ($_, "\r"); + } + return $lines; + } + + /** + * Parses YAML code and returns an array for a node + * @access private + * @return array + * @param string $line A line from the YAML file + */ + function _parseLine($line) { + if (!$line) return array(); + $line = trim($line); + + if (!$line) return array(); + $array = array(); + + $group = $this->nodeContainsGroup($line); + if ($group) { + $this->addGroup($line, $group); + $line = $this->stripGroup ($line, $group); + } + + if ($this->startsMappedSequence($line)) + return $this->returnMappedSequence($line); + + if ($this->startsMappedValue($line)) + return $this->returnMappedValue($line); + + if ($this->isArrayElement($line)) + return $this->returnArrayElement($line); + + if ($this->isPlainArray($line)) + return $this->returnPlainArray($line); + + + return $this->returnKeyValuePair($line); + + } + + /** + * Finds the type of the passed value, returns the value as the new type. + * @access private + * @param string $value + * @return mixed + */ + function _toType($value) { + if ($value === '') return null; + $first_character = $value[0]; + $last_character = substr($value, -1, 1); + + $is_quoted = false; + do { + if (!$value) break; + if ($first_character != '"' && $first_character != "'") break; + if ($last_character != '"' && $last_character != "'") break; + $is_quoted = true; + } while (0); + + if ($is_quoted) + return strtr(substr ($value, 1, -1), array ('\\"' => '"', '\'\'' => '\'', '\\\'' => '\'')); + + if (strpos($value, ' #') !== false) + $value = preg_replace('/\s+#(.+)$/','',$value); + + if ($first_character == '[' && $last_character == ']') { + // Take out strings sequences and mappings + $innerValue = trim(substr ($value, 1, -1)); + if ($innerValue === '') return array(); + $explode = $this->_inlineEscape($innerValue); + // Propagate value array + $value = array(); + foreach ($explode as $v) { + $value[] = $this->_toType($v); + } + return $value; + } + + if (strpos($value,': ')!==false && $first_character != '{') { + $array = explode(': ',$value); + $key = trim($array[0]); + array_shift($array); + $value = trim(implode(': ',$array)); + $value = $this->_toType($value); + return array($key => $value); + } + + if ($first_character == '{' && $last_character == '}') { + $innerValue = trim(substr ($value, 1, -1)); + if ($innerValue === '') return array(); + // Inline Mapping + // Take out strings sequences and mappings + $explode = $this->_inlineEscape($innerValue); + // Propagate value array + $array = array(); + foreach ($explode as $v) { + $SubArr = $this->_toType($v); + if (empty($SubArr)) continue; + if (is_array ($SubArr)) { + $array[key($SubArr)] = $SubArr[key($SubArr)]; continue; + } + $array[] = $SubArr; + } + return $array; + } + + if ($value == 'null' || $value == 'NULL' || $value == 'Null' || $value == '' || $value == '~') { + return null; + } + + if (intval($first_character) > 0 && preg_match ('/^[1-9]+[0-9]*$/', $value)) { + $intvalue = (int)$value; + if ($intvalue != PHP_INT_MAX) + $value = $intvalue; + return $value; + } + + if (in_array($value, + array('true', 'on', '+', 'yes', 'y', 'True', 'TRUE', 'On', 'ON', 'YES', 'Yes', 'Y'))) { + return true; + } + + if (in_array(strtolower($value), + array('false', 'off', '-', 'no', 'n'))) { + return false; + } + + if (is_numeric($value)) { + if ($value === '0') return 0; + if (trim ($value, 0) === $value) + $value = (float)$value; + return $value; + } + + return $value; + } + + /** + * Used in inlines to check for more inlines or quoted strings + * @access private + * @return array + */ + function _inlineEscape($inline) { + // There's gotta be a cleaner way to do this... + // While pure sequences seem to be nesting just fine, + // pure mappings and mappings with sequences inside can't go very + // deep. This needs to be fixed. + + $seqs = array(); + $maps = array(); + $saved_strings = array(); + + // Check for strings + $regex = '/(?:(")|(?:\'))((?(1)[^"]+|[^\']+))(?(1)"|\')/'; + if (preg_match_all($regex,$inline,$strings)) { + $saved_strings = $strings[0]; + $inline = preg_replace($regex,'YAMLString',$inline); + } + unset($regex); + + $i = 0; + do { + + // Check for sequences + while (preg_match('/\[([^{}\[\]]+)\]/U',$inline,$matchseqs)) { + $seqs[] = $matchseqs[0]; + $inline = preg_replace('/\[([^{}\[\]]+)\]/U', ('YAMLSeq' . (count($seqs) - 1) . 's'), $inline, 1); + } + + // Check for mappings + while (preg_match('/{([^\[\]{}]+)}/U',$inline,$matchmaps)) { + $maps[] = $matchmaps[0]; + $inline = preg_replace('/{([^\[\]{}]+)}/U', ('YAMLMap' . (count($maps) - 1) . 's'), $inline, 1); + } + + if ($i++ >= 10) break; + + } while (strpos ($inline, '[') !== false || strpos ($inline, '{') !== false); + + $explode = explode(', ',$inline); + $stringi = 0; $i = 0; + + while (1) { + + // Re-add the sequences + if (!empty($seqs)) { + foreach ($explode as $key => $value) { + if (strpos($value,'YAMLSeq') !== false) { + foreach ($seqs as $seqk => $seq) { + $explode[$key] = str_replace(('YAMLSeq'.$seqk.'s'),$seq,$value); + $value = $explode[$key]; + } + } + } + } + + // Re-add the mappings + if (!empty($maps)) { + foreach ($explode as $key => $value) { + if (strpos($value,'YAMLMap') !== false) { + foreach ($maps as $mapk => $map) { + $explode[$key] = str_replace(('YAMLMap'.$mapk.'s'), $map, $value); + $value = $explode[$key]; + } + } + } + } + + + // Re-add the strings + if (!empty($saved_strings)) { + foreach ($explode as $key => $value) { + while (strpos($value,'YAMLString') !== false) { + $explode[$key] = preg_replace('/YAMLString/',$saved_strings[$stringi],$value, 1); + unset($saved_strings[$stringi]); + ++$stringi; + $value = $explode[$key]; + } + } + } + + $finished = true; + foreach ($explode as $key => $value) { + if (strpos($value,'YAMLSeq') !== false) { + $finished = false; break; + } + if (strpos($value,'YAMLMap') !== false) { + $finished = false; break; + } + if (strpos($value,'YAMLString') !== false) { + $finished = false; break; + } + } + if ($finished) break; + + $i++; + if ($i > 10) + break; // Prevent infinite loops. + } + + return $explode; + } + + function literalBlockContinues ($line, $lineIndent) { + if (!trim($line)) return true; + if (strlen($line) - strlen(ltrim($line)) > $lineIndent) return true; + return false; + } + + function referenceContentsByAlias ($alias) { + do { + if (!isset($this->SavedGroups[$alias])) { echo "Bad group name: $alias."; break; } + $groupPath = $this->SavedGroups[$alias]; + $value = $this->result; + foreach ($groupPath as $k) { + $value = $value[$k]; + } + } while (false); + return $value; + } + + function addArrayInline ($array, $indent) { + $CommonGroupPath = $this->path; + if (empty ($array)) return false; + + foreach ($array as $k => $_) { + $this->addArray(array($k => $_), $indent); + $this->path = $CommonGroupPath; + } + return true; + } + + function addArray ($incoming_data, $incoming_indent) { + + // print_r ($incoming_data); + + if (count ($incoming_data) > 1) + return $this->addArrayInline ($incoming_data, $incoming_indent); + + $key = key ($incoming_data); + $value = isset($incoming_data[$key]) ? $incoming_data[$key] : null; + if ($key === '__!YAMLZero') $key = '0'; + + if ($incoming_indent == 0 && !$this->_containsGroupAlias && !$this->_containsGroupAnchor) { // Shortcut for root-level values. + if ($key || $key === '' || $key === '0') { + $this->result[$key] = $value; + } else { + $this->result[] = $value; end ($this->result); $key = key ($this->result); + } + $this->path[$incoming_indent] = $key; + return; + } + + + + $history = array(); + // Unfolding inner array tree. + $history[] = $_arr = $this->result; + foreach ($this->path as $k) { + $history[] = $_arr = $_arr[$k]; + } + + if ($this->_containsGroupAlias) { + $value = $this->referenceContentsByAlias($this->_containsGroupAlias); + $this->_containsGroupAlias = false; + } + + + // Adding string or numeric key to the innermost level or $this->arr. + if (is_string($key) && $key == '<<') { + if (!is_array ($_arr)) { $_arr = array (); } + $_arr = array_merge ($_arr, $value); + } else if ($key || $key === '' || $key === '0') { + $_arr[$key] = $value; + } else { + if (!is_array ($_arr)) { $_arr = array ($value); $key = 0; } + else { $_arr[] = $value; end ($_arr); $key = key ($_arr); } + } + + $reverse_path = array_reverse($this->path); + $reverse_history = array_reverse ($history); + $reverse_history[0] = $_arr; + $cnt = count($reverse_history) - 1; + for ($i = 0; $i < $cnt; $i++) { + $reverse_history[$i+1][$reverse_path[$i]] = $reverse_history[$i]; + } + $this->result = $reverse_history[$cnt]; + + $this->path[$incoming_indent] = $key; + + if ($this->_containsGroupAnchor) { + $this->SavedGroups[$this->_containsGroupAnchor] = $this->path; + if (is_array ($value)) { + $k = key ($value); + if (!is_int ($k)) { + $this->SavedGroups[$this->_containsGroupAnchor][$incoming_indent + 2] = $k; + } + } + $this->_containsGroupAnchor = false; + } + + } + + function startsLiteralBlock ($line) { + $lastChar = substr (trim($line), -1); + if ($lastChar != '>' && $lastChar != '|') return false; + if ($lastChar == '|') return $lastChar; + // HTML tags should not be counted as literal blocks. + if (preg_match ('#<.*?>$#', $line)) return false; + return $lastChar; + } + + function greedilyNeedNextLine($line) { + $line = trim ($line); + if (!strlen($line)) return false; + if (substr ($line, -1, 1) == ']') return false; + if ($line[0] == '[') return true; + if (preg_match ('#^[^:]+?:\s*\[#', $line)) return true; + return false; + } + + function addLiteralLine ($literalBlock, $line, $literalBlockStyle) { + $line = $this->stripIndent($line); + $line = rtrim ($line, "\r\n\t ") . "\n"; + if ($literalBlockStyle == '|') { + return $literalBlock . $line; + } + if (strlen($line) == 0) + return rtrim($literalBlock, ' ') . "\n"; + if ($line == "\n" && $literalBlockStyle == '>') { + return rtrim ($literalBlock, " \t") . "\n"; + } + if ($line != "\n") + $line = trim ($line, "\r\n ") . " "; + return $literalBlock . $line; + } + + function revertLiteralPlaceHolder ($lineArray, $literalBlock) { + foreach ($lineArray as $k => $_) { + if (is_array($_)) + $lineArray[$k] = $this->revertLiteralPlaceHolder ($_, $literalBlock); + else if (substr($_, -1 * strlen ($this->LiteralPlaceHolder)) == $this->LiteralPlaceHolder) + $lineArray[$k] = rtrim ($literalBlock, " \r\n"); + } + return $lineArray; + } + + function stripIndent ($line, $indent = -1) { + if ($indent == -1) $indent = strlen($line) - strlen(ltrim($line)); + return substr ($line, $indent); + } + + function getParentPathByIndent ($indent) { + if ($indent == 0) return array(); + $linePath = $this->path; + do { + end($linePath); $lastIndentInParentPath = key($linePath); + if ($indent <= $lastIndentInParentPath) array_pop ($linePath); + } while ($indent <= $lastIndentInParentPath); + return $linePath; + } + + + function clearBiggerPathValues ($indent) { + + + if ($indent == 0) $this->path = array(); + if (empty ($this->path)) return true; + + foreach ($this->path as $k => $_) { + if ($k > $indent) unset ($this->path[$k]); + } + + return true; + } + + + function isComment ($line) { + if (!$line) return false; + if ($line[0] == '#') return true; + if (trim($line, " \r\n\t") == '---') return true; + return false; + } + + function isEmpty ($line) { + return (trim ($line) === ''); + } + + + function isArrayElement ($line) { + if (!$line) return false; + if ($line[0] != '-') return false; + if (strlen ($line) > 3) + if (substr($line,0,3) == '---') return false; + + return true; + } + + function isHashElement ($line) { + return strpos($line, ':'); + } + + function isLiteral ($line) { + if ($this->isArrayElement($line)) return false; + if ($this->isHashElement($line)) return false; + return true; + } + + + function unquote ($value) { + if (!$value) return $value; + if (!is_string($value)) return $value; + if ($value[0] == '\'') return trim ($value, '\''); + if ($value[0] == '"') return trim ($value, '"'); + return $value; + } + + function startsMappedSequence ($line) { + return ($line[0] == '-' && substr ($line, -1, 1) == ':'); + } + + function returnMappedSequence ($line) { + $array = array(); + $key = $this->unquote(trim(substr($line,1,-1))); + $array[$key] = array(); + $this->delayedPath = array(strpos ($line, $key) + $this->indent => $key); + return array($array); + } + + function returnMappedValue ($line) { + $array = array(); + $key = $this->unquote (trim(substr($line,0,-1))); + $array[$key] = ''; + return $array; + } + + function startsMappedValue ($line) { + return (substr ($line, -1, 1) == ':'); + } + + function isPlainArray ($line) { + return ($line[0] == '[' && substr ($line, -1, 1) == ']'); + } + + function returnPlainArray ($line) { + return $this->_toType($line); + } + + function returnKeyValuePair ($line) { + $array = array(); + $key = ''; + if (strpos ($line, ':')) { + // It's a key/value pair most likely + // If the key is in double quotes pull it out + if (($line[0] == '"' || $line[0] == "'") && preg_match('/^(["\'](.*)["\'](\s)*:)/',$line,$matches)) { + $value = trim(str_replace($matches[1],'',$line)); + $key = $matches[2]; + } else { + // Do some guesswork as to the key and the value + $explode = explode(':',$line); + $key = trim($explode[0]); + array_shift($explode); + $value = trim(implode(':',$explode)); + } + // Set the type of the value. Int, string, etc + $value = $this->_toType($value); + if ($key === '0') $key = '__!YAMLZero'; + $array[$key] = $value; + } else { + $array = array ($line); + } + return $array; + + } + + + function returnArrayElement ($line) { + if (strlen($line) <= 1) return array(array()); // Weird %) + $array = array(); + $value = trim(substr($line,1)); + $value = $this->_toType($value); + $array[] = $value; + return $array; + } + + + function nodeContainsGroup ($line) { + $symbolsForReference = 'A-z0-9_\-'; + if (strpos($line, '&') === false && strpos($line, '*') === false) return false; // Please die fast ;-) + if ($line[0] == '&' && preg_match('/^(&['.$symbolsForReference.']+)/', $line, $matches)) return $matches[1]; + if ($line[0] == '*' && preg_match('/^(\*['.$symbolsForReference.']+)/', $line, $matches)) return $matches[1]; + if (preg_match('/(&['.$symbolsForReference.']+)$/', $line, $matches)) return $matches[1]; + if (preg_match('/(\*['.$symbolsForReference.']+$)/', $line, $matches)) return $matches[1]; + if (preg_match ('#^\s*<<\s*:\s*(\*[^\s]+).*$#', $line, $matches)) return $matches[1]; + return false; + + } + + function addGroup ($line, $group) { + if ($group[0] == '&') $this->_containsGroupAnchor = substr ($group, 1); + if ($group[0] == '*') $this->_containsGroupAlias = substr ($group, 1); + //print_r ($this->path); + } + + function stripGroup ($line, $group) { + $line = trim(str_replace($group, '', $line)); + return $line; + } +} + +// Enable use of Spyc from command line +// The syntax is the following: php spyc.php spyc.yaml + +define ('SPYC_FROM_COMMAND_LINE', false); + +do { + if (!SPYC_FROM_COMMAND_LINE) break; + if (empty ($_SERVER['argc']) || $_SERVER['argc'] < 2) break; + if (empty ($_SERVER['PHP_SELF']) || $_SERVER['PHP_SELF'] != 'spyc.php') break; + $file = $argv[1]; + printf ("Spyc loading file: %s\n", $file); + print_r (spyc_load_file ($file)); +} while (0); \ No newline at end of file diff --git a/application/third_party/CIUnit/libraries/spyc/php4/test.php4 b/application/third_party/CIUnit/libraries/spyc/php4/test.php4 new file mode 100755 index 0000000..315f501 --- /dev/null +++ b/application/third_party/CIUnit/libraries/spyc/php4/test.php4 @@ -0,0 +1,162 @@ + "1.5ghz", "ram" => "1 gig", + "os" => "os x 10.4.1")) + die('Sequence 4 failed'); + +# Mapped sequence +if ($yaml['domains'] != array("yaml.org", "php.net")) + die("Key: 'domains' failed"); + +# A sequence like this. +if ($yaml[5] != array("program" => "Adium", "platform" => "OS X", + "type" => "Chat Client")) + die('Sequence 5 failed'); + +# A folded block as a mapped value +if ($yaml['no time'] != "There isn't any time for your tricks!\nDo you understand?") + die("Key: 'no time' failed"); + +# A literal block as a mapped value +if ($yaml['some time'] != "There is nothing but time\nfor your tricks.") + die("Key: 'some time' failed"); + +# Crazy combinations +if ($yaml['databases'] != array( array("name" => "spartan", "notes" => + array( "Needs to be backed up", + "Needs to be normalized" ), + "type" => "mysql" ))) + die("Key: 'databases' failed"); + +# You can be a bit tricky +if ($yaml["if: you'd"] != "like") + die("Key: 'if: you\'d' failed"); + +# Inline sequences +if ($yaml[6] != array("One", "Two", "Three", "Four")) + die("Sequence 6 failed"); + +# Nested Inline Sequences +if ($yaml[7] != array("One", array("Two", "And", "Three"), "Four", "Five")) + die("Sequence 7 failed"); + +# Nested Nested Inline Sequences +if ($yaml[8] != array( "This", array("Is", "Getting", array("Ridiculous", "Guys")), + "Seriously", array("Show", "Mercy"))) + die("Sequence 8 failed"); + +# Inline mappings +if ($yaml[9] != array("name" => "chris", "age" => "young", "brand" => "lucky strike")) + die("Sequence 9 failed"); + +# Nested inline mappings +if ($yaml[10] != array("name" => "mark", "age" => "older than chris", + "brand" => array("marlboro", "lucky strike"))) + die("Sequence 10 failed"); + +# References -- they're shaky, but functional +if ($yaml['dynamic languages'] != array('Perl', 'Python', 'PHP', 'Ruby')) + die("Key: 'dynamic languages' failed"); + +if ($yaml['compiled languages'] != array('C/C++', 'Java')) + die("Key: 'compiled languages' failed"); + +if ($yaml['all languages'] != array( + array('Perl', 'Python', 'PHP', 'Ruby'), + array('C/C++', 'Java') + )) + die("Key: 'all languages' failed"); + +# Added in .2.2: Escaped quotes +if ($yaml[11] != "you know, this shouldn't work. but it does.") + die("Sequence 11 failed."); + +if ($yaml[12] != "that's my value.") + die("Sequence 12 failed."); + +if ($yaml[13] != "again, that's my value.") + die("Sequence 13 failed."); + +if ($yaml[14] != "here's to \"quotes\", boss.") + die("Sequence 14 failed."); + +if ($yaml[15] != array( 'name' => "Foo, Bar's", 'age' => 20)) + die("Sequence 15 failed."); + +if ($yaml[16] != array( 0 => "a", 1 => array (0 => 1, 1 => 2), 2 => "b")) + die("Sequence 16 failed."); + +if ($yaml['endloop'] != "Does this line in the end indeed make Spyc go to an infinite loop?") + die("[endloop] failed."); + + +print "spyc.yaml parsed correctly\n"; + +?> \ No newline at end of file diff --git a/application/third_party/CIUnit/libraries/spyc/spyc.php b/application/third_party/CIUnit/libraries/spyc/spyc.php new file mode 100755 index 0000000..cf56772 --- /dev/null +++ b/application/third_party/CIUnit/libraries/spyc/spyc.php @@ -0,0 +1,1024 @@ + + * @author Chris Wanstrath + * @link http://code.google.com/p/spyc/ + * @copyright Copyright 2005-2006 Chris Wanstrath, 2006-2009 Vlad Andersen + * @license http://www.opensource.org/licenses/mit-license.php MIT License + * @package Spyc + */ + +if (!function_exists('spyc_load')) { + /** + * Parses YAML to array. + * @param string $string YAML string. + * @return array + */ + function spyc_load ($string) { + return Spyc::YAMLLoadString($string); + } +} + +if (!function_exists('spyc_load_file')) { + /** + * Parses YAML to array. + * @param string $file Path to YAML file. + * @return array + */ + function spyc_load_file ($file) { + return Spyc::YAMLLoad($file); + } +} + +/** + * The Simple PHP YAML Class. + * + * This class can be used to read a YAML file and convert its contents + * into a PHP array. It currently supports a very limited subsection of + * the YAML spec. + * + * Usage: + * + * $Spyc = new Spyc; + * $array = $Spyc->load($file); + * + * or: + * + * $array = Spyc::YAMLLoad($file); + * + * or: + * + * $array = spyc_load_file($file); + * + * @package Spyc + */ +class Spyc { + + // SETTINGS + + /** + * Setting this to true will force YAMLDump to enclose any string value in + * quotes. False by default. + * + * @var bool + */ + public $setting_dump_force_quotes = false; + + /** + * Setting this to true will forse YAMLLoad to use syck_load function when + * possible. False by default. + * @var bool + */ + public $setting_use_syck_is_possible = false; + + + + /**#@+ + * @access private + * @var mixed + */ + private $_dumpIndent; + private $_dumpWordWrap; + private $_containsGroupAnchor = false; + private $_containsGroupAlias = false; + private $path; + private $result; + private $LiteralPlaceHolder = '___YAML_Literal_Block___'; + private $SavedGroups = array(); + private $indent; + /** + * Path modifier that should be applied after adding current element. + * @var array + */ + private $delayedPath = array(); + + /**#@+ + * @access public + * @var mixed + */ + public $_nodeId; + +/** + * Load a valid YAML string to Spyc. + * @param string $input + * @return array + */ + public function load ($input) { + return $this->__loadString($input); + } + + /** + * Load a valid YAML file to Spyc. + * @param string $file + * @return array + */ + public function loadFile ($file) { + return $this->__load($file); + } + + /** + * Load YAML into a PHP array statically + * + * The load method, when supplied with a YAML stream (string or file), + * will do its best to convert YAML in a file into a PHP array. Pretty + * simple. + * Usage: + * + * $array = Spyc::YAMLLoad('lucky.yaml'); + * print_r($array); + * + * @access public + * @return array + * @param string $input Path of YAML file or string containing YAML + */ + public static function YAMLLoad($input) { + $Spyc = new Spyc; + return $Spyc->__load($input); + } + + /** + * Load a string of YAML into a PHP array statically + * + * The load method, when supplied with a YAML string, will do its best + * to convert YAML in a string into a PHP array. Pretty simple. + * + * Note: use this function if you don't want files from the file system + * loaded and processed as YAML. This is of interest to people concerned + * about security whose input is from a string. + * + * Usage: + * + * $array = Spyc::YAMLLoadString("---\n0: hello world\n"); + * print_r($array); + * + * @access public + * @return array + * @param string $input String containing YAML + */ + public static function YAMLLoadString($input) { + $Spyc = new Spyc; + return $Spyc->__loadString($input); + } + + /** + * Dump YAML from PHP array statically + * + * The dump method, when supplied with an array, will do its best + * to convert the array into friendly YAML. Pretty simple. Feel free to + * save the returned string as nothing.yaml and pass it around. + * + * Oh, and you can decide how big the indent is and what the wordwrap + * for folding is. Pretty cool -- just pass in 'false' for either if + * you want to use the default. + * + * Indent's default is 2 spaces, wordwrap's default is 40 characters. And + * you can turn off wordwrap by passing in 0. + * + * @access public + * @return string + * @param array $array PHP array + * @param int $indent Pass in false to use the default, which is 2 + * @param int $wordwrap Pass in 0 for no wordwrap, false for default (40) + */ + public static function YAMLDump($array,$indent = false,$wordwrap = false) { + $spyc = new Spyc; + return $spyc->dump($array,$indent,$wordwrap); + } + + + /** + * Dump PHP array to YAML + * + * The dump method, when supplied with an array, will do its best + * to convert the array into friendly YAML. Pretty simple. Feel free to + * save the returned string as tasteful.yaml and pass it around. + * + * Oh, and you can decide how big the indent is and what the wordwrap + * for folding is. Pretty cool -- just pass in 'false' for either if + * you want to use the default. + * + * Indent's default is 2 spaces, wordwrap's default is 40 characters. And + * you can turn off wordwrap by passing in 0. + * + * @access public + * @return string + * @param array $array PHP array + * @param int $indent Pass in false to use the default, which is 2 + * @param int $wordwrap Pass in 0 for no wordwrap, false for default (40) + */ + public function dump($array,$indent = false,$wordwrap = false) { + // Dumps to some very clean YAML. We'll have to add some more features + // and options soon. And better support for folding. + + // New features and options. + if ($indent === false or !is_numeric($indent)) { + $this->_dumpIndent = 2; + } else { + $this->_dumpIndent = $indent; + } + + if ($wordwrap === false or !is_numeric($wordwrap)) { + $this->_dumpWordWrap = 40; + } else { + $this->_dumpWordWrap = $wordwrap; + } + + // New YAML document + $string = "---\n"; + + // Start at the base of the array and move through it. + if ($array) { + $array = (array)$array; + $first_key = key($array); + + $previous_key = -1; + foreach ($array as $key => $value) { + $string .= $this->_yamlize($key,$value,0,$previous_key, $first_key); + $previous_key = $key; + } + } + return $string; + } + + /** + * Attempts to convert a key / value array item to YAML + * @access private + * @return string + * @param $key The name of the key + * @param $value The value of the item + * @param $indent The indent of the current node + */ + private function _yamlize($key,$value,$indent, $previous_key = -1, $first_key = 0) { + if (is_array($value)) { + if (empty ($value)) + return $this->_dumpNode($key, array(), $indent, $previous_key, $first_key); + // It has children. What to do? + // Make it the right kind of item + $string = $this->_dumpNode($key, NULL, $indent, $previous_key, $first_key); + // Add the indent + $indent += $this->_dumpIndent; + // Yamlize the array + $string .= $this->_yamlizeArray($value,$indent); + } elseif (!is_array($value)) { + // It doesn't have children. Yip. + $string = $this->_dumpNode($key, $value, $indent, $previous_key, $first_key); + } + return $string; + } + + /** + * Attempts to convert an array to YAML + * @access private + * @return string + * @param $array The array you want to convert + * @param $indent The indent of the current level + */ + private function _yamlizeArray($array,$indent) { + if (is_array($array)) { + $string = ''; + $previous_key = -1; + $first_key = key($array); + foreach ($array as $key => $value) { + $string .= $this->_yamlize($key, $value, $indent, $previous_key, $first_key); + $previous_key = $key; + } + return $string; + } else { + return false; + } + } + + /** + * Returns YAML from a key and a value + * @access private + * @return string + * @param $key The name of the key + * @param $value The value of the item + * @param $indent The indent of the current node + */ + private function _dumpNode($key, $value, $indent, $previous_key = -1, $first_key = 0) { + // do some folding here, for blocks + if (is_string ($value) && ((strpos($value,"\n") !== false || strpos($value,": ") !== false || strpos($value,"- ") !== false || + strpos($value,"*") !== false || strpos($value,"#") !== false || strpos($value,"<") !== false || strpos($value,">") !== false || + strpos($value,"[") !== false || strpos($value,"]") !== false || strpos($value,"{") !== false || strpos($value,"}") !== false) || substr ($value, -1, 1) == ':')) { + $value = $this->_doLiteralBlock($value,$indent); + } else { + $value = $this->_doFolding($value,$indent); + if (is_bool($value)) { + $value = ($value) ? "true" : "false"; + } + } + + if ($value === array()) $value = '[ ]'; + + $spaces = str_repeat(' ',$indent); + + if (is_int($key) && $key - 1 == $previous_key && $first_key===0) { + // It's a sequence + $string = $spaces.'- '.$value."\n"; + } else { + if ($first_key===0) throw new Exception('Keys are all screwy. The first one was zero, now it\'s "'. $key .'"'); + // It's mapped + if (strpos($key, ":") !== false) { $key = '"' . $key . '"'; } + $string = $spaces.$key.': '.$value."\n"; + } + return $string; + } + + /** + * Creates a literal block for dumping + * @access private + * @return string + * @param $value + * @param $indent int The value of the indent + */ + private function _doLiteralBlock($value,$indent) { + if (strpos($value, "\n") === false && strpos($value, "'") === false) { + return sprintf ("'%s'", $value); + } + if (strpos($value, "\n") === false && strpos($value, '"') === false) { + return sprintf ('"%s"', $value); + } + $exploded = explode("\n",$value); + $newValue = '|'; + $indent += $this->_dumpIndent; + $spaces = str_repeat(' ',$indent); + foreach ($exploded as $line) { + $newValue .= "\n" . $spaces . trim($line); + } + return $newValue; + } + + /** + * Folds a string of text, if necessary + * @access private + * @return string + * @param $value The string you wish to fold + */ + private function _doFolding($value,$indent) { + // Don't do anything if wordwrap is set to 0 + + if ($this->_dumpWordWrap !== 0 && is_string ($value) && strlen($value) > $this->_dumpWordWrap) { + $indent += $this->_dumpIndent; + $indent = str_repeat(' ',$indent); + $wrapped = wordwrap($value,$this->_dumpWordWrap,"\n$indent"); + $value = ">\n".$indent.$wrapped; + } else { + if ($this->setting_dump_force_quotes && is_string ($value)) + $value = '"' . $value . '"'; + } + + + return $value; + } + +// LOADING FUNCTIONS + + private function __load($input) { + $Source = $this->loadFromSource($input); + return $this->loadWithSource($Source); + } + + private function __loadString($input) { + $Source = $this->loadFromString($input); + return $this->loadWithSource($Source); + } + + private function loadWithSource($Source) { + if (empty ($Source)) return array(); + if ($this->setting_use_syck_is_possible && function_exists ('syck_load')) { + $array = syck_load (implode ('', $Source)); + return is_array($array) ? $array : array(); + } + + $this->path = array(); + $this->result = array(); + + $cnt = count($Source); + for ($i = 0; $i < $cnt; $i++) { + $line = $Source[$i]; + + $this->indent = strlen($line) - strlen(ltrim($line)); + $tempPath = $this->getParentPathByIndent($this->indent); + $line = self::stripIndent($line, $this->indent); + if (self::isComment($line)) continue; + if (self::isEmpty($line)) continue; + $this->path = $tempPath; + + $literalBlockStyle = self::startsLiteralBlock($line); + if ($literalBlockStyle) { + $line = rtrim ($line, $literalBlockStyle . " \n"); + $literalBlock = ''; + $line .= $this->LiteralPlaceHolder; + + while (++$i < $cnt && $this->literalBlockContinues($Source[$i], $this->indent)) { + $literalBlock = $this->addLiteralLine($literalBlock, $Source[$i], $literalBlockStyle); + } + $i--; + } + + while (++$i < $cnt && self::greedilyNeedNextLine($line)) { + $line = rtrim ($line, " \n\t\r") . ' ' . ltrim ($Source[$i], " \t"); + } + $i--; + + + + if (strpos ($line, '#')) { + if (strpos ($line, '"') === false && strpos ($line, "'") === false) + $line = preg_replace('/\s+#(.+)$/','',$line); + } + + $lineArray = $this->_parseLine($line); + + if ($literalBlockStyle) + $lineArray = $this->revertLiteralPlaceHolder ($lineArray, $literalBlock); + + $this->addArray($lineArray, $this->indent); + + foreach ($this->delayedPath as $indent => $delayedPath) + $this->path[$indent] = $delayedPath; + + $this->delayedPath = array(); + + } + return $this->result; + } + + private function loadFromSource ($input) { + if (!empty($input) && strpos($input, "\n") === false && file_exists($input)) + return file($input); + + return $this->loadFromString($input); + } + + private function loadFromString ($input) { + $lines = explode("\n",$input); + foreach ($lines as $k => $_) { + $lines[$k] = rtrim ($_, "\r"); + } + return $lines; + } + + /** + * Parses YAML code and returns an array for a node + * @access private + * @return array + * @param string $line A line from the YAML file + */ + private function _parseLine($line) { + if (!$line) return array(); + $line = trim($line); + + if (!$line) return array(); + $array = array(); + + $group = $this->nodeContainsGroup($line); + if ($group) { + $this->addGroup($line, $group); + $line = $this->stripGroup ($line, $group); + } + + if ($this->startsMappedSequence($line)) + return $this->returnMappedSequence($line); + + if ($this->startsMappedValue($line)) + return $this->returnMappedValue($line); + + if ($this->isArrayElement($line)) + return $this->returnArrayElement($line); + + if ($this->isPlainArray($line)) + return $this->returnPlainArray($line); + + + return $this->returnKeyValuePair($line); + + } + + /** + * Finds the type of the passed value, returns the value as the new type. + * @access private + * @param string $value + * @return mixed + */ + private function _toType($value) { + if ($value === '') return null; + $first_character = $value[0]; + $last_character = substr($value, -1, 1); + + $is_quoted = false; + do { + if (!$value) break; + if ($first_character != '"' && $first_character != "'") break; + if ($last_character != '"' && $last_character != "'") break; + $is_quoted = true; + } while (0); + + if ($is_quoted) + return strtr(substr ($value, 1, -1), array ('\\"' => '"', '\'\'' => '\'', '\\\'' => '\'')); + + if (strpos($value, ' #') !== false) + $value = preg_replace('/\s+#(.+)$/','',$value); + + if ($first_character == '[' && $last_character == ']') { + // Take out strings sequences and mappings + $innerValue = trim(substr ($value, 1, -1)); + if ($innerValue === '') return array(); + $explode = $this->_inlineEscape($innerValue); + // Propagate value array + $value = array(); + foreach ($explode as $v) { + $value[] = $this->_toType($v); + } + return $value; + } + + if (strpos($value,': ')!==false && $first_character != '{') { + $array = explode(': ',$value); + $key = trim($array[0]); + array_shift($array); + $value = trim(implode(': ',$array)); + $value = $this->_toType($value); + return array($key => $value); + } + + if ($first_character == '{' && $last_character == '}') { + $innerValue = trim(substr ($value, 1, -1)); + if ($innerValue === '') return array(); + // Inline Mapping + // Take out strings sequences and mappings + $explode = $this->_inlineEscape($innerValue); + // Propagate value array + $array = array(); + foreach ($explode as $v) { + $SubArr = $this->_toType($v); + if (empty($SubArr)) continue; + if (is_array ($SubArr)) { + $array[key($SubArr)] = $SubArr[key($SubArr)]; continue; + } + $array[] = $SubArr; + } + return $array; + } + + if ($value == 'null' || $value == 'NULL' || $value == 'Null' || $value == '' || $value == '~') { + return null; + } + + if (intval($first_character) > 0 && preg_match ('/^[1-9]+[0-9]*$/', $value)) { + $intvalue = (int)$value; + if ($intvalue != PHP_INT_MAX) + $value = $intvalue; + return $value; + } + + if (in_array($value, + array('true', 'on', '+', 'yes', 'y', 'True', 'TRUE', 'On', 'ON', 'YES', 'Yes', 'Y'))) { + return true; + } + + if (in_array(strtolower($value), + array('false', 'off', '-', 'no', 'n'))) { + return false; + } + + if (is_numeric($value)) { + if ($value === '0') return 0; + if (trim ($value, 0) === $value) + $value = (float)$value; + return $value; + } + + return $value; + } + + /** + * Used in inlines to check for more inlines or quoted strings + * @access private + * @return array + */ + private function _inlineEscape($inline) { + // There's gotta be a cleaner way to do this... + // While pure sequences seem to be nesting just fine, + // pure mappings and mappings with sequences inside can't go very + // deep. This needs to be fixed. + + $seqs = array(); + $maps = array(); + $saved_strings = array(); + + // Check for strings + $regex = '/(?:(")|(?:\'))((?(1)[^"]+|[^\']+))(?(1)"|\')/'; + if (preg_match_all($regex,$inline,$strings)) { + $saved_strings = $strings[0]; + $inline = preg_replace($regex,'YAMLString',$inline); + } + unset($regex); + + $i = 0; + do { + + // Check for sequences + while (preg_match('/\[([^{}\[\]]+)\]/U',$inline,$matchseqs)) { + $seqs[] = $matchseqs[0]; + $inline = preg_replace('/\[([^{}\[\]]+)\]/U', ('YAMLSeq' . (count($seqs) - 1) . 's'), $inline, 1); + } + + // Check for mappings + while (preg_match('/{([^\[\]{}]+)}/U',$inline,$matchmaps)) { + $maps[] = $matchmaps[0]; + $inline = preg_replace('/{([^\[\]{}]+)}/U', ('YAMLMap' . (count($maps) - 1) . 's'), $inline, 1); + } + + if ($i++ >= 10) break; + + } while (strpos ($inline, '[') !== false || strpos ($inline, '{') !== false); + + $explode = explode(', ',$inline); + $stringi = 0; $i = 0; + + while (1) { + + // Re-add the sequences + if (!empty($seqs)) { + foreach ($explode as $key => $value) { + if (strpos($value,'YAMLSeq') !== false) { + foreach ($seqs as $seqk => $seq) { + $explode[$key] = str_replace(('YAMLSeq'.$seqk.'s'),$seq,$value); + $value = $explode[$key]; + } + } + } + } + + // Re-add the mappings + if (!empty($maps)) { + foreach ($explode as $key => $value) { + if (strpos($value,'YAMLMap') !== false) { + foreach ($maps as $mapk => $map) { + $explode[$key] = str_replace(('YAMLMap'.$mapk.'s'), $map, $value); + $value = $explode[$key]; + } + } + } + } + + + // Re-add the strings + if (!empty($saved_strings)) { + foreach ($explode as $key => $value) { + while (strpos($value,'YAMLString') !== false) { + $explode[$key] = preg_replace('/YAMLString/',$saved_strings[$stringi],$value, 1); + unset($saved_strings[$stringi]); + ++$stringi; + $value = $explode[$key]; + } + } + } + + $finished = true; + foreach ($explode as $key => $value) { + if (strpos($value,'YAMLSeq') !== false) { + $finished = false; break; + } + if (strpos($value,'YAMLMap') !== false) { + $finished = false; break; + } + if (strpos($value,'YAMLString') !== false) { + $finished = false; break; + } + } + if ($finished) break; + + $i++; + if ($i > 10) + break; // Prevent infinite loops. + } + + return $explode; + } + + private function literalBlockContinues ($line, $lineIndent) { + if (!trim($line)) return true; + if (strlen($line) - strlen(ltrim($line)) > $lineIndent) return true; + return false; + } + + private function referenceContentsByAlias ($alias) { + do { + if (!isset($this->SavedGroups[$alias])) { echo "Bad group name: $alias."; break; } + $groupPath = $this->SavedGroups[$alias]; + $value = $this->result; + foreach ($groupPath as $k) { + $value = $value[$k]; + } + } while (false); + return $value; + } + + private function addArrayInline ($array, $indent) { + $CommonGroupPath = $this->path; + if (empty ($array)) return false; + + foreach ($array as $k => $_) { + $this->addArray(array($k => $_), $indent); + $this->path = $CommonGroupPath; + } + return true; + } + + private function addArray ($incoming_data, $incoming_indent) { + + // print_r ($incoming_data); + + if (count ($incoming_data) > 1) + return $this->addArrayInline ($incoming_data, $incoming_indent); + + $key = key ($incoming_data); + $value = isset($incoming_data[$key]) ? $incoming_data[$key] : null; + if ($key === '__!YAMLZero') $key = '0'; + + if ($incoming_indent == 0 && !$this->_containsGroupAlias && !$this->_containsGroupAnchor) { // Shortcut for root-level values. + if ($key || $key === '' || $key === '0') { + $this->result[$key] = $value; + } else { + $this->result[] = $value; end ($this->result); $key = key ($this->result); + } + $this->path[$incoming_indent] = $key; + return; + } + + + + $history = array(); + // Unfolding inner array tree. + $history[] = $_arr = $this->result; + foreach ($this->path as $k) { + $history[] = $_arr = $_arr[$k]; + } + + if ($this->_containsGroupAlias) { + $value = $this->referenceContentsByAlias($this->_containsGroupAlias); + $this->_containsGroupAlias = false; + } + + + // Adding string or numeric key to the innermost level or $this->arr. + if (is_string($key) && $key == '<<') { + if (!is_array ($_arr)) { $_arr = array (); } + + $_arr = array_merge ($_arr, $value); + } else if ($key || $key === '' || $key === '0') { + $_arr[$key] = $value; + } else { + if (!is_array ($_arr)) { $_arr = array ($value); $key = 0; } + else { $_arr[] = $value; end ($_arr); $key = key ($_arr); } + } + + $reverse_path = array_reverse($this->path); + $reverse_history = array_reverse ($history); + $reverse_history[0] = $_arr; + $cnt = count($reverse_history) - 1; + for ($i = 0; $i < $cnt; $i++) { + $reverse_history[$i+1][$reverse_path[$i]] = $reverse_history[$i]; + } + $this->result = $reverse_history[$cnt]; + + $this->path[$incoming_indent] = $key; + + if ($this->_containsGroupAnchor) { + $this->SavedGroups[$this->_containsGroupAnchor] = $this->path; + if (is_array ($value)) { + $k = key ($value); + if (!is_int ($k)) { + $this->SavedGroups[$this->_containsGroupAnchor][$incoming_indent + 2] = $k; + } + } + $this->_containsGroupAnchor = false; + } + + } + + private static function startsLiteralBlock ($line) { + $lastChar = substr (trim($line), -1); + if ($lastChar != '>' && $lastChar != '|') return false; + if ($lastChar == '|') return $lastChar; + // HTML tags should not be counted as literal blocks. + if (preg_match ('#<.*?>$#', $line)) return false; + return $lastChar; + } + + private static function greedilyNeedNextLine($line) { + $line = trim ($line); + if (!strlen($line)) return false; + if (substr ($line, -1, 1) == ']') return false; + if ($line[0] == '[') return true; + if (preg_match ('#^[^:]+?:\s*\[#', $line)) return true; + return false; + } + + private function addLiteralLine ($literalBlock, $line, $literalBlockStyle) { + $line = self::stripIndent($line); + $line = rtrim ($line, "\r\n\t ") . "\n"; + if ($literalBlockStyle == '|') { + return $literalBlock . $line; + } + if (strlen($line) == 0) + return rtrim($literalBlock, ' ') . "\n"; + if ($line == "\n" && $literalBlockStyle == '>') { + return rtrim ($literalBlock, " \t") . "\n"; + } + if ($line != "\n") + $line = trim ($line, "\r\n ") . " "; + return $literalBlock . $line; + } + + function revertLiteralPlaceHolder ($lineArray, $literalBlock) { + foreach ($lineArray as $k => $_) { + if (is_array($_)) + $lineArray[$k] = $this->revertLiteralPlaceHolder ($_, $literalBlock); + else if (substr($_, -1 * strlen ($this->LiteralPlaceHolder)) == $this->LiteralPlaceHolder) + $lineArray[$k] = rtrim ($literalBlock, " \r\n"); + } + return $lineArray; + } + + private static function stripIndent ($line, $indent = -1) { + if ($indent == -1) $indent = strlen($line) - strlen(ltrim($line)); + return substr ($line, $indent); + } + + private function getParentPathByIndent ($indent) { + if ($indent == 0) return array(); + $linePath = $this->path; + do { + end($linePath); $lastIndentInParentPath = key($linePath); + if ($indent <= $lastIndentInParentPath) array_pop ($linePath); + } while ($indent <= $lastIndentInParentPath); + return $linePath; + } + + + private function clearBiggerPathValues ($indent) { + + + if ($indent == 0) $this->path = array(); + if (empty ($this->path)) return true; + + foreach ($this->path as $k => $_) { + if ($k > $indent) unset ($this->path[$k]); + } + + return true; + } + + + private static function isComment ($line) { + if (!$line) return false; + if ($line[0] == '#') return true; + if (trim($line, " \r\n\t") == '---') return true; + return false; + } + + private static function isEmpty ($line) { + return (trim ($line) === ''); + } + + + private function isArrayElement ($line) { + if (!$line) return false; + if ($line[0] != '-') return false; + if (strlen ($line) > 3) + if (substr($line,0,3) == '---') return false; + + return true; + } + + private function isHashElement ($line) { + return strpos($line, ':'); + } + + private function isLiteral ($line) { + if ($this->isArrayElement($line)) return false; + if ($this->isHashElement($line)) return false; + return true; + } + + + private static function unquote ($value) { + if (!$value) return $value; + if (!is_string($value)) return $value; + if ($value[0] == '\'') return trim ($value, '\''); + if ($value[0] == '"') return trim ($value, '"'); + return $value; + } + + private function startsMappedSequence ($line) { + return ($line[0] == '-' && substr ($line, -1, 1) == ':'); + } + + private function returnMappedSequence ($line) { + $array = array(); + $key = self::unquote(trim(substr($line,1,-1))); + $array[$key] = array(); + $this->delayedPath = array(strpos ($line, $key) + $this->indent => $key); + return array($array); + } + + private function returnMappedValue ($line) { + $array = array(); + $key = self::unquote (trim(substr($line,0,-1))); + $array[$key] = ''; + return $array; + } + + private function startsMappedValue ($line) { + return (substr ($line, -1, 1) == ':'); + } + + private function isPlainArray ($line) { + return ($line[0] == '[' && substr ($line, -1, 1) == ']'); + } + + private function returnPlainArray ($line) { + return $this->_toType($line); + } + + private function returnKeyValuePair ($line) { + $array = array(); + $key = ''; + if (strpos ($line, ':')) { + // It's a key/value pair most likely + // If the key is in double quotes pull it out + if (($line[0] == '"' || $line[0] == "'") && preg_match('/^(["\'](.*)["\'](\s)*:)/',$line,$matches)) { + $value = trim(str_replace($matches[1],'',$line)); + $key = $matches[2]; + } else { + // Do some guesswork as to the key and the value + $explode = explode(':',$line); + $key = trim($explode[0]); + array_shift($explode); + $value = trim(implode(':',$explode)); + } + // Set the type of the value. Int, string, etc + $value = $this->_toType($value); + if ($key === '0') $key = '__!YAMLZero'; + $array[$key] = $value; + } else { + $array = array ($line); + } + return $array; + + } + + + private function returnArrayElement ($line) { + if (strlen($line) <= 1) return array(array()); // Weird %) + $array = array(); + $value = trim(substr($line,1)); + $value = $this->_toType($value); + $array[] = $value; + return $array; + } + + + private function nodeContainsGroup ($line) { + $symbolsForReference = 'A-z0-9_\-'; + if (strpos($line, '&') === false && strpos($line, '*') === false) return false; // Please die fast ;-) + if ($line[0] == '&' && preg_match('/^(&['.$symbolsForReference.']+)/', $line, $matches)) return $matches[1]; + if ($line[0] == '*' && preg_match('/^(\*['.$symbolsForReference.']+)/', $line, $matches)) return $matches[1]; + if (preg_match('/(&['.$symbolsForReference.']+)$/', $line, $matches)) return $matches[1]; + if (preg_match('/(\*['.$symbolsForReference.']+$)/', $line, $matches)) return $matches[1]; + if (preg_match ('#^\s*<<\s*:\s*(\*[^\s]+).*$#', $line, $matches)) return $matches[1]; + return false; + + } + + private function addGroup ($line, $group) { + if ($group[0] == '&') $this->_containsGroupAnchor = substr ($group, 1); + if ($group[0] == '*') $this->_containsGroupAlias = substr ($group, 1); + //print_r ($this->path); + } + + private function stripGroup ($line, $group) { + $line = trim(str_replace($group, '', $line)); + return $line; + } +} + +// Enable use of Spyc from command line +// The syntax is the following: php spyc.php spyc.yaml + +define ('SPYC_FROM_COMMAND_LINE', false); + +do { + if (!SPYC_FROM_COMMAND_LINE) break; + if (empty ($_SERVER['argc']) || $_SERVER['argc'] < 2) break; + if (empty ($_SERVER['PHP_SELF']) || $_SERVER['PHP_SELF'] != 'spyc.php') break; + $file = $argv[1]; + printf ("Spyc loading file: %s\n", $file); + print_r (spyc_load_file ($file)); +} while (0); \ No newline at end of file diff --git a/application/third_party/CIUnit/libraries/spyc/spyc.yaml b/application/third_party/CIUnit/libraries/spyc/spyc.yaml new file mode 100755 index 0000000..2e38e82 --- /dev/null +++ b/application/third_party/CIUnit/libraries/spyc/spyc.yaml @@ -0,0 +1,196 @@ +# +# S P Y C +# a simple php yaml class +# +# authors: [vlad andersen (vlad.andersen@gmail.com), chris wanstrath (chris@ozmm.org)] +# websites: [http://www.yaml.org, http://spyc.sourceforge.net/] +# license: [MIT License, http://www.opensource.org/licenses/mit-license.php] +# copyright: (c) 2005-2006 Chris Wanstrath, 2006-2009 Vlad Andersen +# +# spyc.yml - A file containing the YAML that Spyc understands. + +--- + +# Mappings - with proper types +String: Anyone's name, really. +Int: 13 +True: true +False: false +Zero: 0 +Null: NULL +Float: 5.34 + +# A sequence +- PHP Class +- Basic YAML Loader +- Very Basic YAML Dumper + +# A sequence of a sequence +- + - YAML is so easy to learn. + - Your config files will never be the same. + +# Sequence of mappings +- + cpu: 1.5ghz + ram: 1 gig + os : os x 10.4.1 + +# Mapped sequence +domains: + - yaml.org + - php.net + +# A sequence like this. +- program: Adium + platform: OS X + type: Chat Client + +# A folded block as a mapped value +no time: > + There isn't any time + for your tricks! + + Do you understand? + +# A literal block as a mapped value +some time: | + There is nothing but time + for your tricks. + +# Crazy combinations +databases: + - name: spartan + notes: + - Needs to be backed up + - Needs to be normalized + type: mysql + +# You can be a bit tricky +"if: you'd": like + +# Inline sequences +- [One, Two, Three, Four] + +# Nested Inline Sequences +- [One, [Two, And, Three], Four, Five] + +# Nested Nested Inline Sequences +- [This, [Is, Getting, [Ridiculous, Guys]], Seriously, [Show, Mercy]] + +# Inline mappings +- {name: chris, age: young, brand: lucky strike} + +# Nested inline mappings +- {name: mark, age: older than chris, brand: [marlboro, lucky strike]} + +# References -- they're shaky, but functional +dynamic languages: &DLANGS + - Perl + - Python + - PHP + - Ruby +compiled languages: &CLANGS + - C/C++ + - Java +all languages: + - *DLANGS + - *CLANGS + +# Added in .2.2: Escaped quotes +- you know, this shouldn't work. but it does. +- 'that''s my value.' +- 'again, that\'s my value.' +- "here's to \"quotes\", boss." + +# added in .2.3 +- {name: "Foo, Bar's", age: 20} + +# Added in .2.4: bug [ 1418193 ] Quote Values in Nested Arrays +- [a, ['1', "2"], b] + +# Added in .2.4: malformed YAML +all + javascripts: [dom1.js, dom.js] + +# Added in .2 +1040: Ooo, a numeric key! # And working comments? Wow! Colons in comments: a menace (0.3). + +hash_1: Hash #and a comment +hash_2: "Hash #and a comment" +"hash#3": "Hash (#) can appear in key too" + +float_test: 1.0 +float_test_with_quotes: '1.0' +float_inverse_test: 001 + +a_really_large_number: 115792089237316195423570985008687907853269984665640564039457584007913129639936 # 2^256 + +int array: [ 1, 2, 3 ] + +array on several lines: + [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 ] + +morelesskey: "" + +array_of_zero: [0] +sophisticated_array_of_zero: {rx: {tx: [0]} } + +switches: + - { row: 0, col: 0, func: {tx: [0, 1]} } + +empty_sequence: [ ] +empty_hash: { } + +special_characters: "[{]]{{]]" + +asterisks: "*" + +empty_key: + : + key: value + +trailing_colon: "foo:" + +multiline_items: + - type: SomeItem + values: [blah, blah, blah, + blah] + ints: [2, 54, 12, + 2143] + +many_lines: | + A quick + fox + + + jumped + over + + + + + + a lazy + + + + dog + + +werte: + 1: nummer 1 + 0: Stunde 0 + +noindent_records: +- record1: value1 +- record2: value2 + +"a:1": [1000] +"a:2": + - 2000 + +# [Endloop] +endloop: | + Does this line in the end indeed make Spyc go to an infinite loop? \ No newline at end of file diff --git a/application/third_party/CIUnit/libraries/spyc/tests/DumpTest.php b/application/third_party/CIUnit/libraries/spyc/tests/DumpTest.php new file mode 100755 index 0000000..0529d67 --- /dev/null +++ b/application/third_party/CIUnit/libraries/spyc/tests/DumpTest.php @@ -0,0 +1,58 @@ +files_to_test = array ('../spyc.yaml', 'failing1.yaml', 'indent_1.yaml', 'quotes.yaml'); + } + + public function testDump() { + foreach ($this->files_to_test as $file) { + $yaml = spyc_load(file_get_contents($file)); + $dump = Spyc::YAMLDump ($yaml); + $yaml_after_dump = Spyc::YAMLLoad ($dump); + $this->assertEquals ($yaml, $yaml_after_dump); + } + } + + public function testDumpWithQuotes() { + $Spyc = new Spyc(); + $Spyc->setting_dump_force_quotes = true; + foreach ($this->files_to_test as $file) { + $yaml = $Spyc->load(file_get_contents($file)); + $dump = $Spyc->dump ($yaml); + $yaml_after_dump = Spyc::YAMLLoad ($dump); + $this->assertEquals ($yaml, $yaml_after_dump); + } + } + + public function testDumpArrays() { + $dump = Spyc::YAMLDump(array ('item1', 'item2', 'item3')); + $awaiting = "---\n- item1\n- item2\n- item3\n"; + $this->assertEquals ($awaiting, $dump); + } + + public function testDumpNumerics() { + $dump = Spyc::YAMLDump(array ('404', '405', '500')); + $awaiting = "---\n- 404\n- 405\n- 500\n"; + $this->assertEquals ($awaiting, $dump); + } + + public function testDumpAsterisks() { + $dump = Spyc::YAMLDump(array ('*')); + $awaiting = "---\n- '*'\n"; + $this->assertEquals ($awaiting, $dump); + } + + + public function testEmpty() { + $dump = Spyc::YAMLDump(array("foo" => array())); + $awaiting = "---\nfoo: [ ]\n"; + $this->assertEquals ($awaiting, $dump); + } + +} \ No newline at end of file diff --git a/application/third_party/CIUnit/libraries/spyc/tests/IndentTest.php b/application/third_party/CIUnit/libraries/spyc/tests/IndentTest.php new file mode 100755 index 0000000..482d8e4 --- /dev/null +++ b/application/third_party/CIUnit/libraries/spyc/tests/IndentTest.php @@ -0,0 +1,57 @@ +Y = Spyc::YAMLLoad("indent_1.yaml"); + } + + public function testIndent_1() { + $this->assertEquals (array ('child_1' => 2, 'child_2' => 0, 'child_3' => 1), $this->Y['root']); + } + + public function testIndent_2() { + $this->assertEquals (array ('child_1' => 1, 'child_2' => 2), $this->Y['root2']); + } + + public function testIndent_3() { + $this->assertEquals (array (array ('resolutions' => array (1024 => 768, 1920 => 1200), 'producer' => 'Nec')), $this->Y['display']); + } + + public function testIndent_4() { + $this->assertEquals (array ( + array ('resolutions' => array (1024 => 768)), + array ('resolutions' => array (1920 => 1200)), + ), $this->Y['displays']); + } + + public function testIndent_5() { + $this->assertEquals (array (array ( + 'row' => 0, + 'col' => 0, + 'headsets_affected' => array ( + array ( + 'ports' => array (0), + 'side' => 'left', + ) + ), + 'switch_function' => array ( + 'ics_ptt' => true + ) + )), $this->Y['nested_hashes_and_seqs']); + } + + public function testIndent_6() { + $this->assertEquals (array ( + 'h' => array ( + array ('a' => 'b', 'a1' => 'b1'), + array ('c' => 'd') + ) + ), $this->Y['easier_nest']); + } + +} \ No newline at end of file diff --git a/application/third_party/CIUnit/libraries/spyc/tests/ParseTest.php b/application/third_party/CIUnit/libraries/spyc/tests/ParseTest.php new file mode 100755 index 0000000..2eecf54 --- /dev/null +++ b/application/third_party/CIUnit/libraries/spyc/tests/ParseTest.php @@ -0,0 +1,305 @@ +yaml = spyc_load_file('../spyc.yaml'); + } + + public function testMergeHashKeys() { + $Expected = array ( + array ('step' => array('instrument' => 'Lasik 2000', 'pulseEnergy' => 5.4, 'pulseDuration' => 12, 'repetition' => 1000, 'spotSize' => '1mm')), + array ('step' => array('instrument' => 'Lasik 2000', 'pulseEnergy' => 5.4, 'pulseDuration' => 12, 'repetition' => 1000, 'spotSize' => '2mm')), + ); + $Actual = spyc_load_file ('indent_1.yaml'); + $this->assertEquals ($Expected, $Actual['steps']); + } + + public function testDeathMasks() { + $Expected = array ('sad' => 2, 'magnificent' => 4); + $Actual = spyc_load_file ('indent_1.yaml'); + $this->assertEquals ($Expected, $Actual['death masks are']); + } + + public function testDevDb() { + $Expected = array ('adapter' => 'mysql', 'host' => 'localhost', 'database' => 'rails_dev'); + $Actual = spyc_load_file ('indent_1.yaml'); + $this->assertEquals ($Expected, $Actual['development']); + } + + public function testNumericKey() { + $this->assertEquals ("Ooo, a numeric key!", $this->yaml[1040]); + } + + public function testMappingsString() { + $this->assertEquals ("Anyone's name, really.", $this->yaml['String']); + } + + public function testMappingsInt() { + $this->assertSame (13, $this->yaml['Int']); + } + + public function testMappingsBooleanTrue() { + $this->assertSame (true, $this->yaml['True']); + } + + public function testMappingsBooleanFalse() { + $this->assertSame (false, $this->yaml['False']); + } + + public function testMappingsZero() { + $this->assertSame (0, $this->yaml['Zero']); + } + + public function testMappingsNull() { + $this->assertSame (null, $this->yaml['Null']); + } + + public function testMappingsFloat() { + $this->assertSame (5.34, $this->yaml['Float']); + } + + public function testSeq0() { + $this->assertEquals ("PHP Class", $this->yaml[0]); + } + + public function testSeq1() { + $this->assertEquals ("Basic YAML Loader", $this->yaml[1]); + } + + public function testSeq2() { + $this->assertEquals ("Very Basic YAML Dumper", $this->yaml[2]); + } + + public function testSeq3() { + $this->assertEquals (array("YAML is so easy to learn.", + "Your config files will never be the same."), $this->yaml[3]); + } + + public function testSeqMap() { + $this->assertEquals (array("cpu" => "1.5ghz", "ram" => "1 gig", + "os" => "os x 10.4.1"), $this->yaml[4]); + } + + public function testMappedSequence() { + $this->assertEquals (array("yaml.org", "php.net"), $this->yaml['domains']); + } + + public function testAnotherSequence() { + $this->assertEquals (array("program" => "Adium", "platform" => "OS X", + "type" => "Chat Client"), $this->yaml[5]); + } + + public function testFoldedBlock() { + $this->assertEquals ("There isn't any time for your tricks!\nDo you understand?", $this->yaml['no time']); + } + + public function testLiteralAsMapped() { + $this->assertEquals ("There is nothing but time\nfor your tricks.", $this->yaml['some time']); + } + + public function testCrazy() { + $this->assertEquals (array( array("name" => "spartan", "notes" => + array( "Needs to be backed up", + "Needs to be normalized" ), + "type" => "mysql" )), $this->yaml['databases']); + } + + public function testColons() { + $this->assertEquals ("like", $this->yaml["if: you'd"]); + } + + public function testInline() { + $this->assertEquals (array("One", "Two", "Three", "Four"), $this->yaml[6]); + } + + public function testNestedInline() { + $this->assertEquals (array("One", array("Two", "And", "Three"), "Four", "Five"), $this->yaml[7]); + } + + public function testNestedNestedInline() { + $this->assertEquals (array( "This", array("Is", "Getting", array("Ridiculous", "Guys")), + "Seriously", array("Show", "Mercy")), $this->yaml[8]); + } + + public function testInlineMappings() { + $this->assertEquals (array("name" => "chris", "age" => "young", "brand" => "lucky strike"), $this->yaml[9]); + } + + public function testNestedInlineMappings() { + $this->assertEquals (array("name" => "mark", "age" => "older than chris", + "brand" => array("marlboro", "lucky strike")), $this->yaml[10]); + } + + public function testReferences() { + $this->assertEquals (array('Perl', 'Python', 'PHP', 'Ruby'), $this->yaml['dynamic languages']); + } + + public function testReferences2() { + $this->assertEquals (array('C/C++', 'Java'), $this->yaml['compiled languages']); + } + + public function testReferences3() { + $this->assertEquals (array( + array('Perl', 'Python', 'PHP', 'Ruby'), + array('C/C++', 'Java') + ), $this->yaml['all languages']); + } + + public function testEscapedQuotes() { + $this->assertEquals ("you know, this shouldn't work. but it does.", $this->yaml[11]); + } + + public function testEscapedQuotes_2() { + $this->assertEquals ( "that's my value.", $this->yaml[12]); + } + + public function testEscapedQuotes_3() { + $this->assertEquals ("again, that's my value.", $this->yaml[13]); + } + + public function testQuotes() { + $this->assertEquals ("here's to \"quotes\", boss.", $this->yaml[14]); + } + + public function testQuoteSequence() { + $this->assertEquals ( array( 'name' => "Foo, Bar's", 'age' => 20), $this->yaml[15]); + } + + public function testShortSequence() { + $this->assertEquals (array( 0 => "a", 1 => array (0 => 1, 1 => 2), 2 => "b"), $this->yaml[16]); + } + + public function testHash_1() { + $this->assertEquals ("Hash", $this->yaml['hash_1']); + } + + public function testHash_2() { + $this->assertEquals ('Hash #and a comment', $this->yaml['hash_2']); + } + + public function testHash_3() { + $this->assertEquals ('Hash (#) can appear in key too', $this->yaml['hash#3']); + } + + public function testEndloop() { + $this->assertEquals ("Does this line in the end indeed make Spyc go to an infinite loop?", $this->yaml['endloop']); + } + + public function testReallyLargeNumber() { + $this->assertEquals ('115792089237316195423570985008687907853269984665640564039457584007913129639936', $this->yaml['a_really_large_number']); + } + + public function testFloatWithZeros() { + $this->assertSame ('1.0', $this->yaml['float_test']); + } + + public function testFloatWithQuotes() { + $this->assertSame ('1.0', $this->yaml['float_test_with_quotes']); + } + + public function testFloatInverse() { + $this->assertEquals ('001', $this->yaml['float_inverse_test']); + } + + public function testIntArray() { + $this->assertEquals (array (1, 2, 3), $this->yaml['int array']); + } + + public function testArrayOnSeveralLines() { + $this->assertEquals (array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19), $this->yaml['array on several lines']); + } + + public function testmoreLessKey() { + $this->assertEquals ('', $this->yaml['morelesskey']); + } + + public function testArrayOfZero() { + $this->assertSame (array(0), $this->yaml['array_of_zero']); + } + + public function testSophisticatedArrayOfZero() { + $this->assertSame (array('rx' => array ('tx' => array (0))), $this->yaml['sophisticated_array_of_zero']); + } + + public function testSwitches() { + $this->assertEquals (array (array ('row' => 0, 'col' => 0, 'func' => array ('tx' => array(0, 1)))), $this->yaml['switches']); + } + + public function testEmptySequence() { + $this->assertSame (array(), $this->yaml['empty_sequence']); + } + + public function testEmptyHash() { + $this->assertSame (array(), $this->yaml['empty_hash']); + } + + public function testEmptykey() { + $this->assertSame (array('' => array ('key' => 'value')), $this->yaml['empty_key']); + } + + public function testMultilines() { + $this->assertSame (array(array('type' => 'SomeItem', 'values' => array ('blah', 'blah', 'blah', 'blah'), 'ints' => array(2, 54, 12, 2143))), $this->yaml['multiline_items']); + } + + public function testManyNewlines() { + $this->assertSame ('A quick +fox + + +jumped +over + + + + + +a lazy + + + +dog', $this->yaml['many_lines']); + } + + public function testWerte() { + $this->assertSame (array ('1' => 'nummer 1', '0' => 'Stunde 0'), $this->yaml['werte']); + } + + /* public function testNoIndent() { + $this->assertSame (array( + array ('record1'=>'value1'), + array ('record2'=>'value2') + ) + , $this->yaml['noindent_records']); + } */ + + public function testColonsInKeys() { + $this->assertSame (array (1000), $this->yaml['a:1']); + } + + public function testColonsInKeys2() { + $this->assertSame (array (2000), $this->yaml['a:2']); + } + + public function testSpecialCharacters() { + $this->assertSame ('[{]]{{]]', $this->yaml['special_characters']); + } + + public function testAngleQuotes() { + $Quotes = Spyc::YAMLLoad('quotes.yaml'); + $this->assertEquals (array ('html_tags' => array ('
    ', '

    '), 'html_content' => array ('

    hello world

    ', 'hello
    world'), 'text_content' => array ('hello world')), + $Quotes); + } + + public function testFailingColons() { + $Failing = Spyc::YAMLLoad('failing1.yaml'); + $this->assertSame (array ('MyObject' => array ('Prop1' => array ('key1:val1'))), + $Failing); + } + +} \ No newline at end of file diff --git a/application/third_party/CIUnit/libraries/spyc/tests/failing1.yaml b/application/third_party/CIUnit/libraries/spyc/tests/failing1.yaml new file mode 100755 index 0000000..6906a51 --- /dev/null +++ b/application/third_party/CIUnit/libraries/spyc/tests/failing1.yaml @@ -0,0 +1,2 @@ +MyObject: + Prop1: {key1:val1} \ No newline at end of file diff --git a/application/third_party/CIUnit/libraries/spyc/tests/indent_1.yaml b/application/third_party/CIUnit/libraries/spyc/tests/indent_1.yaml new file mode 100755 index 0000000..5a55434 --- /dev/null +++ b/application/third_party/CIUnit/libraries/spyc/tests/indent_1.yaml @@ -0,0 +1,53 @@ +root: + child_1: 2 + + child_2: 0 + child_3: 1 + +root2: + child_1: 1 +# A comment + child_2: 2 + +displays: + - resolutions: + 1024: 768 + - resolutions: + 1920: 1200 + +display: + - resolutions: + 1024: 768 + 1920: 1200 + producer: "Nec" + +nested_hashes_and_seqs: + - { row: 0, col: 0, headsets_affected: [{ports: [0], side: left}], switch_function: {ics_ptt: true} } + +easier_nest: { h: [{a: b, a1: b1}, {c: d}] } + +steps: + - step: &id001 + instrument: Lasik 2000 + pulseEnergy: 5.4 + pulseDuration: 12 + repetition: 1000 + spotSize: 1mm + - step: + <<: *id001 + spotSize: 2mm + +death masks are: + sad: 2 + <<: {magnificent: 4} + +login: &login + adapter: mysql + host: localhost + +development: + database: rails_dev + <<: *login + +"key": "value:" +colon_only: ":" \ No newline at end of file diff --git a/application/third_party/CIUnit/libraries/spyc/tests/quotes.yaml b/application/third_party/CIUnit/libraries/spyc/tests/quotes.yaml new file mode 100755 index 0000000..2ceea86 --- /dev/null +++ b/application/third_party/CIUnit/libraries/spyc/tests/quotes.yaml @@ -0,0 +1,8 @@ +html_tags: + -
    + -

    +html_content: + -

    hello world

    + - hello
    world +text_content: + - hello world \ No newline at end of file diff --git a/application/views/account/password.php b/application/views/account/password.php new file mode 100755 index 0000000..eb6d26f --- /dev/null +++ b/application/views/account/password.php @@ -0,0 +1,38 @@ + + + +
    + Fix the following errors: + +

    + +
    + + +load->view('account/side_nav'); ?> +
    +
    +
    + Change Password +
    +
    +
    + + + +
    +
    +
    + +
    +
     
    +
    + +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/application/views/account/side_nav.php b/application/views/account/side_nav.php new file mode 100755 index 0000000..25f6c08 --- /dev/null +++ b/application/views/account/side_nav.php @@ -0,0 +1,15 @@ +uri->segment(2) ?> + \ No newline at end of file diff --git a/application/views/account/status.php b/application/views/account/status.php new file mode 100755 index 0000000..6b1c1d3 --- /dev/null +++ b/application/views/account/status.php @@ -0,0 +1,48 @@ +session->userdata('username') != 'guest') $this->load->view('account/side_nav'); //Not the guest account ?> +
    +

    Your Account

    +
    +
    User Id
    +
    session->userdata('num_format') == 1) ? $this->todo->kanji_num($this->session->userdata('uid')) : $this->session->userdata('uid') ?>
    + +
    Username
    +
    + +
    Email
    +
    + + +
    Timezone
    +
    + +
    +
    Id Number Format
    +
    + +
    +
    +
    \ No newline at end of file diff --git a/application/views/footer.php b/application/views/footer.php new file mode 100755 index 0000000..94c461d --- /dev/null +++ b/application/views/footer.php @@ -0,0 +1,28 @@ + +page->num_queries() ?> +
    +
    + Generated in benchmark->elapsed_time();?> seconds, quer +
    + + + + +session->userdata('uid') == 1){$this->output->enable_profiler(TRUE);} ?> + + + + + \ No newline at end of file diff --git a/application/views/friend/ajax_search.php b/application/views/friend/ajax_search.php new file mode 100755 index 0000000..3a65992 --- /dev/null +++ b/application/views/friend/ajax_search.php @@ -0,0 +1,13 @@ + + + + + "> + + + + + + + + diff --git a/application/views/friend/group_list.php b/application/views/friend/group_list.php new file mode 100755 index 0000000..5982128 --- /dev/null +++ b/application/views/friend/group_list.php @@ -0,0 +1,46 @@ +load->view('friend/side_nav'); ?> +
    + session->userdata('username') !== 'guest'): ?> +
    +
    + Add Group +
    +
    +
    + +
    + +
     
    +
    +
    +
    +
    + + + + + + + + + + + + + + > + + + + + + + + + + + +
    Your Groups
    Name 
    + +
    You don't have any friend groups
    +
    \ No newline at end of file diff --git a/application/views/friend/list.php b/application/views/friend/list.php new file mode 100755 index 0000000..5d91d62 --- /dev/null +++ b/application/views/friend/list.php @@ -0,0 +1,30 @@ +load->view('friend/side_nav'); ?> +
    + + + + + + + + + + + + + + + "> + + + + + + + +
    Friends
    UsernameEmailGroups
    + +

    Friends

    +

    You currently have no friends :(

    + +
    \ No newline at end of file diff --git a/application/views/friend/manage.php b/application/views/friend/manage.php new file mode 100755 index 0000000..3e7d70c --- /dev/null +++ b/application/views/friend/manage.php @@ -0,0 +1,31 @@ +load->view('friend/side_nav'); ?> +session->userdata('uid'); ?> +uri->segment('3'); ?> +
    +

    Manage Group

    +
    " method="post"> +
    + Group Members +
    +
    +
    + +
    +
    +
    + +
    +
     
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/application/views/friend/requests.php b/application/views/friend/requests.php new file mode 100755 index 0000000..4b30d01 --- /dev/null +++ b/application/views/friend/requests.php @@ -0,0 +1,33 @@ +load->view('friend/side_nav'); ?> +
    + + + + + + + + + + + + + + + "> + + + + + + + +
    Friend Requests
    UsernameEmailAccept/Reject
    + + +
    + +

    Friend Requests

    +

    You currently have no requests.

    + +
    \ No newline at end of file diff --git a/application/views/friend/search.php b/application/views/friend/search.php new file mode 100755 index 0000000..4a4091e --- /dev/null +++ b/application/views/friend/search.php @@ -0,0 +1,24 @@ +load->view('friend/side_nav'); ?> +
    +
    +
    + Find Friends +
    +
    +
    + +
    +
    +
    + + + + + + + + + +
     UsernameEmail
    +
    diff --git a/application/views/friend/side_nav.php b/application/views/friend/side_nav.php new file mode 100755 index 0000000..fbdce0e --- /dev/null +++ b/application/views/friend/side_nav.php @@ -0,0 +1,36 @@ + + +
    + Fix the following errors: + +

    + +
    + + +uri->segment(2) ?> + \ No newline at end of file diff --git a/application/views/header.php b/application/views/header.php new file mode 100755 index 0000000..ef0f3c4 --- /dev/null +++ b/application/views/header.php @@ -0,0 +1,10 @@ + + + + + + <?= $title ?> + + +> +load->view('menu') ?> diff --git a/application/views/login/login.php b/application/views/login/login.php new file mode 100755 index 0000000..3ebf1b0 --- /dev/null +++ b/application/views/login/login.php @@ -0,0 +1,49 @@ + +
    + Fix the following errors: + +

    + +
    + +
    +

    What is Tim's Todo?

    +

    Tim's Todo is a task manager that allows you to...

    +
      +
    • Create, edit, and categorize tasks
    • +
    • Send email reminders that a task is due
    • +
    • Share tasks with friends
    • +
    • Create task checklists
    • +
    • Comment on your tasks, and those shared with you
    • +
    +

    If it sounds interesting, or useful, sign up and try it out.

    +

    Want to try it without creating an account? Login with username: guest and password: guest

    +

    It's nice to have feedback. Send suggestions/comments/criticism to tim (at) timshomepage.net or @timw4mail on Twitter.

    +
    +
    + +
    + Login +
    +
    +
    + +
    +
    +
    + +
    +
     
    +
    + +
    +
    +
    + +
    +
    + Don't have an account? Register +
    + diff --git a/application/views/login/register.php b/application/views/login/register.php new file mode 100755 index 0000000..3666a2e --- /dev/null +++ b/application/views/login/register.php @@ -0,0 +1,42 @@ + +
    + Fix the following errors: + +

    + +
    + +
    + Already have an account? Login + +
    +
    + +
    + Create an account +
    +
    +
    + +
    +
    +
    + + +
    +
    +
    + +
    +
     
    +
    + +
    +
    +
    + +
    diff --git a/application/views/menu.php b/application/views/menu.php new file mode 100755 index 0000000..c384d6b --- /dev/null +++ b/application/views/menu.php @@ -0,0 +1,39 @@ +
    +
    + Tim's ToDo +
    Tim's Todo
    +
    + session->userdata('uid') != FALSE): ?> + + +
    + + +
    + Fix the following errors: + +

    + +
    + + +session->flashdata('message') != FALSE): ?> +page->set_message($this->session->flashdata('message_type'), $this->session->flashdata('message'), TRUE); ?> + +
    diff --git a/application/views/message.php b/application/views/message.php new file mode 100755 index 0000000..311e3ff --- /dev/null +++ b/application/views/message.php @@ -0,0 +1,4 @@ +
    + + +
    \ No newline at end of file diff --git a/application/views/task/add.php b/application/views/task/add.php new file mode 100755 index 0000000..607ca6d --- /dev/null +++ b/application/views/task/add.php @@ -0,0 +1,165 @@ +load->view('task/side_nav'); ?> +
    +

    Add Task

    + +
    + Task +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    + +
    + +
    +
    + +
    + +
    +
    + + + +
    +
    +
    />
    +
     
    +
    + : + : + before the task is due. +
    +
    +
    +
    + Task Permissions +
    +
    +
    +
    +
    +
    Share with:
    +
    + + +   +   + + +
    + +
    Friend Settings
    +
    +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    + You don't currently have any friends :( +
    + + +
    Group-wide Settings
    +
    +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    + You need to create friend groups before you can share tasks. +
    + +
    +
    +
    +
    +
     
    +
    + +
    +
    +
    + +
    \ No newline at end of file diff --git a/application/views/task/ajax_checklist.php b/application/views/task/ajax_checklist.php new file mode 100755 index 0000000..2f3ffcd --- /dev/null +++ b/application/views/task/ajax_checklist.php @@ -0,0 +1,5 @@ + +
  • + /> +    +
  • \ No newline at end of file diff --git a/application/views/task/calendar.php b/application/views/task/calendar.php new file mode 100755 index 0000000..7f2e26c --- /dev/null +++ b/application/views/task/calendar.php @@ -0,0 +1,33 @@ +load->view('task/side_nav'); ?> +uri->segment(3); +$m = $this->uri->segment(4); +$next = ($this->uri->segment(4) == FALSE) ? $this->calendar->adjust_date(date('m') + 1, date('Y')) : + $this->calendar->adjust_date($m + 1, $y); + +$prev = ($this->uri->segment(4) == FALSE) ? $this->calendar->adjust_date(date('m') - 1, date('Y')) : +$this->calendar->adjust_date($m - 1, $y); ?> +
    +

    Task Calendar

    +

    Today is
    + « Previous Month   + Next Month » +

    + + + + + + + + + + + + + + + + +
    +
    SundayMondayTuesdayWednesdayThursdayFridaySaturday
    +
    \ No newline at end of file diff --git a/application/views/task/cat_add.php b/application/views/task/cat_add.php new file mode 100755 index 0000000..ee12f24 --- /dev/null +++ b/application/views/task/cat_add.php @@ -0,0 +1,25 @@ +load->view('task/side_nav'); ?> +
    +
    +
    + Edit Category +
    +
    +
    + + +
    + +
    +
    + +
    + +
     
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/application/views/task/cat_list.php b/application/views/task/cat_list.php new file mode 100755 index 0000000..6997385 --- /dev/null +++ b/application/views/task/cat_list.php @@ -0,0 +1,64 @@ +load->view('task/side_nav'); ?> +
    +
    +
    + Add Category +
    +
    +
    + +
    + +
    +
    + +
    + +
     
    +
    +
    +
    +
    + + + + + session->userdata('num_format') != -1): ?> + + + + + + + + + + + + > + session->userdata('num_format') != -1): ?> + + + + + + + + + + + +
    Categories
    IDNameDescription Type
    session->userdata('num_format') == 1) ? $this->todo->kanji_num($c['id']) : $c['id']; ?> + + + + + + + + + +   + +
    +
    \ No newline at end of file diff --git a/application/views/task/checklist_view.php b/application/views/task/checklist_view.php new file mode 100755 index 0000000..a98d3fc --- /dev/null +++ b/application/views/task/checklist_view.php @@ -0,0 +1,15 @@ + +
    +
      + + + + +
    • + /> +    +
    • + + +
    +
    \ No newline at end of file diff --git a/application/views/task/comments_view.php b/application/views/task/comments_view.php new file mode 100755 index 0000000..c767c86 --- /dev/null +++ b/application/views/task/comments_view.php @@ -0,0 +1,21 @@ + +
    + + + +
    > +


    ()
    +
    + session->userdata('uid')): ?> + + Delete + + +
    +
    +
    + +
    + + +
    diff --git a/application/views/task/edit.php b/application/views/task/edit.php new file mode 100755 index 0000000..d977fa2 --- /dev/null +++ b/application/views/task/edit.php @@ -0,0 +1,211 @@ +load->view('task/side_nav'); ?> +
    +

    Edit Task

    + +

    Delete Task

    + + uri->segment(3)); ?> + +
    + Task +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    + +
    + +
    +
    + +
    + +
    +
    + +
    + +
    +
    + + + +
    +
    +
    />
    +
     
    +
    + : + : + before the task is due. +
    +
    +
    +
    + Task Permissions +
    +
    +
    />
    +
    +
    +
    Share with:
    +
    + + /> +   +   + + /> +
    + + +
    Friend Settings
    +
    +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    + You don't currently have any friends :( +
    + + + +
    Group-wide Settings
    +
    +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    + You need to create friend groups before you can share tasks. +
    + +
    +
    +
    +
    +
     
    +
    + + +
    +
    +
    + +
    + +
    + Add Checklist item +
    +
     
    +
     
    +
    +
    +    + +
    +
    + load->view('task/checklist_view'); ?> +
    +
    + Add Comment +
    +
     
    +
     
    +
     
    +
    + +
    + +
    +
    + load->view('task/comments_view'); ?> +
    +
    +
    \ No newline at end of file diff --git a/application/views/task/list.php b/application/views/task/list.php new file mode 100755 index 0000000..0dd5fd1 --- /dev/null +++ b/application/views/task/list.php @@ -0,0 +1,53 @@ +load->view('task/side_nav'); ?> +
    + + + + + + session->userdata('num_format') != -1): ?> + + + + + + + + + + + + + + + + "> + session->userdata('num_format') != -1): ?> + + + + + + + + + + + + +
    Tasks
    IdTaskStatusCategoryPriorityDueuri->segment(2) != 'archive') ? "Modified" : "Completed" ?>
    session->userdata('num_format') == 1) ? $this->todo->kanji_num($task['id']) : $task['id']; ?> + uri->segment(2) != 'archive' && $this->uri->segment(2) != 'shared'): ?> + Edit + + +
    + +
    + pagination->create_links(); ?> +
    + + +

    Tasks

    +

    You currently have no tasks.

    + +
    \ No newline at end of file diff --git a/application/views/task/side_nav.php b/application/views/task/side_nav.php new file mode 100755 index 0000000..92b8c51 --- /dev/null +++ b/application/views/task/side_nav.php @@ -0,0 +1,45 @@ + + +
    + Fix the following errors: + +

    + +
    + + +uri->segment(2) ?> + \ No newline at end of file diff --git a/application/views/task/view.php b/application/views/task/view.php new file mode 100755 index 0000000..f2264a9 --- /dev/null +++ b/application/views/task/view.php @@ -0,0 +1,113 @@ +load->view('task/side_nav'); ?> +
    +

    + + + + + + + + PERM_CHECKLIST_ACCESS): ?> +

    + + Delete Task + + Edit Task + +

    + +
    +
    Created
    +
    by
    + +
    Due
    +
    + +
    Priority
    +
    + +
    + +
    Status
    +
    + PERM_CHECKLIST_ACCESS): ?> +
    + +
    + + + +
    + +
    Modified
    +
    + +
    Category
    +
    + PERM_CHECKLIST_ACCESS): ?> +
    + +
    + + + +
    + +
    Task Description
    +
    + +
    + + +
    Task Groups
    +
    + +
    + PERM_READ_ACCESS): ?> +
    + + PERM_COMMENT_ACCESS): ?> +
    + PERM_CHECKLIST_ACCESS): ?> + + Add Checklist item +
    +   +
     
    */ ?> +
    +
    +    + +
    +
    + + load->view('task/checklist_view'); ?> +
    + +
    + Add Comment +
    +   +
     
    */ ?> +
     
    +
    + +
    + +
    +
    + load->view('task/comments_view'); ?> +
    +
    + +
    \ No newline at end of file diff --git a/phpci.yml b/phpci.yml new file mode 100755 index 0000000..677d096 --- /dev/null +++ b/phpci.yml @@ -0,0 +1,25 @@ +build_settings: + verbose: true + ignore: + - "application/third_party" + - "web" + - "system" + - "third_party" + - "tests" + +setup: + env: + APPLICATION_ENV: "development" + +test: + php_unit: + config: 'tests/phpunit.xml' + run_from: 'tests' + coverage: '../web/coverage/' + php_mess_detector: + allowed_warnings: 10 + rules: + - "unusedcode" + - "naming" + php_docblock_checker: + php_loc: diff --git a/system/.htaccess b/system/.htaccess new file mode 100755 index 0000000..14249c5 --- /dev/null +++ b/system/.htaccess @@ -0,0 +1 @@ +Deny from all \ No newline at end of file diff --git a/system/core/Benchmark.php b/system/core/Benchmark.php new file mode 100755 index 0000000..a5c3e99 --- /dev/null +++ b/system/core/Benchmark.php @@ -0,0 +1,118 @@ +marker[$name] = microtime(); + } + + // -------------------------------------------------------------------- + + /** + * Calculates the time difference between two marked points. + * + * If the first parameter is empty this function instead returns the + * {elapsed_time} pseudo-variable. This permits the full system + * execution time to be shown in a template. The output class will + * swap the real value for this variable. + * + * @access public + * @param string a particular marked point + * @param string a particular marked point + * @param integer the number of decimal places + * @return mixed + */ + function elapsed_time($point1 = '', $point2 = '', $decimals = 4) + { + if ($point1 == '') + { + return '{elapsed_time}'; + } + + if ( ! isset($this->marker[$point1])) + { + return ''; + } + + if ( ! isset($this->marker[$point2])) + { + $this->marker[$point2] = microtime(); + } + + list($sm, $ss) = explode(' ', $this->marker[$point1]); + list($em, $es) = explode(' ', $this->marker[$point2]); + + return number_format(($em + $es) - ($sm + $ss), $decimals); + } + + // -------------------------------------------------------------------- + + /** + * Memory Usage + * + * This function returns the {memory_usage} pseudo-variable. + * This permits it to be put it anywhere in a template + * without the memory being calculated until the end. + * The output class will swap the real value for this variable. + * + * @access public + * @return string + */ + function memory_usage() + { + return '{memory_usage}'; + } + +} + +// END CI_Benchmark class + +/* End of file Benchmark.php */ +/* Location: ./system/core/Benchmark.php */ \ No newline at end of file diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php new file mode 100755 index 0000000..3407817 --- /dev/null +++ b/system/core/CodeIgniter.php @@ -0,0 +1,402 @@ + $assign_to_config['subclass_prefix'])); + } + +/* + * ------------------------------------------------------ + * Set a liberal script execution time limit + * ------------------------------------------------------ + */ + if (function_exists("set_time_limit") == TRUE AND @ini_get("safe_mode") == 0) + { + @set_time_limit(300); + } + +/* + * ------------------------------------------------------ + * Start the timer... tick tock tick tock... + * ------------------------------------------------------ + */ + $BM =& load_class('Benchmark', 'core'); + $BM->mark('total_execution_time_start'); + $BM->mark('loading_time:_base_classes_start'); + +/* + * ------------------------------------------------------ + * Instantiate the hooks class + * ------------------------------------------------------ + */ + $EXT =& load_class('Hooks', 'core'); + +/* + * ------------------------------------------------------ + * Is there a "pre_system" hook? + * ------------------------------------------------------ + */ + $EXT->_call_hook('pre_system'); + +/* + * ------------------------------------------------------ + * Instantiate the config class + * ------------------------------------------------------ + */ + $CFG =& load_class('Config', 'core'); + + // Do we have any manually set config items in the index.php file? + if (isset($assign_to_config)) + { + $CFG->_assign_to_config($assign_to_config); + } + +/* + * ------------------------------------------------------ + * Instantiate the UTF-8 class + * ------------------------------------------------------ + * + * Note: Order here is rather important as the UTF-8 + * class needs to be used very early on, but it cannot + * properly determine if UTf-8 can be supported until + * after the Config class is instantiated. + * + */ + + $UNI =& load_class('Utf8', 'core'); + +/* + * ------------------------------------------------------ + * Instantiate the URI class + * ------------------------------------------------------ + */ + $URI =& load_class('URI', 'core'); + +/* + * ------------------------------------------------------ + * Instantiate the routing class and set the routing + * ------------------------------------------------------ + */ + $RTR =& load_class('Router', 'core'); + $RTR->_set_routing(); + + // Set any routing overrides that may exist in the main index file + if (isset($routing)) + { + $RTR->_set_overrides($routing); + } + +/* + * ------------------------------------------------------ + * Instantiate the output class + * ------------------------------------------------------ + */ + $OUT =& load_class('Output', 'core'); + +/* + * ------------------------------------------------------ + * Is there a valid cache file? If so, we're done... + * ------------------------------------------------------ + */ + if ($EXT->_call_hook('cache_override') === FALSE) + { + if ($OUT->_display_cache($CFG, $URI) == TRUE) + { + exit; + } + } + +/* + * ----------------------------------------------------- + * Load the security class for xss and csrf support + * ----------------------------------------------------- + */ + $SEC =& load_class('Security', 'core'); + +/* + * ------------------------------------------------------ + * Load the Input class and sanitize globals + * ------------------------------------------------------ + */ + $IN =& load_class('Input', 'core'); + +/* + * ------------------------------------------------------ + * Load the Language class + * ------------------------------------------------------ + */ + $LANG =& load_class('Lang', 'core'); + +/* + * ------------------------------------------------------ + * Load the app controller and local controller + * ------------------------------------------------------ + * + */ + // Load the base controller class + require BASEPATH.'core/Controller.php'; + + function &get_instance() + { + return CI_Controller::get_instance(); + } + + + if (file_exists(APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php')) + { + require APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php'; + } + + // Load the local application controller + // Note: The Router class automatically validates the controller path using the router->_validate_request(). + // If this include fails it means that the default controller in the Routes.php file is not resolving to something valid. + if ( ! file_exists(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().'.php')) + { + show_error('Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.'); + } + + include(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().'.php'); + + // Set a mark point for benchmarking + $BM->mark('loading_time:_base_classes_end'); + +/* + * ------------------------------------------------------ + * Security check + * ------------------------------------------------------ + * + * None of the functions in the app controller or the + * loader class can be called via the URI, nor can + * controller functions that begin with an underscore + */ + $class = $RTR->fetch_class(); + $method = $RTR->fetch_method(); + + if ( ! class_exists($class) + OR strncmp($method, '_', 1) == 0 + OR in_array(strtolower($method), array_map('strtolower', get_class_methods('CI_Controller'))) + ) + { + if ( ! empty($RTR->routes['404_override'])) + { + $x = explode('/', $RTR->routes['404_override']); + $class = $x[0]; + $method = (isset($x[1]) ? $x[1] : 'index'); + if ( ! class_exists($class)) + { + if ( ! file_exists(APPPATH.'controllers/'.$class.'.php')) + { + show_404("{$class}/{$method}"); + } + + include_once(APPPATH.'controllers/'.$class.'.php'); + } + } + else + { + show_404("{$class}/{$method}"); + } + } + +/* + * ------------------------------------------------------ + * Is there a "pre_controller" hook? + * ------------------------------------------------------ + */ + $EXT->_call_hook('pre_controller'); + +/* + * ------------------------------------------------------ + * Instantiate the requested controller + * ------------------------------------------------------ + */ + // Mark a start point so we can benchmark the controller + $BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_start'); + + $CI = new $class(); + +/* + * ------------------------------------------------------ + * Is there a "post_controller_constructor" hook? + * ------------------------------------------------------ + */ + $EXT->_call_hook('post_controller_constructor'); + +/* + * ------------------------------------------------------ + * Call the requested method + * ------------------------------------------------------ + */ + // Is there a "remap" function? If so, we call it instead + if (method_exists($CI, '_remap')) + { + $CI->_remap($method, array_slice($URI->rsegments, 2)); + } + else + { + // is_callable() returns TRUE on some versions of PHP 5 for private and protected + // methods, so we'll use this workaround for consistent behavior + if ( ! in_array(strtolower($method), array_map('strtolower', get_class_methods($CI)))) + { + // Check and see if we are using a 404 override and use it. + if ( ! empty($RTR->routes['404_override'])) + { + $x = explode('/', $RTR->routes['404_override']); + $class = $x[0]; + $method = (isset($x[1]) ? $x[1] : 'index'); + if ( ! class_exists($class)) + { + if ( ! file_exists(APPPATH.'controllers/'.$class.'.php')) + { + show_404("{$class}/{$method}"); + } + + include_once(APPPATH.'controllers/'.$class.'.php'); + unset($CI); + $CI = new $class(); + } + } + else + { + show_404("{$class}/{$method}"); + } + } + + // Call the requested method. + // Any URI segments present (besides the class/function) will be passed to the method for convenience + call_user_func_array(array(&$CI, $method), array_slice($URI->rsegments, 2)); + } + + + // Mark a benchmark end point + $BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_end'); + +/* + * ------------------------------------------------------ + * Is there a "post_controller" hook? + * ------------------------------------------------------ + */ + $EXT->_call_hook('post_controller'); + +/* + * ------------------------------------------------------ + * Send the final rendered output to the browser + * ------------------------------------------------------ + */ + if ($EXT->_call_hook('display_override') === FALSE) + { + $OUT->_display(); + } + +/* + * ------------------------------------------------------ + * Is there a "post_system" hook? + * ------------------------------------------------------ + */ + $EXT->_call_hook('post_system'); + +/* + * ------------------------------------------------------ + * Close the DB connection if one exists + * ------------------------------------------------------ + */ + if (class_exists('CI_DB') AND isset($CI->db)) + { + $CI->db->close(); + } + + +/* End of file CodeIgniter.php */ +/* Location: ./system/core/CodeIgniter.php */ \ No newline at end of file diff --git a/system/core/Common.php b/system/core/Common.php new file mode 100755 index 0000000..1d93fa9 --- /dev/null +++ b/system/core/Common.php @@ -0,0 +1,564 @@ + 5 +* we'll set a static variable. +* +* @access public +* @param string +* @return bool TRUE if the current version is $version or higher +*/ +if ( ! function_exists('is_php')) +{ + function is_php($version = '5.0.0') + { + static $_is_php; + $version = (string)$version; + + if ( ! isset($_is_php[$version])) + { + $_is_php[$version] = (version_compare(PHP_VERSION, $version) < 0) ? FALSE : TRUE; + } + + return $_is_php[$version]; + } +} + +// ------------------------------------------------------------------------ + +/** + * Tests for file writability + * + * is_writable() returns TRUE on Windows servers when you really can't write to + * the file, based on the read-only attribute. is_writable() is also unreliable + * on Unix servers if safe_mode is on. + * + * @access private + * @return void + */ +if ( ! function_exists('is_really_writable')) +{ + function is_really_writable($file) + { + // If we're on a Unix server with safe_mode off we call is_writable + if (DIRECTORY_SEPARATOR == '/' AND @ini_get("safe_mode") == FALSE) + { + return is_writable($file); + } + + // For windows servers and safe_mode "on" installations we'll actually + // write a file then read it. Bah... + if (is_dir($file)) + { + $file = rtrim($file, '/').'/'.md5(mt_rand(1,100).mt_rand(1,100)); + + if (($fp = @fopen($file, FOPEN_WRITE_CREATE)) === FALSE) + { + return FALSE; + } + + fclose($fp); + @chmod($file, DIR_WRITE_MODE); + @unlink($file); + return TRUE; + } + elseif ( ! is_file($file) OR ($fp = @fopen($file, FOPEN_WRITE_CREATE)) === FALSE) + { + return FALSE; + } + + fclose($fp); + return TRUE; + } +} + +// ------------------------------------------------------------------------ + +/** +* Class registry +* +* This function acts as a singleton. If the requested class does not +* exist it is instantiated and set to a static variable. If it has +* previously been instantiated the variable is returned. +* +* @access public +* @param string the class name being requested +* @param string the directory where the class should be found +* @param string the class name prefix +* @return object +*/ +if ( ! function_exists('load_class')) +{ + function &load_class($class, $directory = 'libraries', $prefix = 'CI_') + { + static $_classes = array(); + + // Does the class exist? If so, we're done... + if (isset($_classes[$class])) + { + return $_classes[$class]; + } + + $name = FALSE; + + // Look for the class first in the local application/libraries folder + // then in the native system/libraries folder + foreach (array(APPPATH, BASEPATH) as $path) + { + if (file_exists($path.$directory.'/'.$class.'.php')) + { + $name = $prefix.$class; + + if (class_exists($name) === FALSE) + { + require($path.$directory.'/'.$class.'.php'); + } + + break; + } + } + + // Is the request a class extension? If so we load it too + if (file_exists(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.'.php')) + { + $name = config_item('subclass_prefix').$class; + + if (class_exists($name) === FALSE) + { + require(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.'.php'); + } + } + + // Did we find the class? + if ($name === FALSE) + { + // Note: We use exit() rather then show_error() in order to avoid a + // self-referencing loop with the Excptions class + exit('Unable to locate the specified class: '.$class.'.php'); + } + + // Keep track of what we just loaded + is_loaded($class); + + $_classes[$class] = new $name(); + return $_classes[$class]; + } +} + +// -------------------------------------------------------------------- + +/** +* Keeps track of which libraries have been loaded. This function is +* called by the load_class() function above +* +* @access public +* @return array +*/ +if ( ! function_exists('is_loaded')) +{ + function &is_loaded($class = '') + { + static $_is_loaded = array(); + + if ($class != '') + { + $_is_loaded[strtolower($class)] = $class; + } + + return $_is_loaded; + } +} + +// ------------------------------------------------------------------------ + +/** +* Loads the main config.php file +* +* This function lets us grab the config file even if the Config class +* hasn't been instantiated yet +* +* @access private +* @return array +*/ +if ( ! function_exists('get_config')) +{ + function get_config($replace = array()) + { + static $_config; + + if (isset($_config)) + { + return $_config[0]; + } + + // Is the config file in the environment folder? + if ( ! defined('ENVIRONMENT') OR ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config.php')) + { + $file_path = APPPATH.'config/config.php'; + } + + // Fetch the config file + if ( ! file_exists($file_path)) + { + exit('The configuration file does not exist.'); + } + + require($file_path); + + // Does the $config array exist in the file? + if ( ! isset($config) OR ! is_array($config)) + { + exit('Your config file does not appear to be formatted correctly.'); + } + + // Are any values being dynamically replaced? + if (count($replace) > 0) + { + foreach ($replace as $key => $val) + { + if (isset($config[$key])) + { + $config[$key] = $val; + } + } + } + + return $_config[0] =& $config; + } +} + +// ------------------------------------------------------------------------ + +/** +* Returns the specified config item +* +* @access public +* @return mixed +*/ +if ( ! function_exists('config_item')) +{ + function config_item($item) + { + static $_config_item = array(); + + if ( ! isset($_config_item[$item])) + { + $config =& get_config(); + + if ( ! isset($config[$item])) + { + return FALSE; + } + $_config_item[$item] = $config[$item]; + } + + return $_config_item[$item]; + } +} + +// ------------------------------------------------------------------------ + +/** +* Error Handler +* +* This function lets us invoke the exception class and +* display errors using the standard error template located +* in application/errors/errors.php +* This function will send the error page directly to the +* browser and exit. +* +* @access public +* @return void +*/ +if ( ! function_exists('show_error')) +{ + function show_error($message, $status_code = 500, $heading = 'An Error Was Encountered') + { + $_error =& load_class('Exceptions', 'core'); + echo $_error->show_error($heading, $message, 'error_general', $status_code); + exit; + } +} + +// ------------------------------------------------------------------------ + +/** +* 404 Page Handler +* +* This function is similar to the show_error() function above +* However, instead of the standard error template it displays +* 404 errors. +* +* @access public +* @return void +*/ +if ( ! function_exists('show_404')) +{ + function show_404($page = '', $log_error = TRUE) + { + $_error =& load_class('Exceptions', 'core'); + $_error->show_404($page, $log_error); + exit; + } +} + +// ------------------------------------------------------------------------ + +/** +* Error Logging Interface +* +* We use this as a simple mechanism to access the logging +* class and send messages to be logged. +* +* @access public +* @return void +*/ +if ( ! function_exists('log_message')) +{ + function log_message($level = '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 + */ +if ( ! function_exists('set_status_header')) +{ + function set_status_header($code = 200, $text = '') + { + $stati = array( + 200 => 'OK', + 201 => 'Created', + 202 => 'Accepted', + 203 => 'Non-Authoritative Information', + 204 => 'No Content', + 205 => 'Reset Content', + 206 => 'Partial Content', + + 300 => 'Multiple Choices', + 301 => 'Moved Permanently', + 302 => 'Found', + 304 => 'Not Modified', + 305 => 'Use Proxy', + 307 => 'Temporary Redirect', + + 400 => 'Bad Request', + 401 => 'Unauthorized', + 403 => 'Forbidden', + 404 => 'Not Found', + 405 => 'Method Not Allowed', + 406 => 'Not Acceptable', + 407 => 'Proxy Authentication Required', + 408 => 'Request Timeout', + 409 => 'Conflict', + 410 => 'Gone', + 411 => 'Length Required', + 412 => 'Precondition Failed', + 413 => 'Request Entity Too Large', + 414 => 'Request-URI Too Long', + 415 => 'Unsupported Media Type', + 416 => 'Requested Range Not Satisfiable', + 417 => 'Expectation Failed', + + 500 => 'Internal Server Error', + 501 => 'Not Implemented', + 502 => 'Bad Gateway', + 503 => 'Service Unavailable', + 504 => 'Gateway Timeout', + 505 => 'HTTP Version Not Supported' + ); + + if ($code == '' OR ! is_numeric($code)) + { + show_error('Status codes must be numeric', 500); + } + + if (isset($stati[$code]) AND $text == '') + { + $text = $stati[$code]; + } + + if ($text == '') + { + show_error('No status text available. Please check your status code number or supply your own message text.', 500); + } + + $server_protocol = (isset($_SERVER['SERVER_PROTOCOL'])) ? $_SERVER['SERVER_PROTOCOL'] : FALSE; + + if (substr(php_sapi_name(), 0, 3) == 'cgi') + { + header("Status: {$code} {$text}", TRUE); + } + elseif ($server_protocol == 'HTTP/1.1' OR $server_protocol == 'HTTP/1.0') + { + header($server_protocol." {$code} {$text}", TRUE, $code); + } + else + { + header("HTTP/1.1 {$code} {$text}", TRUE, $code); + } + } +} + +// -------------------------------------------------------------------- + +/** +* Exception Handler +* +* This is the custom exception handler that is declaired at the top +* of Codeigniter.php. The main reason we use this is to permit +* PHP errors to be logged in our own log files since the user may +* not have access to server logs. Since this function +* effectively intercepts PHP errors, however, we also need +* to display errors based on the current error_reporting level. +* We do that with the use of a PHP error template. +* +* @access private +* @return void +*/ +if ( ! function_exists('_exception_handler')) +{ + function _exception_handler($severity, $message, $filepath, $line) + { + // We don't bother with "strict" notices since they tend to fill up + // the log file with excess information that isn't normally very helpful. + // For example, if you are running PHP 5 and you use version 4 style + // class functions (without prefixes like "public", "private", etc.) + // you'll get notices telling you that these have been deprecated. + if ($severity == E_STRICT) + { + return; + } + + $_error =& load_class('Exceptions', 'core'); + + // Should we display the error? We'll get the current error_reporting + // level and add its bits with the severity bits to find out. + if (($severity & error_reporting()) == $severity) + { + $_error->show_php_error($severity, $message, $filepath, $line); + } + + // Should we log the error? No? We're done... + if (config_item('log_threshold') == 0) + { + return; + } + + $_error->log_exception($severity, $message, $filepath, $line); + } +} + +// -------------------------------------------------------------------- + +/** + * Remove Invisible Characters + * + * This prevents sandwiching null characters + * between ascii characters, like Java\0script. + * + * @access public + * @param string + * @return string + */ +if ( ! function_exists('remove_invisible_characters')) +{ + function remove_invisible_characters($str, $url_encoded = TRUE) + { + $non_displayables = array(); + + // every control character except newline (dec 10) + // carriage return (dec 13), and horizontal tab (dec 09) + + if ($url_encoded) + { + $non_displayables[] = '/%0[0-8bcef]/'; // url encoded 00-08, 11, 12, 14, 15 + $non_displayables[] = '/%1[0-9a-f]/'; // url encoded 16-31 + } + + $non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S'; // 00-08, 11, 12, 14-31, 127 + + do + { + $str = preg_replace($non_displayables, '', $str, -1, $count); + } + while ($count); + + return $str; + } +} + +// ------------------------------------------------------------------------ + +/** +* Returns HTML escaped variable +* +* @access public +* @param mixed +* @return mixed +*/ +if ( ! function_exists('html_escape')) +{ + function html_escape($var) + { + if (is_array($var)) + { + return array_map('html_escape', $var); + } + else + { + return htmlspecialchars($var, ENT_QUOTES, config_item('charset')); + } + } +} + +/* End of file Common.php */ +/* Location: ./system/core/Common.php */ \ No newline at end of file diff --git a/system/core/Config.php b/system/core/Config.php new file mode 100755 index 0000000..46ed936 --- /dev/null +++ b/system/core/Config.php @@ -0,0 +1,379 @@ +config =& get_config(); + log_message('debug', "Config Class Initialized"); + + // Set the base_url automatically if none was provided + if ($this->config['base_url'] == '') + { + if (isset($_SERVER['HTTP_HOST'])) + { + $base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http'; + $base_url .= '://'. $_SERVER['HTTP_HOST']; + $base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); + } + + else + { + $base_url = 'http://localhost/'; + } + + $this->set_item('base_url', $base_url); + } + } + + // -------------------------------------------------------------------- + + /** + * Load Config File + * + * @access public + * @param string the config file name + * @param boolean if configuration values should be loaded into their own section + * @param boolean true if errors should just return false, false if an error message should be displayed + * @return boolean if the file was loaded correctly + */ + function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE) + { + $file = ($file == '') ? 'config' : str_replace('.php', '', $file); + $found = FALSE; + $loaded = FALSE; + + $check_locations = defined('ENVIRONMENT') + ? array(ENVIRONMENT.'/'.$file, $file) + : array($file); + + foreach ($this->_config_paths as $path) + { + foreach ($check_locations as $location) + { + $file_path = $path.'config/'.$location.'.php'; + + if (in_array($file_path, $this->is_loaded, TRUE)) + { + $loaded = TRUE; + continue 2; + } + + if (file_exists($file_path)) + { + $found = TRUE; + break; + } + } + + if ($found === FALSE) + { + continue; + } + + include($file_path); + + if ( ! isset($config) OR ! is_array($config)) + { + if ($fail_gracefully === TRUE) + { + return FALSE; + } + show_error('Your '.$file_path.' file does not appear to contain a valid configuration array.'); + } + + if ($use_sections === TRUE) + { + if (isset($this->config[$file])) + { + $this->config[$file] = array_merge($this->config[$file], $config); + } + else + { + $this->config[$file] = $config; + } + } + else + { + $this->config = array_merge($this->config, $config); + } + + $this->is_loaded[] = $file_path; + unset($config); + + $loaded = TRUE; + log_message('debug', 'Config file loaded: '.$file_path); + break; + } + + if ($loaded === FALSE) + { + if ($fail_gracefully === TRUE) + { + return FALSE; + } + show_error('The configuration file '.$file.'.php does not exist.'); + } + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Fetch a config file item + * + * + * @access public + * @param string the config item name + * @param string the index name + * @param bool + * @return string + */ + function item($item, $index = '') + { + if ($index == '') + { + if ( ! isset($this->config[$item])) + { + return FALSE; + } + + $pref = $this->config[$item]; + } + else + { + if ( ! isset($this->config[$index])) + { + return FALSE; + } + + if ( ! isset($this->config[$index][$item])) + { + return FALSE; + } + + $pref = $this->config[$index][$item]; + } + + return $pref; + } + + // -------------------------------------------------------------------- + + /** + * Fetch a config file item - adds slash after item (if item is not empty) + * + * @access public + * @param string the config item name + * @param bool + * @return string + */ + function slash_item($item) + { + if ( ! isset($this->config[$item])) + { + return FALSE; + } + if( trim($this->config[$item]) == '') + { + return ''; + } + + return rtrim($this->config[$item], '/').'/'; + } + + // -------------------------------------------------------------------- + + /** + * Site URL + * Returns base_url . index_page [. uri_string] + * + * @access public + * @param string the URI string + * @return string + */ + function site_url($uri = '') + { + if ($uri == '') + { + return $this->slash_item('base_url').$this->item('index_page'); + } + + if ($this->item('enable_query_strings') == FALSE) + { + $suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix'); + return $this->slash_item('base_url').$this->slash_item('index_page').$this->_uri_string($uri).$suffix; + } + else + { + return $this->slash_item('base_url').$this->item('index_page').'?'.$this->_uri_string($uri); + } + } + + // ------------------------------------------------------------- + + /** + * Base URL + * Returns base_url [. uri_string] + * + * @access public + * @param string $uri + * @return string + */ + function base_url($uri = '') + { + return $this->slash_item('base_url').ltrim($this->_uri_string($uri), '/'); + } + + // ------------------------------------------------------------- + + /** + * Build URI string for use in Config::site_url() and Config::base_url() + * + * @access protected + * @param $uri + * @return string + */ + protected function _uri_string($uri) + { + if ($this->item('enable_query_strings') == FALSE) + { + if (is_array($uri)) + { + $uri = implode('/', $uri); + } + $uri = trim($uri, '/'); + } + else + { + if (is_array($uri)) + { + $i = 0; + $str = ''; + foreach ($uri as $key => $val) + { + $prefix = ($i == 0) ? '' : '&'; + $str .= $prefix.$key.'='.$val; + $i++; + } + $uri = $str; + } + } + return $uri; + } + + // -------------------------------------------------------------------- + + /** + * System URL + * + * @access public + * @return string + */ + function system_url() + { + $x = explode("/", preg_replace("|/*(.+?)/*$|", "\\1", BASEPATH)); + return $this->slash_item('base_url').end($x).'/'; + } + + // -------------------------------------------------------------------- + + /** + * Set a config file item + * + * @access public + * @param string the config item key + * @param string the config item value + * @return void + */ + function set_item($item, $value) + { + $this->config[$item] = $value; + } + + // -------------------------------------------------------------------- + + /** + * Assign to Config + * + * This function is called by the front controller (CodeIgniter.php) + * after the Config class is instantiated. It permits config items + * to be assigned or overriden by variables contained in the index.php file + * + * @access private + * @param array + * @return void + */ + function _assign_to_config($items = array()) + { + if (is_array($items)) + { + foreach ($items as $key => $val) + { + $this->set_item($key, $val); + } + } + } +} + +// END CI_Config class + +/* End of file Config.php */ +/* Location: ./system/core/Config.php */ diff --git a/system/core/Controller.php b/system/core/Controller.php new file mode 100755 index 0000000..6ccaf97 --- /dev/null +++ b/system/core/Controller.php @@ -0,0 +1,64 @@ + $class) + { + $this->$var =& load_class($class); + } + + $this->load =& load_class('Loader', 'core'); + + $this->load->initialize(); + + log_message('debug', "Controller Class Initialized"); + } + + public static function &get_instance() + { + return self::$instance; + } +} +// END Controller class + +/* End of file Controller.php */ +/* Location: ./system/core/Controller.php */ \ No newline at end of file diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php new file mode 100755 index 0000000..4512096 --- /dev/null +++ b/system/core/Exceptions.php @@ -0,0 +1,193 @@ + 'Error', + E_WARNING => 'Warning', + E_PARSE => 'Parsing Error', + E_NOTICE => 'Notice', + E_CORE_ERROR => 'Core Error', + E_CORE_WARNING => 'Core Warning', + E_COMPILE_ERROR => 'Compile Error', + E_COMPILE_WARNING => 'Compile Warning', + E_USER_ERROR => 'User Error', + E_USER_WARNING => 'User Warning', + E_USER_NOTICE => 'User Notice', + E_STRICT => 'Runtime Notice' + ); + + + /** + * Constructor + */ + public function __construct() + { + $this->ob_level = ob_get_level(); + // Note: Do not log messages from this constructor. + } + + // -------------------------------------------------------------------- + + /** + * Exception Logger + * + * This function logs PHP generated error messages + * + * @access private + * @param string the error severity + * @param string the error string + * @param string the error filepath + * @param string the error line number + * @return string + */ + function log_exception($severity, $message, $filepath, $line) + { + $severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity]; + + log_message('error', 'Severity: '.$severity.' --> '.$message. ' '.$filepath.' '.$line, TRUE); + } + + // -------------------------------------------------------------------- + + /** + * 404 Page Not Found Handler + * + * @access private + * @param string the page + * @param bool log error yes/no + * @return string + */ + function show_404($page = '', $log_error = TRUE) + { + $heading = "404 Page Not Found"; + $message = "The page you requested was not found."; + + // By default we log this, but allow a dev to skip it + if ($log_error) + { + log_message('error', '404 Page Not Found --> '.$page); + } + + echo $this->show_error($heading, $message, 'error_404', 404); + exit; + } + + // -------------------------------------------------------------------- + + /** + * General Error Page + * + * This function takes an error message as input + * (either as a string or an array) and displays + * it using the specified template. + * + * @access private + * @param string the heading + * @param string the message + * @param string the template name + * @param int the status code + * @return string + */ + function show_error($heading, $message, $template = 'error_general', $status_code = 500) + { + set_status_header($status_code); + + $message = '

    '.implode('

    ', ( ! is_array($message)) ? array($message) : $message).'

    '; + + if (ob_get_level() > $this->ob_level + 1) + { + ob_end_flush(); + } + ob_start(); + include(APPPATH.'errors/'.$template.'.php'); + $buffer = ob_get_contents(); + ob_end_clean(); + return $buffer; + } + + // -------------------------------------------------------------------- + + /** + * Native PHP error handler + * + * @access private + * @param string the error severity + * @param string the error string + * @param string the error filepath + * @param string the error line number + * @return string + */ + function show_php_error($severity, $message, $filepath, $line) + { + $severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity]; + + $filepath = str_replace("\\", "/", $filepath); + + // For safety reasons we do not show the full file path + if (FALSE !== strpos($filepath, '/')) + { + $x = explode('/', $filepath); + $filepath = $x[count($x)-2].'/'.end($x); + } + + if (ob_get_level() > $this->ob_level + 1) + { + ob_end_flush(); + } + ob_start(); + include(APPPATH.'errors/error_php.php'); + $buffer = ob_get_contents(); + ob_end_clean(); + echo $buffer; + } + + +} +// END Exceptions Class + +/* End of file Exceptions.php */ +/* Location: ./system/core/Exceptions.php */ \ No newline at end of file diff --git a/system/core/Hooks.php b/system/core/Hooks.php new file mode 100755 index 0000000..ee5c230 --- /dev/null +++ b/system/core/Hooks.php @@ -0,0 +1,248 @@ +_initialize(); + log_message('debug', "Hooks Class Initialized"); + } + + // -------------------------------------------------------------------- + + /** + * Initialize the Hooks Preferences + * + * @access private + * @return void + */ + function _initialize() + { + $CFG =& load_class('Config', 'core'); + + // If hooks are not enabled in the config file + // there is nothing else to do + + if ($CFG->item('enable_hooks') == FALSE) + { + return; + } + + // Grab the "hooks" definition file. + // If there are no hooks, we're done. + + if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/hooks.php')) + { + include(APPPATH.'config/'.ENVIRONMENT.'/hooks.php'); + } + elseif (is_file(APPPATH.'config/hooks.php')) + { + include(APPPATH.'config/hooks.php'); + } + + + if ( ! isset($hook) OR ! is_array($hook)) + { + return; + } + + $this->hooks =& $hook; + $this->enabled = TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Call Hook + * + * Calls a particular hook + * + * @access private + * @param string the hook name + * @return mixed + */ + function _call_hook($which = '') + { + if ( ! $this->enabled OR ! isset($this->hooks[$which])) + { + return FALSE; + } + + if (isset($this->hooks[$which][0]) AND is_array($this->hooks[$which][0])) + { + foreach ($this->hooks[$which] as $val) + { + $this->_run_hook($val); + } + } + else + { + $this->_run_hook($this->hooks[$which]); + } + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Run Hook + * + * Runs a particular hook + * + * @access private + * @param array the hook details + * @return bool + */ + function _run_hook($data) + { + if ( ! is_array($data)) + { + return FALSE; + } + + // ----------------------------------- + // Safety - Prevents run-away loops + // ----------------------------------- + + // If the script being called happens to have the same + // hook call within it a loop can happen + + if ($this->in_progress == TRUE) + { + return; + } + + // ----------------------------------- + // Set file path + // ----------------------------------- + + if ( ! isset($data['filepath']) OR ! isset($data['filename'])) + { + return FALSE; + } + + $filepath = APPPATH.$data['filepath'].'/'.$data['filename']; + + if ( ! file_exists($filepath)) + { + return FALSE; + } + + // ----------------------------------- + // Set class/function name + // ----------------------------------- + + $class = FALSE; + $function = FALSE; + $params = ''; + + if (isset($data['class']) AND $data['class'] != '') + { + $class = $data['class']; + } + + if (isset($data['function'])) + { + $function = $data['function']; + } + + if (isset($data['params'])) + { + $params = $data['params']; + } + + if ($class === FALSE AND $function === FALSE) + { + return FALSE; + } + + // ----------------------------------- + // Set the in_progress flag + // ----------------------------------- + + $this->in_progress = TRUE; + + // ----------------------------------- + // Call the requested class and/or function + // ----------------------------------- + + if ($class !== FALSE) + { + if ( ! class_exists($class)) + { + require($filepath); + } + + $HOOK = new $class; + $HOOK->$function($params); + } + else + { + if ( ! function_exists($function)) + { + require($filepath); + } + + $function($params); + } + + $this->in_progress = FALSE; + return TRUE; + } + +} + +// END CI_Hooks class + +/* End of file Hooks.php */ +/* Location: ./system/core/Hooks.php */ \ No newline at end of file diff --git a/system/core/Input.php b/system/core/Input.php new file mode 100755 index 0000000..88afa8c --- /dev/null +++ b/system/core/Input.php @@ -0,0 +1,849 @@ +_allow_get_array = (config_item('allow_get_array') === TRUE); + $this->_enable_xss = (config_item('global_xss_filtering') === TRUE); + $this->_enable_csrf = (config_item('csrf_protection') === TRUE); + + global $SEC; + $this->security =& $SEC; + + // Do we need the UTF-8 class? + if (UTF8_ENABLED === TRUE) + { + global $UNI; + $this->uni =& $UNI; + } + + // Sanitize global arrays + $this->_sanitize_globals(); + } + + // -------------------------------------------------------------------- + + /** + * Fetch from array + * + * This is a helper function to retrieve values from global arrays + * + * @access private + * @param array + * @param string + * @param bool + * @return string + */ + function _fetch_from_array(&$array, $index = '', $xss_clean = FALSE) + { + if ( ! isset($array[$index])) + { + return FALSE; + } + + if ($xss_clean === TRUE) + { + return $this->security->xss_clean($array[$index]); + } + + return $array[$index]; + } + + // -------------------------------------------------------------------- + + /** + * Fetch an item from the GET array + * + * @access public + * @param string + * @param bool + * @return string + */ + function get($index = NULL, $xss_clean = FALSE) + { + // Check if a field has been provided + if ($index === NULL AND ! empty($_GET)) + { + $get = array(); + + // loop through the full _GET array + foreach (array_keys($_GET) as $key) + { + $get[$key] = $this->_fetch_from_array($_GET, $key, $xss_clean); + } + return $get; + } + + return $this->_fetch_from_array($_GET, $index, $xss_clean); + } + + // -------------------------------------------------------------------- + + /** + * Fetch an item from the POST array + * + * @access public + * @param string + * @param bool + * @return string + */ + function post($index = NULL, $xss_clean = FALSE) + { + // Check if a field has been provided + if ($index === NULL AND ! empty($_POST)) + { + $post = array(); + + // Loop through the full _POST array and return it + foreach (array_keys($_POST) as $key) + { + $post[$key] = $this->_fetch_from_array($_POST, $key, $xss_clean); + } + return $post; + } + + return $this->_fetch_from_array($_POST, $index, $xss_clean); + } + + + // -------------------------------------------------------------------- + + /** + * Fetch an item from either the GET array or the POST + * + * @access public + * @param string The index key + * @param bool XSS cleaning + * @return string + */ + function get_post($index = '', $xss_clean = FALSE) + { + if ( ! isset($_POST[$index]) ) + { + return $this->get($index, $xss_clean); + } + else + { + return $this->post($index, $xss_clean); + } + } + + // -------------------------------------------------------------------- + + /** + * Fetch an item from the COOKIE array + * + * @access public + * @param string + * @param bool + * @return string + */ + function cookie($index = '', $xss_clean = FALSE) + { + return $this->_fetch_from_array($_COOKIE, $index, $xss_clean); + } + + // ------------------------------------------------------------------------ + + /** + * Set cookie + * + * Accepts six parameter, or you can submit an associative + * array in the first parameter containing all the values. + * + * @access public + * @param mixed + * @param string the value of the cookie + * @param string the number of seconds until expiration + * @param string the cookie domain. Usually: .yourdomain.com + * @param string the cookie path + * @param string the cookie prefix + * @param bool true makes the cookie secure + * @return void + */ + function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE) + { + if (is_array($name)) + { + // always leave 'name' in last place, as the loop will break otherwise, due to $$item + foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'secure', 'name') as $item) + { + if (isset($name[$item])) + { + $$item = $name[$item]; + } + } + } + + if ($prefix == '' AND config_item('cookie_prefix') != '') + { + $prefix = config_item('cookie_prefix'); + } + if ($domain == '' AND config_item('cookie_domain') != '') + { + $domain = config_item('cookie_domain'); + } + if ($path == '/' AND config_item('cookie_path') != '/') + { + $path = config_item('cookie_path'); + } + if ($secure == FALSE AND config_item('cookie_secure') != FALSE) + { + $secure = config_item('cookie_secure'); + } + + if ( ! is_numeric($expire)) + { + $expire = time() - 86500; + } + else + { + $expire = ($expire > 0) ? time() + $expire : 0; + } + + setcookie($prefix.$name, $value, $expire, $path, $domain, $secure); + } + + // -------------------------------------------------------------------- + + /** + * Fetch an item from the SERVER array + * + * @access public + * @param string + * @param bool + * @return string + */ + function server($index = '', $xss_clean = FALSE) + { + return $this->_fetch_from_array($_SERVER, $index, $xss_clean); + } + + // -------------------------------------------------------------------- + + /** + * Fetch the IP Address + * + * @return string + */ + public function ip_address() + { + if ($this->ip_address !== FALSE) + { + return $this->ip_address; + } + + $proxy_ips = config_item('proxy_ips'); + if ( ! empty($proxy_ips)) + { + $proxy_ips = explode(',', str_replace(' ', '', $proxy_ips)); + foreach (array('HTTP_X_FORWARDED_FOR', 'HTTP_CLIENT_IP', 'HTTP_X_CLIENT_IP', 'HTTP_X_CLUSTER_CLIENT_IP') as $header) + { + if (($spoof = $this->server($header)) !== FALSE) + { + // Some proxies typically list the whole chain of IP + // addresses through which the client has reached us. + // e.g. client_ip, proxy_ip1, proxy_ip2, etc. + if (strpos($spoof, ',') !== FALSE) + { + $spoof = explode(',', $spoof, 2); + $spoof = $spoof[0]; + } + + if ( ! $this->valid_ip($spoof)) + { + $spoof = FALSE; + } + else + { + break; + } + } + } + + $this->ip_address = ($spoof !== FALSE && in_array($_SERVER['REMOTE_ADDR'], $proxy_ips, TRUE)) + ? $spoof : $_SERVER['REMOTE_ADDR']; + } + else + { + $this->ip_address = $_SERVER['REMOTE_ADDR']; + } + + if ( ! $this->valid_ip($this->ip_address)) + { + $this->ip_address = '0.0.0.0'; + } + + return $this->ip_address; + } + + // -------------------------------------------------------------------- + + /** + * Validate IP Address + * + * @access public + * @param string + * @param string ipv4 or ipv6 + * @return bool + */ + public function valid_ip($ip, $which = '') + { + $which = strtolower($which); + + // First check if filter_var is available + if (is_callable('filter_var')) + { + switch ($which) { + case 'ipv4': + $flag = FILTER_FLAG_IPV4; + break; + case 'ipv6': + $flag = FILTER_FLAG_IPV6; + break; + default: + $flag = ''; + break; + } + + return (bool) filter_var($ip, FILTER_VALIDATE_IP, $flag); + } + + if ($which !== 'ipv6' && $which !== 'ipv4') + { + if (strpos($ip, ':') !== FALSE) + { + $which = 'ipv6'; + } + elseif (strpos($ip, '.') !== FALSE) + { + $which = 'ipv4'; + } + else + { + return FALSE; + } + } + + $func = '_valid_'.$which; + return $this->$func($ip); + } + + // -------------------------------------------------------------------- + + /** + * Validate IPv4 Address + * + * Updated version suggested by Geert De Deckere + * + * @access protected + * @param string + * @return bool + */ + protected function _valid_ipv4($ip) + { + $ip_segments = explode('.', $ip); + + // Always 4 segments needed + if (count($ip_segments) !== 4) + { + return FALSE; + } + // IP can not start with 0 + if ($ip_segments[0][0] == '0') + { + return FALSE; + } + + // Check each segment + foreach ($ip_segments as $segment) + { + // IP segments must be digits and can not be + // longer than 3 digits or greater then 255 + if ($segment == '' OR preg_match("/[^0-9]/", $segment) OR $segment > 255 OR strlen($segment) > 3) + { + return FALSE; + } + } + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Validate IPv6 Address + * + * @access protected + * @param string + * @return bool + */ + protected function _valid_ipv6($str) + { + // 8 groups, separated by : + // 0-ffff per group + // one set of consecutive 0 groups can be collapsed to :: + + $groups = 8; + $collapsed = FALSE; + + $chunks = array_filter( + preg_split('/(:{1,2})/', $str, NULL, PREG_SPLIT_DELIM_CAPTURE) + ); + + // Rule out easy nonsense + if (current($chunks) == ':' OR end($chunks) == ':') + { + return FALSE; + } + + // PHP supports IPv4-mapped IPv6 addresses, so we'll expect those as well + if (strpos(end($chunks), '.') !== FALSE) + { + $ipv4 = array_pop($chunks); + + if ( ! $this->_valid_ipv4($ipv4)) + { + return FALSE; + } + + $groups--; + } + + while ($seg = array_pop($chunks)) + { + if ($seg[0] == ':') + { + if (--$groups == 0) + { + return FALSE; // too many groups + } + + if (strlen($seg) > 2) + { + return FALSE; // long separator + } + + if ($seg == '::') + { + if ($collapsed) + { + return FALSE; // multiple collapsed + } + + $collapsed = TRUE; + } + } + elseif (preg_match("/[^0-9a-f]/i", $seg) OR strlen($seg) > 4) + { + return FALSE; // invalid segment + } + } + + return $collapsed OR $groups == 1; + } + + // -------------------------------------------------------------------- + + /** + * User Agent + * + * @access public + * @return string + */ + function user_agent() + { + if ($this->user_agent !== FALSE) + { + return $this->user_agent; + } + + $this->user_agent = ( ! isset($_SERVER['HTTP_USER_AGENT'])) ? FALSE : $_SERVER['HTTP_USER_AGENT']; + + return $this->user_agent; + } + + // -------------------------------------------------------------------- + + /** + * Sanitize Globals + * + * This function does the following: + * + * Unsets $_GET data (if query strings are not enabled) + * + * Unsets all globals if register_globals is enabled + * + * Standardizes newline characters to \n + * + * @access private + * @return void + */ + function _sanitize_globals() + { + // It would be "wrong" to unset any of these GLOBALS. + $protected = array('_SERVER', '_GET', '_POST', '_FILES', '_REQUEST', + '_SESSION', '_ENV', 'GLOBALS', 'HTTP_RAW_POST_DATA', + 'system_folder', 'application_folder', 'BM', 'EXT', + 'CFG', 'URI', 'RTR', 'OUT', 'IN'); + + // Unset globals for securiy. + // This is effectively the same as register_globals = off + foreach (array($_GET, $_POST, $_COOKIE) as $global) + { + if ( ! is_array($global)) + { + if ( ! in_array($global, $protected)) + { + global $$global; + $$global = NULL; + } + } + else + { + foreach ($global as $key => $val) + { + if ( ! in_array($key, $protected)) + { + global $$key; + $$key = NULL; + } + } + } + } + + // Is $_GET data allowed? If not we'll set the $_GET to an empty array + if ($this->_allow_get_array == FALSE) + { + $_GET = array(); + } + else + { + if (is_array($_GET) AND count($_GET) > 0) + { + foreach ($_GET as $key => $val) + { + $_GET[$this->_clean_input_keys($key)] = $this->_clean_input_data($val); + } + } + } + + // Clean $_POST Data + if (is_array($_POST) AND count($_POST) > 0) + { + foreach ($_POST as $key => $val) + { + $_POST[$this->_clean_input_keys($key)] = $this->_clean_input_data($val); + } + } + + // Clean $_COOKIE Data + if (is_array($_COOKIE) AND count($_COOKIE) > 0) + { + // Also get rid of specially treated cookies that might be set by a server + // or silly application, that are of no use to a CI application anyway + // but that when present will trip our 'Disallowed Key Characters' alarm + // http://www.ietf.org/rfc/rfc2109.txt + // note that the key names below are single quoted strings, and are not PHP variables + unset($_COOKIE['$Version']); + unset($_COOKIE['$Path']); + unset($_COOKIE['$Domain']); + + foreach ($_COOKIE as $key => $val) + { + $_COOKIE[$this->_clean_input_keys($key)] = $this->_clean_input_data($val); + } + } + + // Sanitize PHP_SELF + $_SERVER['PHP_SELF'] = strip_tags($_SERVER['PHP_SELF']); + + + // CSRF Protection check on HTTP requests + if ($this->_enable_csrf == TRUE && ! $this->is_cli_request()) + { + $this->security->csrf_verify(); + } + + log_message('debug', "Global POST and COOKIE data sanitized"); + } + + // -------------------------------------------------------------------- + + /** + * Clean Input Data + * + * This is a helper function. It escapes data and + * standardizes newline characters to \n + * + * @access private + * @param string + * @return string + */ + function _clean_input_data($str) + { + if (is_array($str)) + { + $new_array = array(); + foreach ($str as $key => $val) + { + $new_array[$this->_clean_input_keys($key)] = $this->_clean_input_data($val); + } + return $new_array; + } + + /* We strip slashes if magic quotes is on to keep things consistent + + NOTE: In PHP 5.4 get_magic_quotes_gpc() will always return 0 and + it will probably not exist in future versions at all. + */ + if ( ! is_php('5.4') && get_magic_quotes_gpc()) + { + $str = stripslashes($str); + } + + // Clean UTF-8 if supported + if (UTF8_ENABLED === TRUE) + { + $str = $this->uni->clean_string($str); + } + + // Remove control characters + $str = remove_invisible_characters($str); + + // Should we filter the input data? + if ($this->_enable_xss === TRUE) + { + $str = $this->security->xss_clean($str); + } + + // Standardize newlines if needed + if ($this->_standardize_newlines == TRUE) + { + if (strpos($str, "\r") !== FALSE) + { + $str = str_replace(array("\r\n", "\r", "\r\n\n"), PHP_EOL, $str); + } + } + + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Clean Keys + * + * This is a helper function. To prevent malicious users + * from trying to exploit keys we make sure that keys are + * only named with alpha-numeric text and a few other items. + * + * @access private + * @param string + * @return string + */ + function _clean_input_keys($str) + { + if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str)) + { + 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. + * + * @param bool XSS cleaning + * + * @return array + */ + public function request_headers($xss_clean = FALSE) + { + // Look at Apache go! + if (function_exists('apache_request_headers')) + { + $headers = apache_request_headers(); + } + else + { + $headers['Content-Type'] = (isset($_SERVER['CONTENT_TYPE'])) ? $_SERVER['CONTENT_TYPE'] : @getenv('CONTENT_TYPE'); + + foreach ($_SERVER as $key => $val) + { + if (strncmp($key, 'HTTP_', 5) === 0) + { + $headers[substr($key, 5)] = $this->_fetch_from_array($_SERVER, $key, $xss_clean); + } + } + } + + // take SOME_HEADER and turn it into Some-Header + foreach ($headers as $key => $val) + { + $key = str_replace('_', ' ', strtolower($key)); + $key = str_replace(' ', '-', ucwords($key)); + + $this->headers[$key] = $val; + } + + return $this->headers; + } + + // -------------------------------------------------------------------- + + /** + * Get Request Header + * + * Returns the value of a single member of the headers class member + * + * @param string array key for $this->headers + * @param boolean XSS Clean or not + * @return mixed FALSE on failure, string on success + */ + public function get_request_header($index, $xss_clean = FALSE) + { + if (empty($this->headers)) + { + $this->request_headers(); + } + + if ( ! isset($this->headers[$index])) + { + return FALSE; + } + + if ($xss_clean === TRUE) + { + return $this->security->xss_clean($this->headers[$index]); + } + + return $this->headers[$index]; + } + + // -------------------------------------------------------------------- + + /** + * Is ajax Request? + * + * Test to see if a request contains the HTTP_X_REQUESTED_WITH header + * + * @return boolean + */ + public function is_ajax_request() + { + return ($this->server('HTTP_X_REQUESTED_WITH') === 'XMLHttpRequest'); + } + + // -------------------------------------------------------------------- + + /** + * Is cli Request? + * + * Test to see if a request was made from the command line + * + * @return bool + */ + public function is_cli_request() + { + return (php_sapi_name() === 'cli' OR defined('STDIN')); + } + +} + +/* End of file Input.php */ +/* Location: ./system/core/Input.php */ \ No newline at end of file diff --git a/system/core/Lang.php b/system/core/Lang.php new file mode 100755 index 0000000..ef5d108 --- /dev/null +++ b/system/core/Lang.php @@ -0,0 +1,160 @@ +is_loaded, TRUE)) + { + return; + } + + $config =& get_config(); + + if ($idiom == '') + { + $deft_lang = ( ! isset($config['language'])) ? 'english' : $config['language']; + $idiom = ($deft_lang == '') ? 'english' : $deft_lang; + } + + // Determine where the language file is and load it + if ($alt_path != '' && file_exists($alt_path.'language/'.$idiom.'/'.$langfile)) + { + include($alt_path.'language/'.$idiom.'/'.$langfile); + } + else + { + $found = FALSE; + + foreach (get_instance()->load->get_package_paths(TRUE) as $package_path) + { + if (file_exists($package_path.'language/'.$idiom.'/'.$langfile)) + { + include($package_path.'language/'.$idiom.'/'.$langfile); + $found = TRUE; + break; + } + } + + if ($found !== TRUE) + { + show_error('Unable to load the requested language file: language/'.$idiom.'/'.$langfile); + } + } + + + if ( ! isset($lang)) + { + log_message('error', 'Language file contains no data: language/'.$idiom.'/'.$langfile); + return; + } + + if ($return == TRUE) + { + return $lang; + } + + $this->is_loaded[] = $langfile; + $this->language = array_merge($this->language, $lang); + unset($lang); + + log_message('debug', 'Language file loaded: language/'.$idiom.'/'.$langfile); + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Fetch a single line of text from the language array + * + * @access public + * @param string $line the language line + * @return string + */ + function line($line = '') + { + $value = ($line == '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line]; + + // Because killer robots like unicorns! + if ($value === FALSE) + { + log_message('error', 'Could not find the language line "'.$line.'"'); + } + + return $value; + } + +} +// END Language Class + +/* End of file Lang.php */ +/* Location: ./system/core/Lang.php */ diff --git a/system/core/Loader.php b/system/core/Loader.php new file mode 100755 index 0000000..b5b0634 --- /dev/null +++ b/system/core/Loader.php @@ -0,0 +1,1248 @@ + 'unit', + 'user_agent' => 'agent'); + + /** + * Constructor + * + * Sets the path to the view files and gets the initial output buffering level + */ + public function __construct() + { + $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); + $this->_ci_view_paths = array(APPPATH.'views/' => TRUE); + + log_message('debug', "Loader Class Initialized"); + } + + // -------------------------------------------------------------------- + + /** + * Initialize the Loader + * + * This method is called once in CI_Controller. + * + * @param array + * @return object + */ + public function initialize() + { + $this->_ci_classes = array(); + $this->_ci_loaded_files = array(); + $this->_ci_models = array(); + $this->_base_classes =& is_loaded(); + + $this->_ci_autoloader(); + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * Is Loaded + * + * A utility function to test if a class is in the self::$_ci_classes array. + * This function returns the object name if the class tested for is loaded, + * and returns FALSE if it isn't. + * + * It is mainly used in the form_helper -> _get_validation_object() + * + * @param string class being checked for + * @return mixed class object name on the CI SuperObject or FALSE + */ + public function is_loaded($class) + { + if (isset($this->_ci_classes[$class])) + { + return $this->_ci_classes[$class]; + } + + return FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Class Loader + * + * This function lets users load and instantiate classes. + * It is designed to be called from a user's app controllers. + * + * @param string the name of the class + * @param mixed the optional parameters + * @param string an optional object name + * @return void + */ + public function library($library = '', $params = NULL, $object_name = NULL) + { + if (is_array($library)) + { + foreach ($library as $class) + { + $this->library($class, $params); + } + + return; + } + + if ($library == '' OR isset($this->_base_classes[$library])) + { + return FALSE; + } + + if ( ! is_null($params) && ! is_array($params)) + { + $params = NULL; + } + + $this->_ci_load_class($library, $params, $object_name); + } + + // -------------------------------------------------------------------- + + /** + * Model Loader + * + * This function lets users load and instantiate models. + * + * @param string the name of the class + * @param string name for the model + * @param bool database connection + * @return void + */ + public function model($model, $name = '', $db_conn = FALSE) + { + if (is_array($model)) + { + foreach ($model as $babe) + { + $this->model($babe); + } + return; + } + + if ($model == '') + { + return; + } + + $path = ''; + + // Is the model in a sub-folder? If so, parse out the filename and path. + if (($last_slash = strrpos($model, '/')) !== FALSE) + { + // 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); + + foreach ($this->_ci_model_paths as $mod_path) + { + if ( ! file_exists($mod_path.'models/'.$path.$model.'.php')) + { + continue; + } + + 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.'.php'); + + $model = ucfirst($model); + + $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 + * + * @param string the DB credentials + * @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 + */ + public 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 == NULL AND isset($CI->db) AND is_object($CI->db)) + { + return FALSE; + } + + require_once(BASEPATH.'database/DB.php'); + + if ($return === TRUE) + { + return DB($params, $active_record); + } + + // Initialize the db variable. Needed to prevent + // reference errors with some configurations + $CI->db = ''; + + // Load the DB class + $CI->db =& DB($params, $active_record); + } + + // -------------------------------------------------------------------- + + /** + * Load the Utilities Class + * + * @return string + */ + public 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.php'); + require_once(BASEPATH.'database/drivers/'.$CI->db->dbdriver.'/'.$CI->db->dbdriver.'_utility.php'); + $class = 'CI_DB_'.$CI->db->dbdriver.'_utility'; + + $CI->dbutil = new $class(); + } + + // -------------------------------------------------------------------- + + /** + * Load the Database Forge Class + * + * @return string + */ + public function dbforge() + { + if ( ! class_exists('CI_DB')) + { + $this->database(); + } + + $CI =& get_instance(); + + require_once(BASEPATH.'database/DB_forge.php'); + require_once(BASEPATH.'database/drivers/'.$CI->db->dbdriver.'/'.$CI->db->dbdriver.'_forge.php'); + $class = 'CI_DB_'.$CI->db->dbdriver.'_forge'; + + $CI->dbforge = new $class(); + } + + // -------------------------------------------------------------------- + + /** + * Load View + * + * This function is used to load a "view" file. It has three parameters: + * + * 1. The name of the "view" file to be included. + * 2. An associative array of data to be extracted for use in the view. + * 3. TRUE/FALSE - whether to return the data or load it. In + * some cases it's advantageous to be able to return data so that + * a developer can process it in some way. + * + * @param string + * @param array + * @param bool + * @return void + */ + public function view($view, $vars = array(), $return = FALSE) + { + return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return)); + } + + // -------------------------------------------------------------------- + + /** + * Load File + * + * This is a generic file loader + * + * @param string + * @param bool + * @return string + */ + public function file($path, $return = FALSE) + { + return $this->_ci_load(array('_ci_path' => $path, '_ci_return' => $return)); + } + + // -------------------------------------------------------------------- + + /** + * Set Variables + * + * Once variables are set they become available within + * the controller class and its "view" files. + * + * @param array + * @param string + * @return void + */ + public function vars($vars = array(), $val = '') + { + if ($val != '' AND is_string($vars)) + { + $vars = array($vars => $val); + } + + $vars = $this->_ci_object_to_array($vars); + + if (is_array($vars) AND count($vars) > 0) + { + foreach ($vars as $key => $val) + { + $this->_ci_cached_vars[$key] = $val; + } + } + } + + // -------------------------------------------------------------------- + + /** + * Get Variable + * + * Check if a variable is set and retrieve it. + * + * @param array + * @return void + */ + public function get_var($key) + { + return isset($this->_ci_cached_vars[$key]) ? $this->_ci_cached_vars[$key] : NULL; + } + + // -------------------------------------------------------------------- + + /** + * Load Helper + * + * This function loads the specified helper file. + * + * @param mixed + * @return void + */ + public function helper($helpers = array()) + { + foreach ($this->_ci_prep_filename($helpers, '_helper') as $helper) + { + if (isset($this->_ci_helpers[$helper])) + { + continue; + } + + $ext_helper = APPPATH.'helpers/'.config_item('subclass_prefix').$helper.'.php'; + + // Is this a helper extension request? + if (file_exists($ext_helper)) + { + $base_helper = BASEPATH.'helpers/'.$helper.'.php'; + + if ( ! file_exists($base_helper)) + { + show_error('Unable to load the requested file: helpers/'.$helper.'.php'); + } + + include_once($ext_helper); + include_once($base_helper); + + $this->_ci_helpers[$helper] = TRUE; + log_message('debug', 'Helper loaded: '.$helper); + continue; + } + + // Try to load the helper + foreach ($this->_ci_helper_paths as $path) + { + if (file_exists($path.'helpers/'.$helper.'.php')) + { + include_once($path.'helpers/'.$helper.'.php'); + + $this->_ci_helpers[$helper] = TRUE; + log_message('debug', 'Helper loaded: '.$helper); + break; + } + } + + // unable to load the helper + if ( ! isset($this->_ci_helpers[$helper])) + { + show_error('Unable to load the requested file: helpers/'.$helper.'.php'); + } + } + } + + // -------------------------------------------------------------------- + + /** + * Load Helpers + * + * This is simply an alias to the above function in case the + * user has written the plural form of this function. + * + * @param array + * @return void + */ + public function helpers($helpers = array()) + { + $this->helper($helpers); + } + + // -------------------------------------------------------------------- + + /** + * Loads a language file + * + * @param array + * @param string + * @return void + */ + public function language($file = array(), $lang = '') + { + $CI =& get_instance(); + + if ( ! is_array($file)) + { + $file = array($file); + } + + foreach ($file as $langfile) + { + $CI->lang->load($langfile, $lang); + } + } + + // -------------------------------------------------------------------- + + /** + * Loads a config file + * + * @param string + * @param bool + * @param bool + * @return void + */ + public function config($file = '', $use_sections = FALSE, $fail_gracefully = FALSE) + { + $CI =& get_instance(); + $CI->config->load($file, $use_sections, $fail_gracefully); + } + + // -------------------------------------------------------------------- + + /** + * Driver + * + * Loads a driver library + * + * @param string the name of the class + * @param mixed the optional parameters + * @param string an optional object name + * @return void + */ + public function driver($library = '', $params = NULL, $object_name = NULL) + { + if ( ! class_exists('CI_Driver_Library')) + { + // we aren't instantiating an object here, that'll be done by the Library itself + require BASEPATH.'libraries/Driver.php'; + } + + if ($library == '') + { + return FALSE; + } + + // 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); + } + + // -------------------------------------------------------------------- + + /** + * Add Package Path + * + * Prepends a parent path to the library, model, helper, and config path arrays + * + * @param string + * @param boolean + * @return void + */ + public function add_package_path($path, $view_cascade=TRUE) + { + $path = rtrim($path, '/').'/'; + + array_unshift($this->_ci_library_paths, $path); + array_unshift($this->_ci_model_paths, $path); + array_unshift($this->_ci_helper_paths, $path); + + $this->_ci_view_paths = array($path.'views/' => $view_cascade) + $this->_ci_view_paths; + + // Add config file path + $config =& $this->_ci_get_component('config'); + array_unshift($config->_config_paths, $path); + } + + // -------------------------------------------------------------------- + + /** + * Get Package Paths + * + * Return a list of all package paths, by default it will ignore BASEPATH. + * + * @param string + * @return void + */ + public function get_package_paths($include_base = FALSE) + { + return $include_base === TRUE ? $this->_ci_library_paths : $this->_ci_model_paths; + } + + // -------------------------------------------------------------------- + + /** + * Remove Package Path + * + * 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. + * + * @param type + * @param bool + * @return type + */ + public function remove_package_path($path = '', $remove_config_path = TRUE) + { + $config =& $this->_ci_get_component('config'); + + if ($path == '') + { + $void = array_shift($this->_ci_library_paths); + $void = array_shift($this->_ci_model_paths); + $void = array_shift($this->_ci_helper_paths); + $void = array_shift($this->_ci_view_paths); + $void = array_shift($config->_config_paths); + } + 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 (isset($this->_ci_view_paths[$path.'views/'])) + { + unset($this->_ci_view_paths[$path.'views/']); + } + + 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))); + $this->_ci_view_paths = array_merge($this->_ci_view_paths, array(APPPATH.'views/' => TRUE)); + $config->_config_paths = array_unique(array_merge($config->_config_paths, array(APPPATH))); + } + + // -------------------------------------------------------------------- + + /** + * Loader + * + * This function is used to load views and files. + * Variables are prefixed with _ci_ to avoid symbol collision with + * variables made available to view files + * + * @param array + * @return void + */ + protected function _ci_load($_ci_data) + { + // Set the default data variables + foreach (array('_ci_view', '_ci_vars', '_ci_path', '_ci_return') as $_ci_val) + { + $$_ci_val = ( ! isset($_ci_data[$_ci_val])) ? FALSE : $_ci_data[$_ci_val]; + } + + $file_exists = FALSE; + + // Set the path to the requested file + if ($_ci_path != '') + { + $_ci_x = explode('/', $_ci_path); + $_ci_file = end($_ci_x); + } + else + { + $_ci_ext = pathinfo($_ci_view, PATHINFO_EXTENSION); + $_ci_file = ($_ci_ext == '') ? $_ci_view.'.php' : $_ci_view; + + foreach ($this->_ci_view_paths as $view_file => $cascade) + { + if (file_exists($view_file.$_ci_file)) + { + $_ci_path = $view_file.$_ci_file; + $file_exists = TRUE; + break; + } + + if ( ! $cascade) + { + break; + } + } + } + + if ( ! $file_exists && ! 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. + + $_ci_CI =& get_instance(); + foreach (get_object_vars($_ci_CI) as $_ci_key => $_ci_var) + { + if ( ! isset($this->$_ci_key)) + { + $this->$_ci_key =& $_ci_CI->$_ci_key; + } + } + + /* + * Extract and cache variables + * + * You can either set variables using the dedicated $this->load_vars() + * 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 + * + * We buffer the output for two reasons: + * 1. Speed. You get a significant speed boost. + * 2. So that the final rendered template can be + * post-processed by the output class. Why do we + * need post processing? For one thing, in order to + * show the elapsed page load time. Unless we + * can intercept the content right before it's sent to + * 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(' $this->_ci_ob_level + 1) + { + ob_end_flush(); + } + else + { + $_ci_CI->output->append_output(ob_get_contents()); + @ob_end_clean(); + } + } + + // -------------------------------------------------------------------- + + /** + * Load class + * + * This function loads the requested class. + * + * @param string the item that is being loaded + * @param mixed any additional parameters + * @param string an optional object name + * @return void + */ + protected 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, + // but we don't want a leading slash + $class = str_replace('.php', '', trim($class, '/')); + + // Was the path included with the class name? + // We look for a slash to determine this + $subdir = ''; + if (($last_slash = strrpos($class, '/')) !== FALSE) + { + // 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 + foreach (array(ucfirst($class), strtolower($class)) as $class) + { + $subclass = APPPATH.'libraries/'.$subdir.config_item('subclass_prefix').$class.'.php'; + + // Is this a class extension request? + if (file_exists($subclass)) + { + $baseclass = BASEPATH.'libraries/'.ucfirst($class).'.php'; + + if ( ! file_exists($baseclass)) + { + log_message('error', "Unable to load the requested class: ".$class); + show_error("Unable to load the requested class: ".$class); + } + + // Safety: Was the class already loaded by a previous call? + if (in_array($subclass, $this->_ci_loaded_files)) + { + // Before we deem this to be a duplicate request, let's see + // if a custom object name is being supplied. If so, we'll + // return a new instance of the object + if ( ! is_null($object_name)) + { + $CI =& get_instance(); + if ( ! isset($CI->$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($subclass); + $this->_ci_loaded_files[] = $subclass; + + 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; + foreach ($this->_ci_library_paths as $path) + { + $filepath = $path.'libraries/'.$subdir.$class.'.php'; + + // 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)) + { + // Before we deem this to be a duplicate request, let's see + // if a custom object name is being supplied. If so, we'll + // return a new instance of the object + if ( ! is_null($object_name)) + { + $CI =& get_instance(); + if ( ! isset($CI->$object_name)) + { + 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? + if ($subdir == '') + { + $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) + { + log_message('error', "Unable to load the requested class: ".$class); + show_error("Unable to load the requested class: ".$class); + } + } + + // -------------------------------------------------------------------- + + /** + * Instantiates a class + * + * @param string + * @param string + * @param bool + * @param string an optional object name + * @return null + */ + protected function _ci_init_class($class, $prefix = '', $config = FALSE, $object_name = NULL) + { + // Is there an associated config file for this class? Note: these should always be lowercase + if ($config === NULL) + { + // Fetch the config paths containing any package paths + $config_component = $this->_ci_get_component('config'); + + if (is_array($config_component->_config_paths)) + { + // 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. Check for environment + // first, global next + if (defined('ENVIRONMENT') AND file_exists($path .'config/'.ENVIRONMENT.'/'.strtolower($class).'.php')) + { + include($path .'config/'.ENVIRONMENT.'/'.strtolower($class).'.php'); + break; + } + elseif (defined('ENVIRONMENT') AND file_exists($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php')) + { + include($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php'); + break; + } + elseif (file_exists($path .'config/'.strtolower($class).'.php')) + { + include($path .'config/'.strtolower($class).'.php'); + break; + } + elseif (file_exists($path .'config/'.ucfirst(strtolower($class)).'.php')) + { + include($path .'config/'.ucfirst(strtolower($class)).'.php'); + break; + } + } + } + } + + if ($prefix == '') + { + if (class_exists('CI_'.$class)) + { + $name = 'CI_'.$class; + } + elseif (class_exists(config_item('subclass_prefix').$class)) + { + $name = config_item('subclass_prefix').$class; + } + else + { + $name = $class; + } + } + else + { + $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]; + } + else + { + $classvar = $object_name; + } + + // Save the class name and object name + $this->_ci_classes[$class] = $classvar; + + // 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, and helpers to be loaded automatically. + * + * @param array + * @return void + */ + private function _ci_autoloader() + { + if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/autoload.php')) + { + include(APPPATH.'config/'.ENVIRONMENT.'/autoload.php'); + } + else + { + include(APPPATH.'config/autoload.php'); + } + + 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 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']) AND isset($autoload['core'])) + { + $autoload['libraries'] = $autoload['core']; + } + + // Load libraries + if (isset($autoload['libraries']) AND count($autoload['libraries']) > 0) + { + // Load the database driver. + if (in_array('database', $autoload['libraries'])) + { + $this->database(); + $autoload['libraries'] = array_diff($autoload['libraries'], array('database')); + } + + // Load all other libraries + foreach ($autoload['libraries'] as $item) + { + $this->library($item); + } + } + + // Autoload models + if (isset($autoload['model'])) + { + $this->model($autoload['model']); + } + } + + // -------------------------------------------------------------------- + + /** + * Object to Array + * + * Takes an object as input and converts the class variables to array key/vals + * + * @param object + * @return array + */ + protected function _ci_object_to_array($object) + { + return (is_object($object)) ? get_object_vars($object) : $object; + } + + // -------------------------------------------------------------------- + + /** + * Get a reference to a specific library or model + * + * @param string + * @return bool + */ + protected function &_ci_get_component($component) + { + $CI =& get_instance(); + return $CI->$component; + } + + // -------------------------------------------------------------------- + + /** + * Prep filename + * + * This function preps the name of various items to make loading them more reliable. + * + * @param mixed + * @param string + * @return array + */ + protected function _ci_prep_filename($filename, $extension) + { + if ( ! is_array($filename)) + { + return array(strtolower(str_replace('.php', '', str_replace($extension, '', $filename)).$extension)); + } + else + { + foreach ($filename as $key => $val) + { + $filename[$key] = strtolower(str_replace('.php', '', str_replace($extension, '', $val)).$extension); + } + + return $filename; + } + } +} + +/* End of file Loader.php */ +/* 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 0000000..1f14250 --- /dev/null +++ b/system/core/Model.php @@ -0,0 +1,57 @@ +$key; + } +} +// END Model Class + +/* End of file Model.php */ +/* Location: ./system/core/Model.php */ \ No newline at end of file diff --git a/system/core/Output.php b/system/core/Output.php new file mode 100755 index 0000000..7959bef --- /dev/null +++ b/system/core/Output.php @@ -0,0 +1,574 @@ +_zlib_oc = @ini_get('zlib.output_compression'); + + // Get mime types for later + if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) + { + include APPPATH.'config/'.ENVIRONMENT.'/mimes.php'; + } + else + { + include APPPATH.'config/mimes.php'; + } + + + $this->mime_types = $mimes; + + log_message('debug', "Output Class Initialized"); + } + + // -------------------------------------------------------------------- + + /** + * Get Output + * + * Returns the current output string + * + * @access public + * @return string + */ + function get_output() + { + return $this->final_output; + } + + // -------------------------------------------------------------------- + + /** + * Set Output + * + * Sets the output string + * + * @access public + * @param string + * @return void + */ + function set_output($output) + { + $this->final_output = $output; + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * Append Output + * + * Appends data onto the output string + * + * @access public + * @param string + * @return void + */ + function append_output($output) + { + if ($this->final_output == '') + { + $this->final_output = $output; + } + else + { + $this->final_output .= $output; + } + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * Set Header + * + * Lets you set a server header which will be outputted with the final display. + * + * Note: If a file is cached, headers will not be sent. We need to figure out + * how to permit header data to be saved with the cache data... + * + * @access public + * @param string + * @param bool + * @return void + */ + function set_header($header, $replace = TRUE) + { + // If zlib.output_compression is enabled it will compress the output, + // but it will not modify the content-length header to compensate for + // the reduction, causing the browser to hang waiting for more data. + // We'll just skip content-length in those cases. + + if ($this->_zlib_oc && strncasecmp($header, 'content-length', 14) == 0) + { + return; + } + + $this->headers[] = array($header, $replace); + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * Set Content Type Header + * + * @access public + * @param string extension of the file we're outputting + * @return void + */ + function set_content_type($mime_type) + { + if (strpos($mime_type, '/') === FALSE) + { + $extension = ltrim($mime_type, '.'); + + // Is this extension supported? + if (isset($this->mime_types[$extension])) + { + $mime_type =& $this->mime_types[$extension]; + + if (is_array($mime_type)) + { + $mime_type = current($mime_type); + } + } + } + + $header = 'Content-Type: '.$mime_type; + + $this->headers[] = array($header, TRUE); + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * Set HTTP Status Header + * moved to Common procedural functions in 1.7.2 + * + * @access public + * @param int the status code + * @param string + * @return void + */ + function set_status_header($code = 200, $text = '') + { + set_status_header($code, $text); + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * Enable/disable Profiler + * + * @access public + * @param bool + * @return void + */ + function enable_profiler($val = TRUE) + { + $this->enable_profiler = (is_bool($val)) ? $val : TRUE; + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * Set Profiler Sections + * + * Allows override of default / config settings for Profiler section display + * + * @access public + * @param array + * @return void + */ + function set_profiler_sections($sections) + { + foreach ($sections as $section => $enable) + { + $this->_profiler_sections[$section] = ($enable !== FALSE) ? TRUE : FALSE; + } + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * Set Cache + * + * @access public + * @param integer + * @return void + */ + function cache($time) + { + $this->cache_expiration = ( ! is_numeric($time)) ? 0 : $time; + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * Display Output + * + * All "view" data is automatically put into this variable by the controller class: + * + * $this->final_output + * + * This function sends the finalized output data to the browser along + * with any server headers and profile data. It also stops the + * benchmark timer so the page rendering speed and memory usage can be shown. + * + * @access public + * @param string + * @return mixed + */ + function _display($output = '') + { + // Note: We use globals because we can't use $CI =& get_instance() + // since this function is sometimes called by the caching mechanism, + // which happens before the CI super object is available. + global $BM, $CFG; + + // Grab the super object if we can. + if (class_exists('CI_Controller')) + { + $CI =& get_instance(); + } + + // -------------------------------------------------------------------- + + // Set the output data + if ($output == '') + { + $output =& $this->final_output; + } + + // -------------------------------------------------------------------- + + // Do we need to write a cache file? Only if the controller does not have its + // own _output() method and we are not dealing with a cache file, which we + // can determine by the existence of the $CI object above + if ($this->cache_expiration > 0 && isset($CI) && ! method_exists($CI, '_output')) + { + $this->_write_cache($output); + } + + // -------------------------------------------------------------------- + + // Parse out the elapsed time and memory usage, + // then swap the pseudo-variables with the data + + $elapsed = $BM->elapsed_time('total_execution_time_start', 'total_execution_time_end'); + + if ($this->parse_exec_vars === TRUE) + { + $memory = ( ! function_exists('memory_get_usage')) ? '0' : round(memory_get_usage()/1024/1024, 2).'MB'; + + $output = str_replace('{elapsed_time}', $elapsed, $output); + $output = str_replace('{memory_usage}', $memory, $output); + } + + // -------------------------------------------------------------------- + + // Is compression requested? + if ($CFG->item('compress_output') === TRUE && $this->_zlib_oc == FALSE) + { + if (extension_loaded('zlib')) + { + if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) AND strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE) + { + ob_start('ob_gzhandler'); + } + } + } + + // -------------------------------------------------------------------- + + // Are there any server headers to send? + if (count($this->headers) > 0) + { + foreach ($this->headers as $header) + { + @header($header[0], $header[1]); + } + } + + // -------------------------------------------------------------------- + + // Does the $CI object exist? + // If not we know we are dealing with a cache file so we'll + // simply echo out the data and exit. + if ( ! isset($CI)) + { + echo $output; + log_message('debug', "Final output sent to browser"); + log_message('debug', "Total execution time: ".$elapsed); + return TRUE; + } + + // -------------------------------------------------------------------- + + // Do we need to generate profile data? + // If so, load the Profile class and run it. + if ($this->enable_profiler == TRUE) + { + $CI->load->library('profiler'); + + if ( ! empty($this->_profiler_sections)) + { + $CI->profiler->set_sections($this->_profiler_sections); + } + + // If the output data contains closing and tags + // we will remove them and add them back after we insert the profile data + if (preg_match("|.*?|is", $output)) + { + $output = preg_replace("|.*?|is", '', $output); + $output .= $CI->profiler->run(); + $output .= ''; + } + else + { + $output .= $CI->profiler->run(); + } + } + + // -------------------------------------------------------------------- + + // Does the controller contain a function named _output()? + // If so send the output there. Otherwise, echo it. + if (method_exists($CI, '_output')) + { + $CI->_output($output); + } + else + { + echo $output; // Send it to the browser! + } + + log_message('debug', "Final output sent to browser"); + log_message('debug', "Total execution time: ".$elapsed); + } + + // -------------------------------------------------------------------- + + /** + * Write a Cache File + * + * @access public + * @param string + * @return void + */ + function _write_cache($output) + { + $CI =& get_instance(); + $path = $CI->config->item('cache_path'); + + $cache_path = ($path == '') ? APPPATH.'cache/' : $path; + + if ( ! is_dir($cache_path) OR ! is_really_writable($cache_path)) + { + log_message('error', "Unable to write cache file: ".$cache_path); + return; + } + + $uri = $CI->config->item('base_url'). + $CI->config->item('index_page'). + $CI->uri->uri_string(); + + $cache_path .= md5($uri); + + if ( ! $fp = @fopen($cache_path, FOPEN_WRITE_CREATE_DESTRUCTIVE)) + { + log_message('error', "Unable to write cache file: ".$cache_path); + return; + } + + $expire = time() + ($this->cache_expiration * 60); + + if (flock($fp, LOCK_EX)) + { + fwrite($fp, $expire.'TS--->'.$output); + flock($fp, LOCK_UN); + } + else + { + log_message('error', "Unable to secure a file lock for file at: ".$cache_path); + return; + } + fclose($fp); + @chmod($cache_path, FILE_WRITE_MODE); + + log_message('debug', "Cache file written: ".$cache_path); + } + + // -------------------------------------------------------------------- + + /** + * Update/serve a cached file + * + * @access public + * @param object config class + * @param object uri class + * @return void + */ + function _display_cache(&$CFG, &$URI) + { + $cache_path = ($CFG->item('cache_path') == '') ? APPPATH.'cache/' : $CFG->item('cache_path'); + + // Build the file path. The file name is an MD5 hash of the full URI + $uri = $CFG->item('base_url'). + $CFG->item('index_page'). + $URI->uri_string; + + $filepath = $cache_path.md5($uri); + + if ( ! @file_exists($filepath)) + { + return FALSE; + } + + if ( ! $fp = @fopen($filepath, FOPEN_READ)) + { + return FALSE; + } + + flock($fp, LOCK_SH); + + $cache = ''; + if (filesize($filepath) > 0) + { + $cache = fread($fp, filesize($filepath)); + } + + flock($fp, LOCK_UN); + fclose($fp); + + // Strip out the embedded timestamp + if ( ! preg_match("/(\d+TS--->)/", $cache, $match)) + { + return FALSE; + } + + // Has the file expired? If so we'll delete it. + if (time() >= trim(str_replace('TS--->', '', $match['1']))) + { + if (is_really_writable($cache_path)) + { + @unlink($filepath); + log_message('debug', "Cache file has expired. File deleted"); + return FALSE; + } + } + + // Display the cache + $this->_display(str_replace($match['0'], '', $cache)); + log_message('debug', "Cache file is current. Sending it to browser."); + return TRUE; + } + + +} +// END Output Class + +/* End of file Output.php */ +/* Location: ./system/core/Output.php */ \ No newline at end of file diff --git a/system/core/Router.php b/system/core/Router.php new file mode 100755 index 0000000..b48a345 --- /dev/null +++ b/system/core/Router.php @@ -0,0 +1,522 @@ +config =& load_class('Config', 'core'); + $this->uri =& load_class('URI', 'core'); + log_message('debug', "Router Class Initialized"); + } + + // -------------------------------------------------------------------- + + /** + * Set the route mapping + * + * This function determines what should be served based on the URI request, + * as well as any "routes" that have been set in the routing config file. + * + * @access private + * @return void + */ + function _set_routing() + { + // Are query strings enabled in the config file? Normally CI doesn't utilize query strings + // since URI segments are more search-engine friendly, but they can optionally be used. + // If this feature is enabled, we will gather the directory/class/method a little differently + $segments = array(); + if ($this->config->item('enable_query_strings') === TRUE AND isset($_GET[$this->config->item('controller_trigger')])) + { + if (isset($_GET[$this->config->item('directory_trigger')])) + { + $this->set_directory(trim($this->uri->_filter_uri($_GET[$this->config->item('directory_trigger')]))); + $segments[] = $this->fetch_directory(); + } + + if (isset($_GET[$this->config->item('controller_trigger')])) + { + $this->set_class(trim($this->uri->_filter_uri($_GET[$this->config->item('controller_trigger')]))); + $segments[] = $this->fetch_class(); + } + + if (isset($_GET[$this->config->item('function_trigger')])) + { + $this->set_method(trim($this->uri->_filter_uri($_GET[$this->config->item('function_trigger')]))); + $segments[] = $this->fetch_method(); + } + } + + // Load the routes.php file. + if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/routes.php')) + { + include(APPPATH.'config/'.ENVIRONMENT.'/routes.php'); + } + elseif (is_file(APPPATH.'config/routes.php')) + { + include(APPPATH.'config/routes.php'); + } + + $this->routes = ( ! isset($route) OR ! is_array($route)) ? array() : $route; + unset($route); + + // Set the default controller so we can display it in the event + // the URI doesn't correlated to a valid controller. + $this->default_controller = ( ! isset($this->routes['default_controller']) OR $this->routes['default_controller'] == '') ? FALSE : strtolower($this->routes['default_controller']); + + // Were there any query string segments? If so, we'll validate them and bail out since we're done. + if (count($segments) > 0) + { + return $this->_validate_request($segments); + } + + // Fetch the complete URI string + $this->uri->_fetch_uri_string(); + + // Is there a URI string? If not, the default controller specified in the "routes" file will be shown. + if ($this->uri->uri_string == '') + { + return $this->_set_default_controller(); + } + + // Do we need to remove the URL suffix? + $this->uri->_remove_url_suffix(); + + // Compile the segments into an array + $this->uri->_explode_segments(); + + // Parse any custom routing that may exist + $this->_parse_routes(); + + // Re-index the segment array so that it starts with 1 rather than 0 + $this->uri->_reindex_segments(); + } + + // -------------------------------------------------------------------- + + /** + * Set the default controller + * + * @access private + * @return void + */ + function _set_default_controller() + { + if ($this->default_controller === FALSE) + { + show_error("Unable to determine what should be displayed. A default route has not been specified in the routing file."); + } + // Is the method being specified? + if (strpos($this->default_controller, '/') !== FALSE) + { + $x = explode('/', $this->default_controller); + + $this->set_class($x[0]); + $this->set_method($x[1]); + $this->_set_request($x); + } + else + { + $this->set_class($this->default_controller); + $this->set_method('index'); + $this->_set_request(array($this->default_controller, 'index')); + } + + // re-index the routed segments array so it starts with 1 rather than 0 + $this->uri->_reindex_segments(); + + log_message('debug', "No URI present. Default controller set."); + } + + // -------------------------------------------------------------------- + + /** + * Set the Route + * + * This function takes an array of URI segments as + * input, and sets the current class/method + * + * @access private + * @param array + * @param bool + * @return void + */ + function _set_request($segments = array()) + { + $segments = $this->_validate_request($segments); + + if (count($segments) == 0) + { + return $this->_set_default_controller(); + } + + $this->set_class($segments[0]); + + if (isset($segments[1])) + { + // A standard method request + $this->set_method($segments[1]); + } + else + { + // This lets the "routed" segment array identify that the default + // index method is being used. + $segments[1] = 'index'; + } + + // Update our "routed" segment array to contain the segments. + // Note: If there is no custom routing, this array will be + // identical to $this->uri->segments + $this->uri->rsegments = $segments; + } + + // -------------------------------------------------------------------- + + /** + * Validates the supplied segments. Attempts to determine the path to + * the controller. + * + * @access private + * @param array + * @return array + */ + function _validate_request($segments) + { + if (count($segments) == 0) + { + return $segments; + } + + // Does the requested controller exist in the root folder? + if (file_exists(APPPATH.'controllers/'.$segments[0].'.php')) + { + return $segments; + } + + // Is the controller in a sub-folder? + if (is_dir(APPPATH.'controllers/'.$segments[0])) + { + // Set the directory and remove it from the segment array + $this->set_directory($segments[0]); + $segments = array_slice($segments, 1); + + if (count($segments) > 0) + { + // Does the requested controller exist in the sub-folder? + if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$segments[0].'.php')) + { + if ( ! empty($this->routes['404_override'])) + { + $x = explode('/', $this->routes['404_override']); + + $this->set_directory(''); + $this->set_class($x[0]); + $this->set_method(isset($x[1]) ? $x[1] : 'index'); + + return $x; + } + else + { + show_404($this->fetch_directory().$segments[0]); + } + } + } + else + { + // Is the method being specified in the route? + if (strpos($this->default_controller, '/') !== FALSE) + { + $x = explode('/', $this->default_controller); + + $this->set_class($x[0]); + $this->set_method($x[1]); + } + else + { + $this->set_class($this->default_controller); + $this->set_method('index'); + } + + // Does the default controller exist in the sub-folder? + if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$this->default_controller.'.php')) + { + $this->directory = ''; + return array(); + } + + } + + return $segments; + } + + + // If we've gotten this far it means that the URI does not correlate to a valid + // controller class. We will now see if there is an override + if ( ! empty($this->routes['404_override'])) + { + $x = explode('/', $this->routes['404_override']); + + $this->set_class($x[0]); + $this->set_method(isset($x[1]) ? $x[1] : 'index'); + + return $x; + } + + + // Nothing else to do at this point but show a 404 + show_404($segments[0]); + } + + // -------------------------------------------------------------------- + + /** + * Parse Routes + * + * This function matches any routes that may exist in + * the config/routes.php file against the URI to + * determine if the class/method need to be remapped. + * + * @access private + * @return void + */ + function _parse_routes() + { + // Turn the segment array into a URI string + $uri = implode('/', $this->uri->segments); + + // Is there a literal match? If so we're done + if (isset($this->routes[$uri])) + { + return $this->_set_request(explode('/', $this->routes[$uri])); + } + + // Loop through the route array looking for wild-cards + foreach ($this->routes as $key => $val) + { + // Convert wild-cards to RegEx + $key = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key)); + + // Does the RegEx match? + if (preg_match('#^'.$key.'$#', $uri)) + { + // Do we have a back-reference? + if (strpos($val, '$') !== FALSE AND strpos($key, '(') !== FALSE) + { + $val = preg_replace('#^'.$key.'$#', $val, $uri); + } + + return $this->_set_request(explode('/', $val)); + } + } + + // If we got this far it means we didn't encounter a + // matching route so we'll set the site default route + $this->_set_request($this->uri->segments); + } + + // -------------------------------------------------------------------- + + /** + * Set the class name + * + * @access public + * @param string + * @return void + */ + function set_class($class) + { + $this->class = str_replace(array('/', '.'), '', $class); + } + + // -------------------------------------------------------------------- + + /** + * Fetch the current class + * + * @access public + * @return string + */ + function fetch_class() + { + return $this->class; + } + + // -------------------------------------------------------------------- + + /** + * Set the method name + * + * @access public + * @param string + * @return void + */ + function set_method($method) + { + $this->method = $method; + } + + // -------------------------------------------------------------------- + + /** + * Fetch the current method + * + * @access public + * @return string + */ + function fetch_method() + { + if ($this->method == $this->fetch_class()) + { + return 'index'; + } + + return $this->method; + } + + // -------------------------------------------------------------------- + + /** + * Set the directory name + * + * @access public + * @param string + * @return void + */ + function set_directory($dir) + { + $this->directory = str_replace(array('/', '.'), '', $dir).'/'; + } + + // -------------------------------------------------------------------- + + /** + * Fetch the sub-directory (if any) that contains the requested controller class + * + * @access public + * @return string + */ + function fetch_directory() + { + return $this->directory; + } + + // -------------------------------------------------------------------- + + /** + * Set the controller overrides + * + * @access public + * @param array + * @return null + */ + function _set_overrides($routing) + { + if ( ! is_array($routing)) + { + return; + } + + if (isset($routing['directory'])) + { + $this->set_directory($routing['directory']); + } + + if (isset($routing['controller']) AND $routing['controller'] != '') + { + $this->set_class($routing['controller']); + } + + if (isset($routing['function'])) + { + $routing['function'] = ($routing['function'] == '') ? 'index' : $routing['function']; + $this->set_method($routing['function']); + } + } + + +} +// END Router Class + +/* End of file Router.php */ +/* Location: ./system/core/Router.php */ \ No newline at end of file diff --git a/system/core/Security.php b/system/core/Security.php new file mode 100755 index 0000000..efa2df9 --- /dev/null +++ b/system/core/Security.php @@ -0,0 +1,875 @@ + '[removed]', + 'document.write' => '[removed]', + '.parentNode' => '[removed]', + '.innerHTML' => '[removed]', + 'window.location' => '[removed]', + '-moz-binding' => '[removed]', + '' => '-->', + ' '<![CDATA[', + '' => '<comment>' + ); + + /* never allowed, regex replacement */ + /** + * List of never allowed regex replacement + * + * @var array + * @access protected + */ + protected $_never_allowed_regex = array( + 'javascript\s*:', + 'expression\s*(\(|&\#40;)', // CSS and IE + 'vbscript\s*:', // IE, surprise! + 'Redirect\s+302', + "([\"'])?data\s*:[^\\1]*?base64[^\\1]*?,[^\\1]*?\\1?" + ); + + /** + * Constructor + * + * @return void + */ + public function __construct() + { + // Is CSRF protection enabled? + if (config_item('csrf_protection') === TRUE) + { + // CSRF config + foreach (array('csrf_expire', 'csrf_token_name', 'csrf_cookie_name') as $key) + { + if (FALSE !== ($val = config_item($key))) + { + $this->{'_'.$key} = $val; + } + } + + // Append application specific cookie prefix + if (config_item('cookie_prefix')) + { + $this->_csrf_cookie_name = config_item('cookie_prefix').$this->_csrf_cookie_name; + } + + // Set the CSRF hash + $this->_csrf_set_hash(); + } + + log_message('debug', "Security Class Initialized"); + } + + // -------------------------------------------------------------------- + + /** + * Verify Cross Site Request Forgery Protection + * + * @return object + */ + public function csrf_verify() + { + // If it's not a POST request we will set the CSRF cookie + if (strtoupper($_SERVER['REQUEST_METHOD']) !== 'POST') + { + return $this->csrf_set_cookie(); + } + + // Do the tokens exist in both the _POST and _COOKIE arrays? + if ( ! isset($_POST[$this->_csrf_token_name], $_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'); + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * Set Cross Site Request Forgery Protection Cookie + * + * @return object + */ + public function csrf_set_cookie() + { + $expire = time() + $this->_csrf_expire; + $secure_cookie = (config_item('cookie_secure') === TRUE) ? 1 : 0; + + if ($secure_cookie && (empty($_SERVER['HTTPS']) OR strtolower($_SERVER['HTTPS']) === 'off')) + { + return FALSE; + } + + setcookie($this->_csrf_cookie_name, $this->_csrf_hash, $expire, config_item('cookie_path'), config_item('cookie_domain'), $secure_cookie); + + log_message('debug', "CRSF cookie Set"); + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * Show CSRF Error + * + * @return void + */ + public function csrf_show_error() + { + show_error('The action you have requested is not allowed.'); + } + + // -------------------------------------------------------------------- + + /** + * Get CSRF Hash + * + * Getter Method + * + * @return string self::_csrf_hash + */ + public function get_csrf_hash() + { + return $this->_csrf_hash; + } + + // -------------------------------------------------------------------- + + /** + * Get CSRF Token Name + * + * Getter Method + * + * @return string self::csrf_token_name + */ + public function get_csrf_token_name() + { + return $this->_csrf_token_name; + } + + // -------------------------------------------------------------------- + + /** + * 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 + * + * @param mixed string or array + * @param bool + * @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); + + // Validate Entities in URLs + $str = $this->_validate_entities($str); + + /* + * URL Decode + * + * Just in case stuff like this is submitted: + * + * Google + * + * 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; + + // Remove Strings that are never allowed + $str = $this->_do_never_allowed($str); + + /* + * Makes PHP tags safe + * + * Note: XML tags are inadvertently replaced too: + * + * '), 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', 'base64', + '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("/]*?)(>|$)#si", array($this, '_js_link_removal'), $str); + } + + if (preg_match("/]*?)(\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 evil attributes such as style, onclick and xmlns + $str = $this->_remove_evil_attributes($str, $is_image); + + /* + * 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: + * 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 + $str = $this->_do_never_allowed($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) + { + return ($str == $converted_string) ? TRUE: FALSE; + } + + log_message('debug', "XSS Filtering completed"); + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Random Hash for protecting URLs + * + * @return string + */ + public function xss_hash() + { + if ($this->_xss_hash == '') + { + mt_srand(); + $this->_xss_hash = md5(time() + mt_rand(0, 1999999999)); + } + + return $this->_xss_hash; + } + + // -------------------------------------------------------------------- + + /** + * HTML Entities Decode + * + * This function is a replacement for html_entity_decode() + * + * 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. + * + * @param string + * @param string + * @return string + */ + public function entity_decode($str, $charset='UTF-8') + { + if (stristr($str, '&') === FALSE) + { + return $str; + } + + $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); + } + + // -------------------------------------------------------------------- + + /** + * Filename Security + * + * @param string + * @param bool + * @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[] = '/'; + } + + $str = remove_invisible_characters($str, FALSE); + return stripslashes(str_replace($bad, '', $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 + * + * @param type + * @return type + */ + protected function _compact_exploded_words($matches) + { + return preg_replace('/\s+/s', '', $matches[1]).$matches[2]; + } + + // -------------------------------------------------------------------- + + /* + * Remove Evil HTML Attributes (like evenhandlers and style) + * + * It removes the evil attribute and either: + * - Everything up until a space + * For example, everything between the pipes: + * + * - Everything inside the quotes + * For example, everything between the pipes: + * + * + * @param string $str The string to check + * @param boolean $is_image TRUE if this is an image + * @return string The string with the evil attributes removed + */ + protected function _remove_evil_attributes($str, $is_image) + { + // All javascript event handlers (e.g. onload, onclick, onmouseover), style, and xmlns + $evil_attributes = array('on\w*', 'style', 'xmlns', 'formaction'); + + if ($is_image === TRUE) + { + /* + * Adobe Photoshop puts XML metadata into JFIF images, + * including namespacing, so we have to allow this for images. + */ + unset($evil_attributes[array_search('xmlns', $evil_attributes)]); + } + + do { + $count = 0; + $attribs = array(); + + // find occurrences of illegal attribute strings with quotes (042 and 047 are octal quotes) + preg_match_all('/('.implode('|', $evil_attributes).')\s*=\s*(\042|\047)([^\\2]*?)(\\2)/is', $str, $matches, PREG_SET_ORDER); + + foreach ($matches as $attr) + { + $attribs[] = preg_quote($attr[0], '/'); + } + + // find occurrences of illegal attribute strings without quotes + preg_match_all('/('.implode('|', $evil_attributes).')\s*=\s*([^\s>]*)/is', $str, $matches, PREG_SET_ORDER); + + foreach ($matches as $attr) + { + $attribs[] = preg_quote($attr[0], '/'); + } + + // replace illegal attribute strings that are inside an html tag + if (count($attribs) > 0) + { + $str = preg_replace('/(<]+?)([^A-Za-z<>\-])(.*?)('.implode('|', $attribs).')(.*?)([\s><]?)([><]*)/i', '$1$2 $4$6$7$8', $str, -1, $count); + } + + } while ($count); + + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Sanitize Naughty HTML + * + * Callback function for xss_clean() to remove naughty HTML elements + * + * @param array + * @return string + */ + protected 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 + * + * @param array + * @return string + */ + protected function _js_link_removal($match) + { + return str_replace( + $match[1], + preg_replace( + '#href=.*?(alert\(|alert&\#40;|javascript\:|livescript\:|mocha\:|charset\=|window\.|document\.|\.cookie|_filter_attributes(str_replace(array('<', '>'), '', $match[1])) + ), + $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 + * + * @param array + * @return string + */ + protected function _js_img_removal($match) + { + return str_replace( + $match[1], + preg_replace( + '#src=.*?(alert\(|alert&\#40;|javascript\:|livescript\:|mocha\:|charset\=|window\.|document\.|\.cookie|_filter_attributes(str_replace(array('<', '>'), '', $match[1])) + ), + $match[0] + ); + } + + // -------------------------------------------------------------------- + + /** + * Attribute Conversion + * + * Used as a callback for XSS Clean + * + * @param array + * @return string + */ + protected function _convert_attribute($match) + { + return str_replace(array('>', '<', '\\'), array('>', '<', '\\\\'), $match[0]); + } + + // -------------------------------------------------------------------- + + /** + * Filter Attributes + * + * Filters tag attributes for consistency and safety + * + * @param string + * @return string + */ + protected 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 + * + * @param array + * @return string + */ + protected function _decode_entity($match) + { + return $this->entity_decode($match[0], strtoupper(config_item('charset'))); + } + + // -------------------------------------------------------------------- + + /** + * Validate URL entities + * + * Called by xss_clean() + * + * @param string + * @return string + */ + protected function _validate_entities($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); + + return $str; + } + + // ---------------------------------------------------------------------- + + /** + * Do Never Allowed + * + * A utility function for xss_clean() + * + * @param string + * @return string + */ + protected function _do_never_allowed($str) + { + $str = str_replace(array_keys($this->_never_allowed_str), $this->_never_allowed_str, $str); + + foreach ($this->_never_allowed_regex as $regex) + { + $str = preg_replace('#'.$regex.'#is', '[removed]', $str); + } + + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Set Cross Site Request Forgery Protection Cookie + * + * @return string + */ + protected 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]) && + preg_match('#^[0-9a-f]{32}$#iS', $_COOKIE[$this->_csrf_cookie_name]) === 1) + { + return $this->_csrf_hash = $_COOKIE[$this->_csrf_cookie_name]; + } + + return $this->_csrf_hash = md5(uniqid(rand(), TRUE)); + } + + return $this->_csrf_hash; + } + +} + +/* End of file Security.php */ +/* Location: ./system/libraries/Security.php */ diff --git a/system/core/URI.php b/system/core/URI.php new file mode 100755 index 0000000..a2f3b23 --- /dev/null +++ b/system/core/URI.php @@ -0,0 +1,654 @@ +config =& load_class('Config', 'core'); + log_message('debug', "URI Class Initialized"); + } + + + // -------------------------------------------------------------------- + + /** + * Get the URI String + * + * @access private + * @return string + */ + function _fetch_uri_string() + { + if (strtoupper($this->config->item('uri_protocol')) == 'AUTO') + { + // Is the request coming from the command line? + if (php_sapi_name() == 'cli' or defined('STDIN')) + { + $this->_set_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->_set_uri_string($uri); + return; + } + + // Is there a PATH_INFO variable? + // Note: some servers seem to have trouble with getenv() so we'll test it two ways + $path = (isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO'); + if (trim($path, '/') != '' && $path != "/".SELF) + { + $this->_set_uri_string($path); + return; + } + + // No PATH_INFO?... What about QUERY_STRING? + $path = (isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING'); + if (trim($path, '/') != '') + { + $this->_set_uri_string($path); + return; + } + + // As a last ditch effort lets try using the $_GET array + if (is_array($_GET) && count($_GET) == 1 && trim(key($_GET), '/') != '') + { + $this->_set_uri_string(key($_GET)); + return; + } + + // We've exhausted all our options... + $this->uri_string = ''; + return; + } + + $uri = strtoupper($this->config->item('uri_protocol')); + + if ($uri == 'REQUEST_URI') + { + $this->_set_uri_string($this->_detect_uri()); + return; + } + elseif ($uri == 'CLI') + { + $this->_set_uri_string($this->_parse_cli_args()); + return; + } + + $path = (isset($_SERVER[$uri])) ? $_SERVER[$uri] : @getenv($uri); + $this->_set_uri_string($path); + } + + // -------------------------------------------------------------------- + + /** + * Set the URI String + * + * @access public + * @param string + * @return string + */ + function _set_uri_string($str) + { + // Filter out control characters + $str = remove_invisible_characters($str, FALSE); + + // If the URI contains only a slash we'll kill it + $this->uri_string = ($str == '/') ? '' : $str; + } + + // -------------------------------------------------------------------- + + /** + * Detects the URI + * + * This function will detect the URI automatically and fix the query string + * if necessary. + * + * @access private + * @return string + */ + private function _detect_uri() + { + if ( ! isset($_SERVER['REQUEST_URI']) OR ! isset($_SERVER['SCRIPT_NAME'])) + { + return ''; + } + + $uri = $_SERVER['REQUEST_URI']; + if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0) + { + $uri = substr($uri, strlen($_SERVER['SCRIPT_NAME'])); + } + elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0) + { + $uri = substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME']))); + } + + // This section ensures that even on servers that require the URI to be in the query string (Nginx) a correct + // URI is found, and also fixes the QUERY_STRING server var and $_GET array. + if (strncmp($uri, '?/', 2) === 0) + { + $uri = substr($uri, 2); + } + $parts = preg_split('#\?#i', $uri, 2); + $uri = $parts[0]; + if (isset($parts[1])) + { + $_SERVER['QUERY_STRING'] = $parts[1]; + parse_str($_SERVER['QUERY_STRING'], $_GET); + } + else + { + $_SERVER['QUERY_STRING'] = ''; + $_GET = array(); + } + + if ($uri == '/' || empty($uri)) + { + return '/'; + } + + $uri = parse_url($uri, PHP_URL_PATH); + + // Do some final cleaning of the URI and return it + return str_replace(array('//', '../'), '/', trim($uri, '/')); + } + + // -------------------------------------------------------------------- + + /** + * Parse cli arguments + * + * Take each command line argument and assume it is a URI segment. + * + * @access private + * @return string + */ + private function _parse_cli_args() + { + $args = array_slice($_SERVER['argv'], 1); + + return $args ? '/' . implode('/', $args) : ''; + } + + // -------------------------------------------------------------------- + + /** + * Filter segments for malicious characters + * + * @access private + * @param string + * @return string + */ + function _filter_uri($str) + { + if ($str != '' && $this->config->item('permitted_uri_chars') != '' && $this->config->item('enable_query_strings') == FALSE) + { + // preg_quote() in PHP 5.3 escapes -, so the str_replace() and addition of - to preg_quote() is to maintain backwards + // compatibility as many are unaware of how characters in the permitted_uri_chars will be parsed as a regex pattern + if ( ! preg_match("|^[".str_replace(array('\\-', '\-'), '-', preg_quote($this->config->item('permitted_uri_chars'), '-'))."]+$|i", $str)) + { + show_error('The URI you submitted has disallowed characters.', 400); + } + } + + // Convert programatic characters to entities + $bad = array('$', '(', ')', '%28', '%29'); + $good = array('$', '(', ')', '(', ')'); + + return str_replace($bad, $good, $str); + } + + // -------------------------------------------------------------------- + + /** + * Remove the suffix from the URL if needed + * + * @access private + * @return void + */ + function _remove_url_suffix() + { + if ($this->config->item('url_suffix') != "") + { + $this->uri_string = preg_replace("|".preg_quote($this->config->item('url_suffix'))."$|", "", $this->uri_string); + } + } + + // -------------------------------------------------------------------- + + /** + * Explode the URI Segments. The individual segments will + * be stored in the $this->segments array. + * + * @access private + * @return void + */ + function _explode_segments() + { + foreach (explode("/", preg_replace("|/*(.+?)/*$|", "\\1", $this->uri_string)) as $val) + { + // Filter segments for security + $val = trim($this->_filter_uri($val)); + + if ($val != '') + { + $this->segments[] = $val; + } + } + } + + // -------------------------------------------------------------------- + /** + * Re-index Segments + * + * This function re-indexes the $this->segment array so that it + * starts at 1 rather than 0. Doing so makes it simpler to + * use functions like $this->uri->segment(n) since there is + * a 1:1 relationship between the segment array and the actual segments. + * + * @access private + * @return void + */ + function _reindex_segments() + { + array_unshift($this->segments, NULL); + array_unshift($this->rsegments, NULL); + unset($this->segments[0]); + unset($this->rsegments[0]); + } + + // -------------------------------------------------------------------- + + /** + * Fetch a URI Segment + * + * This function returns the URI segment based on the number provided. + * + * @access public + * @param integer + * @param bool + * @return string + */ + function segment($n, $no_result = FALSE) + { + return ( ! isset($this->segments[$n])) ? $no_result : $this->segments[$n]; + } + + // -------------------------------------------------------------------- + + /** + * Fetch a URI "routed" Segment + * + * This function returns the re-routed URI segment (assuming routing rules are used) + * based on the number provided. If there is no routing this function returns the + * same result as $this->segment() + * + * @access public + * @param integer + * @param bool + * @return string + */ + function rsegment($n, $no_result = FALSE) + { + return ( ! isset($this->rsegments[$n])) ? $no_result : $this->rsegments[$n]; + } + + // -------------------------------------------------------------------- + + /** + * Generate a key value pair from the URI string + * + * This function generates and associative array of URI data starting + * at the supplied segment. For example, if this is your URI: + * + * example.com/user/search/name/joe/location/UK/gender/male + * + * You can use this function to generate an array with this prototype: + * + * array ( + * name => joe + * location => UK + * gender => male + * ) + * + * @access public + * @param integer the starting segment number + * @param array an array of default values + * @return array + */ + function uri_to_assoc($n = 3, $default = array()) + { + return $this->_uri_to_assoc($n, $default, 'segment'); + } + /** + * Identical to above only it uses the re-routed segment array + * + * @access public + * @param integer the starting segment number + * @param array an array of default values + * @return array + * + */ + function ruri_to_assoc($n = 3, $default = array()) + { + return $this->_uri_to_assoc($n, $default, 'rsegment'); + } + + // -------------------------------------------------------------------- + + /** + * Generate a key value pair from the URI string or Re-routed URI string + * + * @access private + * @param integer the starting segment number + * @param array an array of default values + * @param string which array we should use + * @return array + */ + function _uri_to_assoc($n = 3, $default = array(), $which = 'segment') + { + if ($which == 'segment') + { + $total_segments = 'total_segments'; + $segment_array = 'segment_array'; + } + else + { + $total_segments = 'total_rsegments'; + $segment_array = 'rsegment_array'; + } + + if ( ! is_numeric($n)) + { + return $default; + } + + if (isset($this->keyval[$n])) + { + return $this->keyval[$n]; + } + + if ($this->$total_segments() < $n) + { + if (count($default) == 0) + { + return array(); + } + + $retval = array(); + foreach ($default as $val) + { + $retval[$val] = FALSE; + } + return $retval; + } + + $segments = array_slice($this->$segment_array(), ($n - 1)); + + $i = 0; + $lastval = ''; + $retval = array(); + foreach ($segments as $seg) + { + if ($i % 2) + { + $retval[$lastval] = $seg; + } + else + { + $retval[$seg] = FALSE; + $lastval = $seg; + } + + $i++; + } + + if (count($default) > 0) + { + foreach ($default as $val) + { + if ( ! array_key_exists($val, $retval)) + { + $retval[$val] = FALSE; + } + } + } + + // Cache the array for reuse + $this->keyval[$n] = $retval; + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Generate a URI string from an associative array + * + * + * @access public + * @param array an associative array of key/values + * @return array + */ + function assoc_to_uri($array) + { + $temp = array(); + foreach ((array)$array as $key => $val) + { + $temp[] = $key; + $temp[] = $val; + } + + return implode('/', $temp); + } + + // -------------------------------------------------------------------- + + /** + * Fetch a URI Segment and add a trailing slash + * + * @access public + * @param integer + * @param string + * @return string + */ + function slash_segment($n, $where = 'trailing') + { + return $this->_slash_segment($n, $where, 'segment'); + } + + // -------------------------------------------------------------------- + + /** + * Fetch a URI Segment and add a trailing slash + * + * @access public + * @param integer + * @param string + * @return string + */ + function slash_rsegment($n, $where = 'trailing') + { + return $this->_slash_segment($n, $where, 'rsegment'); + } + + // -------------------------------------------------------------------- + + /** + * Fetch a URI Segment and add a trailing slash - helper function + * + * @access private + * @param integer + * @param string + * @param string + * @return string + */ + function _slash_segment($n, $where = 'trailing', $which = 'segment') + { + $leading = '/'; + $trailing = '/'; + + if ($where == 'trailing') + { + $leading = ''; + } + elseif ($where == 'leading') + { + $trailing = ''; + } + + return $leading.$this->$which($n).$trailing; + } + + // -------------------------------------------------------------------- + + /** + * Segment Array + * + * @access public + * @return array + */ + function segment_array() + { + return $this->segments; + } + + // -------------------------------------------------------------------- + + /** + * Routed Segment Array + * + * @access public + * @return array + */ + function rsegment_array() + { + return $this->rsegments; + } + + // -------------------------------------------------------------------- + + /** + * Total number of segments + * + * @access public + * @return integer + */ + function total_segments() + { + return count($this->segments); + } + + // -------------------------------------------------------------------- + + /** + * Total number of routed segments + * + * @access public + * @return integer + */ + function total_rsegments() + { + return count($this->rsegments); + } + + // -------------------------------------------------------------------- + + /** + * Fetch the entire URI string + * + * @access public + * @return string + */ + function uri_string() + { + return $this->uri_string; + } + + + // -------------------------------------------------------------------- + + /** + * Fetch the entire Re-routed URI string + * + * @access public + * @return string + */ + function ruri_string() + { + return '/'.implode('/', $this->rsegment_array()); + } + +} +// END URI Class + +/* End of file URI.php */ +/* Location: ./system/core/URI.php */ \ No newline at end of file diff --git a/system/core/Utf8.php b/system/core/Utf8.php new file mode 100755 index 0000000..1a5bee1 --- /dev/null +++ b/system/core/Utf8.php @@ -0,0 +1,165 @@ +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 remove_invisible_characters($str, FALSE); + } + + // -------------------------------------------------------------------- + + /** + * Convert to UTF-8 + * + * Attempts to convert a string to UTF-8 + * + * @access public + * @param string + * @param string - input encoding + * @return string + */ + function convert_to_utf8($str, $encoding) + { + if (function_exists('iconv')) + { + $str = @iconv($encoding, 'UTF-8', $str); + } + elseif (function_exists('mb_convert_encoding')) + { + $str = @mb_convert_encoding($str, 'UTF-8', $encoding); + } + else + { + return FALSE; + } + + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Is ASCII? + * + * Tests if a string is standard 7-bit ASCII or not + * + * @access public + * @param string + * @return bool + */ + function _is_ascii($str) + { + return (preg_match('/[^\x00-\x7F]/S', $str) == 0); + } + + // -------------------------------------------------------------------- + +} +// End Utf8 Class + +/* End of file Utf8.php */ +/* Location: ./system/core/Utf8.php */ \ No newline at end of file diff --git a/system/core/index.html b/system/core/index.html new file mode 100755 index 0000000..c942a79 --- /dev/null +++ b/system/core/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

    Directory access is forbidden.

    + + + \ No newline at end of file diff --git a/system/database/DB.php b/system/database/DB.php new file mode 100755 index 0000000..f8d0204 --- /dev/null +++ b/system/database/DB.php @@ -0,0 +1,209 @@ +load->get_package_paths() as $path) + { + if ($path !== APPPATH) + { + if (file_exists($file_path = $path.'config/'.ENVIRONMENT.'/database.php')) + { + include($file_path); + } + elseif (file_exists($file_path = $path.'config/database.php')) + { + include($file_path); + } + } + } + + if ( ! isset($db) OR count($db) === 0) + { + show_error('No database connection settings were found in the database config file.'); + } + + if ($params !== '') + { + $active_group = $params; + } + + if ( ! isset($active_group)) + { + show_error('You have not specified a database connection group via $active_group in your config/database.php file.'); + } + elseif ( ! isset($db[$active_group])) + { + show_error('You have specified an invalid database connection group ('.$active_group.') in your config/database.php file.'); + } + + $params = $db[$active_group]; + } + elseif (is_string($params)) + { + /** + * Parse the URL from the DSN string + * Database settings can be passed as discreet + * parameters or as a data source name in the first + * parameter. DSNs must have this prototype: + * $dsn = 'driver://username:password@hostname/database'; + */ + if (($dsn = @parse_url($params)) === FALSE) + { + show_error('Invalid DB Connection String'); + } + + $params = array( + 'dbdriver' => $dsn['scheme'], + 'hostname' => isset($dsn['host']) ? rawurldecode($dsn['host']) : '', + 'port' => isset($dsn['port']) ? rawurldecode($dsn['port']) : '', + 'username' => isset($dsn['user']) ? rawurldecode($dsn['user']) : '', + 'password' => isset($dsn['pass']) ? rawurldecode($dsn['pass']) : '', + 'database' => isset($dsn['path']) ? rawurldecode(substr($dsn['path'], 1)) : '' + ); + + // Were additional config items set? + if (isset($dsn['query'])) + { + parse_str($dsn['query'], $extra); + + foreach ($extra as $key => $val) + { + if (is_string($val) && in_array(strtoupper($val), array('TRUE', 'FALSE', 'NULL'))) + { + $val = var_export($val); + } + + $params[$key] = $val; + } + } + } + + // No DB specified yet? Beat them senseless... + if (empty($params['dbdriver'])) + { + show_error('You have not selected a database type to connect to.'); + } + + // Load the DB classes. Note: Since the query builder class is optional + // we need to dynamically create a class that extends proper parent class + // based on whether we're using the query builder class or not. + if ($query_builder_override !== NULL) + { + $query_builder = $query_builder_override; + } + // Backwards compatibility work-around for keeping the + // $active_record config variable working. Should be + // removed in v3.1 + elseif ( ! isset($query_builder) && isset($active_record)) + { + $query_builder = $active_record; + } + + require_once(BASEPATH.'database/DB_driver.php'); + + if ( ! isset($query_builder) OR $query_builder === TRUE) + { + require_once(BASEPATH.'database/DB_query_builder.php'); + if ( ! class_exists('CI_DB', FALSE)) + { + /** + * CI_DB + * + * Acts as an alias for both CI_DB_driver and CI_DB_query_builder. + * + * @see CI_DB_query_builder + * @see CI_DB_driver + */ + class CI_DB extends CI_DB_query_builder { } + } + } + elseif ( ! class_exists('CI_DB', FALSE)) + { + /** + * @ignore + */ + class CI_DB extends CI_DB_driver { } + } + + // Load the DB driver + $driver_file = BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].'_driver.php'; + + file_exists($driver_file) OR show_error('Invalid DB driver'); + require_once($driver_file); + + // Instantiate the DB adapter + $driver = 'CI_DB_'.$params['dbdriver'].'_driver'; + $DB = new $driver($params); + + // Check for a subdriver + if ( ! empty($DB->subdriver)) + { + $driver_file = BASEPATH.'database/drivers/'.$DB->dbdriver.'/subdrivers/'.$DB->dbdriver.'_'.$DB->subdriver.'_driver.php'; + + if (file_exists($driver_file)) + { + require_once($driver_file); + $driver = 'CI_DB_'.$DB->dbdriver.'_'.$DB->subdriver.'_driver'; + $DB = new $driver($params); + } + } + + if ($DB->autoinit === TRUE) + { + $DB->initialize(); + } + + return $DB; +} + +/* End of file DB.php */ +/* Location: ./system/database/DB.php */ \ No newline at end of file diff --git a/system/database/DB_cache.php b/system/database/DB_cache.php new file mode 100755 index 0000000..b855ff2 --- /dev/null +++ b/system/database/DB_cache.php @@ -0,0 +1,218 @@ +CI and load the file helper since we use it a lot + $this->CI =& get_instance(); + $this->db =& $db; + $this->CI->load->helper('file'); + + $this->check_path(); + } + + // -------------------------------------------------------------------- + + /** + * Set Cache Directory Path + * + * @param string $path Path to the cache directory + * @return bool + */ + public function check_path($path = '') + { + if ($path === '') + { + if ($this->db->cachedir === '') + { + return $this->db->cache_off(); + } + + $path = $this->db->cachedir; + } + + // Add a trailing slash to the path if needed + $path = realpath($path) + ? rtrim(realpath($path), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR + : rtrim($path, '/').'/'; + + if ( ! is_dir($path)) + { + log_message('debug', 'DB cache path error: '.$path); + + // If the path is wrong we'll turn off caching + return $this->db->cache_off(); + } + + if ( ! is_really_writable($path)) + { + log_message('debug', 'DB cache dir not writable: '.$path); + + // If the path is not really writable we'll turn off caching + return $this->db->cache_off(); + } + + $this->db->cachedir = $path; + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Retrieve a cached query + * + * The URI being requested will become the name of the cache sub-folder. + * An MD5 hash of the SQL statement will become the cache file name. + * + * @param string $sql + * @return string + */ + public function read($sql) + { + $segment_one = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1); + $segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2); + $filepath = $this->db->cachedir.$segment_one.'+'.$segment_two.'/'.md5($sql); + + if (FALSE === ($cachedata = @file_get_contents($filepath))) + { + return FALSE; + } + + return unserialize($cachedata); + } + + // -------------------------------------------------------------------- + + /** + * Write a query to a cache file + * + * @param string $sql + * @param object $object + * @return bool + */ + public function write($sql, $object) + { + $segment_one = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1); + $segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2); + $dir_path = $this->db->cachedir.$segment_one.'+'.$segment_two.'/'; + $filename = md5($sql); + + if ( ! is_dir($dir_path)) + { + if ( ! @mkdir($dir_path, 0777)) + { + return FALSE; + } + + @chmod($dir_path, 0777); + } + + if (write_file($dir_path.$filename, serialize($object)) === FALSE) + { + return FALSE; + } + + @chmod($dir_path.$filename, 0666); + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Delete cache files within a particular directory + * + * @param string $segment_one + * @param string $segment_two + * @return void + */ + public function delete($segment_one = '', $segment_two = '') + { + if ($segment_one === '') + { + $segment_one = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1); + } + + if ($segment_two === '') + { + $segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2); + } + + $dir_path = $this->db->cachedir.$segment_one.'+'.$segment_two.'/'; + delete_files($dir_path, TRUE); + } + + // -------------------------------------------------------------------- + + /** + * Delete all existing cache files + * + * @return void + */ + public function delete_all() + { + delete_files($this->db->cachedir, TRUE, TRUE); + } + +} + +/* End of file DB_cache.php */ +/* Location: ./system/database/DB_cache.php */ \ No newline at end of file diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php new file mode 100755 index 0000000..12ab5bb --- /dev/null +++ b/system/database/DB_driver.php @@ -0,0 +1,1886 @@ + $val) + { + $this->$key = $val; + } + } + + log_message('debug', 'Database Driver Class Initialized'); + } + + // -------------------------------------------------------------------- + + /** + * Initialize Database Settings + * + * @return bool + */ + public function initialize() + { + /* If an established connection is available, then there's + * no need to connect and select the database. + * + * Depending on the database driver, conn_id can be either + * boolean TRUE, a resource or an object. + */ + if ($this->conn_id) + { + return TRUE; + } + + // ---------------------------------------------------------------- + + // Connect to the database and set the connection ID + $this->conn_id = $this->db_connect($this->pconnect); + + // No connection resource? Check if there is a failover else throw an error + if ( ! $this->conn_id) + { + // Check if there is a failover set + if ( ! empty($this->failover) && is_array($this->failover)) + { + // Go over all the failovers + foreach ($this->failover as $failover) + { + // Replace the current settings with those of the failover + foreach ($failover as $key => $val) + { + $this->$key = $val; + } + + // Try to connect + $this->conn_id = $this->db_connect($this->pconnect); + + // If a connection is made break the foreach loop + if ($this->conn_id) + { + break; + } + } + } + + // We still don't have a connection? + if ( ! $this->conn_id) + { + log_message('error', 'Unable to connect to the database'); + + if ($this->db_debug) + { + $this->display_error('db_unable_to_connect'); + } + + return FALSE; + } + } + + // Now we set the character set and that's all + return $this->db_set_charset($this->char_set); + } + + // -------------------------------------------------------------------- + + /** + * Persistent database connection + * + * @return resource + */ + public function db_pconnect() + { + return $this->db_connect(TRUE); + } + + // -------------------------------------------------------------------- + + /** + * Reconnect + * + * Keep / reestablish the db connection if no queries have been + * sent for a length of time exceeding the server's idle timeout. + * + * This is just a dummy method to allow drivers without such + * functionality to not declare it, while others will override it. + * + * @return void + */ + public function reconnect() + { + } + + // -------------------------------------------------------------------- + + /** + * Select database + * + * This is just a dummy method to allow drivers without such + * functionality to not declare it, while others will override it. + * + * @return bool + */ + public function db_select() + { + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Set client character set + * + * @param string + * @return bool + */ + public function db_set_charset($charset) + { + if (method_exists($this, '_db_set_charset') && ! $this->_db_set_charset($charset)) + { + log_message('error', 'Unable to set database connection charset: '.$charset); + + if ($this->db_debug) + { + $this->display_error('db_unable_to_set_charset', $charset); + } + + return FALSE; + } + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * The name of the platform in use (mysql, mssql, etc...) + * + * @return string + */ + public function platform() + { + return $this->dbdriver; + } + + // -------------------------------------------------------------------- + + /** + * Database version number + * + * Returns a string containing the version of the database being used. + * Most drivers will override this method. + * + * @return string + */ + public function version() + { + if (isset($this->data_cache['version'])) + { + return $this->data_cache['version']; + } + + if (FALSE === ($sql = $this->_version())) + { + return ($this->db_debug) ? $this->display_error('db_unsupported_function') : FALSE; + } + + $query = $this->query($sql)->row(); + return $this->data_cache['version'] = $query->ver; + } + + // -------------------------------------------------------------------- + + /** + * Version number query string + * + * @return string + */ + protected function _version() + { + return 'SELECT VERSION() AS ver'; + } + + // -------------------------------------------------------------------- + + /** + * Execute the query + * + * Accepts an SQL string as input and returns a result object upon + * successful execution of a "read" type query. Returns boolean TRUE + * upon successful execution of a "write" type query. Returns boolean + * FALSE upon failure, and if the $db_debug variable is set to TRUE + * will raise an error. + * + * @param string $sql + * @param array $binds = FALSE An array of binding data + * @param bool $return_object = NULL + * @return mixed + */ + public function query($sql, $binds = FALSE, $return_object = NULL) + { + if ($sql === '') + { + log_message('error', 'Invalid query: '.$sql); + return ($this->db_debug) ? $this->display_error('db_invalid_query') : FALSE; + } + elseif ( ! is_bool($return_object)) + { + $return_object = ! $this->is_write_type($sql); + } + + // Verify table prefix and replace if necessary + if ($this->dbprefix !== '' && $this->swap_pre !== '' && $this->dbprefix !== $this->swap_pre) + { + $sql = preg_replace('/(\W)'.$this->swap_pre.'(\S+?)/', '\\1'.$this->dbprefix.'\\2', $sql); + } + + // Compile binds if needed + if ($binds !== FALSE) + { + $sql = $this->compile_binds($sql, $binds); + } + + // Is query caching enabled? If the query is a "read type" + // we will load the caching class and return the previously + // cached query if it exists + if ($this->cache_on === TRUE && $return_object === TRUE && $this->_cache_init()) + { + $this->load_rdriver(); + if (FALSE !== ($cache = $this->CACHE->read($sql))) + { + return $cache; + } + } + + // Save the query for debugging + if ($this->save_queries === TRUE) + { + $this->queries[] = $sql; + } + + // Start the Query Timer + $time_start = microtime(TRUE); + + // Run the Query + if (FALSE === ($this->result_id = $this->simple_query($sql))) + { + if ($this->save_queries === TRUE) + { + $this->query_times[] = 0; + } + + // This will trigger a rollback if transactions are being used + $this->_trans_status = FALSE; + + // Grab the error now, as we might run some additional queries before displaying the error + $error = $this->error(); + + // Log errors + log_message('error', 'Query error: '.$error['message'].' - Invalid query: '.$sql); + + if ($this->db_debug) + { + // 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 + // transactions to remain in limbo. + if ($this->_trans_depth !== 0) + { + do + { + $this->trans_complete(); + } + while ($this->_trans_depth !== 0); + } + + // Display errors + return $this->display_error(array('Error Number: '.$error['code'], $error['message'], $sql)); + } + + return FALSE; + } + + // Stop and aggregate the query time results + $time_end = microtime(TRUE); + $this->benchmark += $time_end - $time_start; + + if ($this->save_queries === TRUE) + { + $this->query_times[] = $time_end - $time_start; + } + + // Increment the query counter + $this->query_count++; + + // Will we have a result object instantiated? If not - we'll simply return TRUE + if ($return_object !== TRUE) + { + // If caching is enabled we'll auto-cleanup any existing files related to this particular URI + if ($this->cache_on === TRUE && $this->cache_autodel === TRUE && $this->_cache_init()) + { + $this->CACHE->delete(); + } + + return TRUE; + } + + // Load and instantiate the result driver + $driver = $this->load_rdriver(); + $RES = new $driver($this); + + // Is query caching enabled? If so, we'll serialize the + // result object and save it to a cache file. + if ($this->cache_on === TRUE && $this->_cache_init()) + { + // We'll create a new instance of the result object + // only without the platform specific driver since + // we can't use it with cached data (the query result + // resource ID won't be any good once we've cached the + // result object, so we'll have to compile the data + // and save it) + $CR = new CI_DB_result($this); + $CR->result_object = $RES->result_object(); + $CR->result_array = $RES->result_array(); + $CR->num_rows = $RES->num_rows(); + + // Reset these since cached objects can not utilize resource IDs. + $CR->conn_id = NULL; + $CR->result_id = NULL; + + $this->CACHE->write($sql, $CR); + } + + return $RES; + } + + // -------------------------------------------------------------------- + + /** + * Load the result drivers + * + * @return string the name of the result class + */ + public function load_rdriver() + { + $driver = 'CI_DB_'.$this->dbdriver.'_result'; + + if ( ! class_exists($driver, FALSE)) + { + require_once(BASEPATH.'database/DB_result.php'); + require_once(BASEPATH.'database/drivers/'.$this->dbdriver.'/'.$this->dbdriver.'_result.php'); + } + + return $driver; + } + + // -------------------------------------------------------------------- + + /** + * Simple Query + * This is a simplified version of the query() function. Internally + * we only use it when running transaction commands since they do + * not require all the features of the main query() function. + * + * @param string the sql query + * @return mixed + */ + public function simple_query($sql) + { + if ( ! $this->conn_id) + { + $this->initialize(); + } + + return $this->_execute($sql); + } + + // -------------------------------------------------------------------- + + /** + * Disable Transactions + * This permits transactions to be disabled at run-time. + * + * @return void + */ + public function trans_off() + { + $this->trans_enabled = FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Enable/disable Transaction Strict Mode + * When strict mode is enabled, if you are running multiple groups of + * transactions, if one group fails all groups will be rolled back. + * If strict mode is disabled, each group is treated autonomously, meaning + * a failure of one group will not affect any others + * + * @param bool $mode = TRUE + * @return void + */ + public function trans_strict($mode = TRUE) + { + $this->trans_strict = is_bool($mode) ? $mode : TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Start Transaction + * + * @param bool $test_mode = FALSE + * @return void + */ + public function trans_start($test_mode = FALSE) + { + if ( ! $this->trans_enabled) + { + return FALSE; + } + + // When transactions are nested we only begin/commit/rollback the outermost ones + if ($this->_trans_depth > 0) + { + $this->_trans_depth += 1; + return; + } + + $this->trans_begin($test_mode); + $this->_trans_depth += 1; + } + + // -------------------------------------------------------------------- + + /** + * Complete Transaction + * + * @return bool + */ + public 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; + } + else + { + $this->_trans_depth = 0; + } + + // The query() function will set this flag to FALSE in the event that a query failed + if ($this->_trans_status === FALSE OR $this->_trans_failure === TRUE) + { + $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. + if ($this->trans_strict === FALSE) + { + $this->_trans_status = TRUE; + } + + log_message('debug', 'DB Transaction Failure'); + return FALSE; + } + + $this->trans_commit(); + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Lets you retrieve the transaction flag to determine if it has failed + * + * @return bool + */ + public function trans_status() + { + return $this->_trans_status; + } + + // -------------------------------------------------------------------- + + /** + * Compile Bindings + * + * @param string the sql statement + * @param array an array of bind data + * @return string + */ + public function compile_binds($sql, $binds) + { + if (empty($binds) OR empty($this->bind_marker) OR strpos($sql, $this->bind_marker) === FALSE) + { + return $sql; + } + elseif ( ! is_array($binds)) + { + $binds = array($binds); + $bind_count = 1; + } + else + { + // Make sure we're using numeric keys + $binds = array_values($binds); + $bind_count = count($binds); + } + + // We'll need the marker length later + $ml = strlen($this->bind_marker); + + // Make sure not to replace a chunk inside a string that happens to match the bind marker + if ($c = preg_match_all("/'[^']*'/i", $sql, $matches)) + { + $c = preg_match_all('/'.preg_quote($this->bind_marker, '/').'/i', + str_replace($matches[0], + str_replace($this->bind_marker, str_repeat(' ', $ml), $matches[0]), + $sql, $c), + $matches, PREG_OFFSET_CAPTURE); + + // Bind values' count must match the count of markers in the query + if ($bind_count !== $c) + { + return $sql; + } + } + elseif (($c = preg_match_all('/'.preg_quote($this->bind_marker, '/').'/i', $sql, $matches, PREG_OFFSET_CAPTURE)) !== $bind_count) + { + return $sql; + } + + do + { + $c--; + $sql = substr_replace($sql, $this->escape($binds[$c]), $matches[0][$c][1], $ml); + } + while ($c !== 0); + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Determines if a query is a "write" type. + * + * @param string An SQL query string + * @return bool + */ + public function is_write_type($sql) + { + return (bool) preg_match('/^\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK|REINDEX)\s/i', $sql); + } + + // -------------------------------------------------------------------- + + /** + * Calculate the aggregate query elapsed time + * + * @param int The number of decimal places + * @return int + */ + public function elapsed_time($decimals = 6) + { + return number_format($this->benchmark, $decimals); + } + + // -------------------------------------------------------------------- + + /** + * Returns the total number of queries + * + * @return int + */ + public function total_queries() + { + return $this->query_count; + } + + // -------------------------------------------------------------------- + + /** + * Returns the last query that was executed + * + * @return string + */ + public function last_query() + { + return end($this->queries); + } + + // -------------------------------------------------------------------- + + /** + * "Smart" Escape String + * + * Escapes data based on type + * Sets boolean and null types + * + * @param string + * @return mixed + */ + public function escape($str) + { + if (is_string($str) OR (is_object($str) && method_exists($str, '__toString'))) + { + return "'".$this->escape_str($str)."'"; + } + elseif (is_bool($str)) + { + return ($str === FALSE) ? 0 : 1; + } + elseif ($str === NULL) + { + return 'NULL'; + } + + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Escape String + * + * @param string $str + * @param bool $like Whether or not the string will be used in a LIKE condition + * @return string + */ + public function escape_str($str, $like = FALSE) + { + if (is_array($str)) + { + foreach ($str as $key => $val) + { + $str[$key] = $this->escape_str($val, $like); + } + + return $str; + } + + $str = $this->_escape_str($str); + + // escape LIKE condition wildcards + if ($like === TRUE) + { + return str_replace( + array($this->_like_escape_chr, '%', '_'), + array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_'), + $str + ); + } + + return $str; + } + + // -------------------------------------------------------------------- + + /** + * Escape LIKE String + * + * Calls the individual driver for platform + * specific escaping for LIKE conditions + * + * @param string|string[] + * @return mixed + */ + public function escape_like_str($str) + { + return $this->escape_str($str, TRUE); + } + + // -------------------------------------------------------------------- + + /** + * Platform-dependant string escape + * + * @param string + * @return string + */ + protected function _escape_str($str) + { + return str_replace("'", "''", remove_invisible_characters($str)); + } + + // -------------------------------------------------------------------- + + /** + * Primary + * + * Retrieves the primary key. It assumes that the row in the first + * position is the primary key + * + * @param string the table name + * @return string + */ + public function primary($table = '') + { + $fields = $this->list_fields($table); + return is_array($fields) ? current($fields) : FALSE; + } + + // -------------------------------------------------------------------- + + /** + * "Count All" query + * + * Generates a platform-specific query string that counts all records in + * the specified database + * + * @param string + * @return int + */ + public function count_all($table = '') + { + if ($table === '') + { + return 0; + } + + $query = $this->query($this->_count_string.$this->escape_identifiers('numrows').' FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE)); + if ($query->num_rows() === 0) + { + return 0; + } + + $query = $query->row(); + $this->_reset_select(); + return (int) $query->numrows; + } + + // -------------------------------------------------------------------- + + /** + * Returns an array of table names + * + * @param string $constrain_by_prefix = FALSE + * @return array + */ + public function list_tables($constrain_by_prefix = FALSE) + { + // Is there a cached result? + if (isset($this->data_cache['table_names'])) + { + return $this->data_cache['table_names']; + } + + if (FALSE === ($sql = $this->_list_tables($constrain_by_prefix))) + { + return ($this->db_debug) ? $this->display_error('db_unsupported_function') : FALSE; + } + + $this->data_cache['table_names'] = array(); + $query = $this->query($sql); + + foreach ($query->result_array() as $row) + { + // Do we know from which column to get the table name? + if ( ! isset($key)) + { + if (isset($row['table_name'])) + { + $key = 'table_name'; + } + elseif (isset($row['TABLE_NAME'])) + { + $key = 'TABLE_NAME'; + } + else + { + /* We have no other choice but to just get the first element's key. + * Due to array_shift() accepting its argument by reference, if + * E_STRICT is on, this would trigger a warning. So we'll have to + * assign it first. + */ + $key = array_keys($row); + $key = array_shift($key); + } + } + + $this->data_cache['table_names'][] = $row[$key]; + } + + return $this->data_cache['table_names']; + } + + // -------------------------------------------------------------------- + + /** + * Determine if a particular table exists + * + * @param string $table_name + * @return bool + */ + public function table_exists($table_name) + { + return in_array($this->protect_identifiers($table_name, TRUE, FALSE, FALSE), $this->list_tables()); + } + + // -------------------------------------------------------------------- + + /** + * Fetch Field Names + * + * @param string the table name + * @return array + */ + public function list_fields($table = '') + { + // Is there a cached result? + if (isset($this->data_cache['field_names'][$table])) + { + return $this->data_cache['field_names'][$table]; + } + + if ($table === '') + { + return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; + } + + if (FALSE === ($sql = $this->_list_columns($table))) + { + return ($this->db_debug) ? $this->display_error('db_unsupported_function') : FALSE; + } + + $query = $this->query($sql); + $this->data_cache['field_names'][$table] = array(); + + foreach ($query->result_array() as $row) + { + // Do we know from where to get the column's name? + if ( ! isset($key)) + { + if (isset($row['column_name'])) + { + $key = 'column_name'; + } + elseif (isset($row['COLUMN_NAME'])) + { + $key = 'COLUMN_NAME'; + } + else + { + // We have no other choice but to just get the first element's key. + $key = key($row); + } + } + + $this->data_cache['field_names'][$table][] = $row[$key]; + } + + return $this->data_cache['field_names'][$table]; + } + + // -------------------------------------------------------------------- + + /** + * Determine if a particular field exists + * + * @param string + * @param string + * @return bool + */ + public function field_exists($field_name, $table_name) + { + return in_array($field_name, $this->list_fields($table_name)); + } + + // -------------------------------------------------------------------- + + /** + * Returns an object with field data + * + * @param string the table name + * @return object + */ + public function field_data($table = '') + { + if ($table === '') + { + return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; + } + + $query = $this->query($this->_field_data($this->protect_identifiers($table, TRUE, NULL, FALSE))); + return $query->field_data(); + } + + // -------------------------------------------------------------------- + + /** + * Escape the SQL Identifiers + * + * This function escapes column and table names + * + * @param mixed + * @return mixed + */ + public function escape_identifiers($item) + { + if ($this->_escape_char === '' OR empty($item) OR in_array($item, $this->_reserved_identifiers)) + { + return $item; + } + elseif (is_array($item)) + { + foreach ($item as $key => $value) + { + $item[$key] = $this->escape_identifiers($value); + } + + return $item; + } + // Avoid breaking functions and literal values inside queries + elseif (ctype_digit($item) OR $item[0] === "'" OR ($this->_escape_char !== '"' && $item[0] === '"') OR strpos($item, '(') !== FALSE) + { + return $item; + } + + static $preg_ec = array(); + + if (empty($preg_ec)) + { + if (is_array($this->_escape_char)) + { + $preg_ec = array( + preg_quote($this->_escape_char[0], '/'), + preg_quote($this->_escape_char[1], '/'), + $this->_escape_char[0], + $this->_escape_char[1] + ); + } + else + { + $preg_ec[0] = $preg_ec[1] = preg_quote($this->_escape_char, '/'); + $preg_ec[2] = $preg_ec[3] = $this->_escape_char; + } + } + + foreach ($this->_reserved_identifiers as $id) + { + if (strpos($item, '.'.$id) !== FALSE) + { + return preg_replace('/'.$preg_ec[0].'?([^'.$preg_ec[1].'\.]+)'.$preg_ec[1].'?\./i', $preg_ec[2].'$1'.$preg_ec[3].'.', $item); + } + } + + return preg_replace('/'.$preg_ec[0].'?([^'.$preg_ec[1].'\.]+)'.$preg_ec[1].'?(\.)?/i', $preg_ec[2].'$1'.$preg_ec[3].'$2', $item); + } + + // -------------------------------------------------------------------- + + /** + * Generate an insert string + * + * @param string the table upon which the query will be performed + * @param array an associative array data of key/values + * @return string + */ + public function insert_string($table, $data) + { + $fields = $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); + } + + // -------------------------------------------------------------------- + + /** + * Insert statement + * + * Generates a platform-specific insert string from the supplied data + * + * @param string the table name + * @param array the insert keys + * @param array the insert values + * @return string + */ + protected function _insert($table, $keys, $values) + { + return 'INSERT INTO '.$table.' ('.implode(', ', $keys).') VALUES ('.implode(', ', $values).')'; + } + + // -------------------------------------------------------------------- + + /** + * Generate an update string + * + * @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 + */ + public function update_string($table, $data, $where) + { + if (empty($where)) + { + return FALSE; + } + + $this->where($where); + + $fields = array(); + foreach ($data as $key => $val) + { + $fields[$this->protect_identifiers($key)] = $this->escape($val); + } + + $sql = $this->_update($this->protect_identifiers($table, TRUE, NULL, FALSE), $fields); + $this->_reset_write(); + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Update statement + * + * Generates a platform-specific update string from the supplied data + * + * @param string the table name + * @param array the update data + * @return string + */ + protected function _update($table, $values) + { + foreach ($values as $key => $val) + { + $valstr[] = $key.' = '.$val; + } + + return 'UPDATE '.$table.' SET '.implode(', ', $valstr) + .$this->_compile_wh('qb_where') + .$this->_compile_order_by() + .($this->qb_limit ? ' LIMIT '.$this->qb_limit : ''); + } + + // -------------------------------------------------------------------- + + /** + * Tests whether the string has an SQL operator + * + * @param string + * @return bool + */ + protected function _has_operator($str) + { + return (bool) preg_match('/(<|>|!|=|\sIS NULL|\sIS NOT NULL|\sEXISTS|\sBETWEEN|\sLIKE|\sIN\s*\(|\s)/i', trim($str)); + } + + // -------------------------------------------------------------------- + + /** + * Returns the SQL string operator + * + * @param string + * @return string + */ + protected function _get_operator($str) + { + static $_operators; + + if (empty($_operators)) + { + $_les = ($this->_like_escape_str !== '') + ? '\s+'.preg_quote(trim(sprintf($this->_like_escape_str, $this->_like_escape_chr)), '/') + : ''; + $_operators = array( + '\s*(?:<|>|!)?=\s*', // =, <=, >=, != + '\s*<>?\s*', // <, <> + '\s*>\s*', // > + '\s+IS NULL', // IS NULL + '\s+IS NOT NULL', // IS NOT NULL + '\s+EXISTS\s*\([^\)]+\)', // EXISTS(sql) + '\s+NOT EXISTS\s*\([^\)]+\)', // NOT EXISTS(sql) + '\s+BETWEEN\s+\S+\s+AND\s+\S+', // BETWEEN value AND value + '\s+IN\s*\([^\)]+\)', // IN(list) + '\s+NOT IN\s*\([^\)]+\)', // NOT IN (list) + '\s+LIKE\s+\S+'.$_les, // LIKE 'expr'[ ESCAPE '%s'] + '\s+NOT LIKE\s+\S+'.$_les // NOT LIKE 'expr'[ ESCAPE '%s'] + ); + + } + + return preg_match('/'.implode('|', $_operators).'/i', $str, $match) + ? $match[0] : FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Enables a native PHP function to be run, using a platform agnostic wrapper. + * + * @param string $function Function name + * @return mixed + */ + public function call_function($function) + { + $driver = ($this->dbdriver === 'postgre') ? 'pg_' : $this->dbdriver.'_'; + + if (FALSE === strpos($driver, $function)) + { + $function = $driver.$function; + } + + if ( ! function_exists($function)) + { + return ($this->db_debug) ? $this->display_error('db_unsupported_function') : FALSE; + } + + return (func_num_args() > 1) + ? call_user_func_array($function, array_slice(func_get_args(), 1)) + : call_user_func($function); + } + + // -------------------------------------------------------------------- + + /** + * Set Cache Directory Path + * + * @param string the path to the cache directory + * @return void + */ + public function cache_set_path($path = '') + { + $this->cachedir = $path; + } + + // -------------------------------------------------------------------- + + /** + * Enable Query Caching + * + * @return bool cache_on value + */ + public function cache_on() + { + return $this->cache_on = TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Disable Query Caching + * + * @return bool cache_on value + */ + public function cache_off() + { + return $this->cache_on = FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Delete the cache files associated with a particular URI + * + * @param string $segment_one = '' + * @param string $segment_two = '' + * @return bool + */ + public function cache_delete($segment_one = '', $segment_two = '') + { + return $this->_cache_init() + ? $this->CACHE->delete($segment_one, $segment_two) + : FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Delete All cache files + * + * @return bool + */ + public function cache_delete_all() + { + return $this->_cache_init() + ? $this->CACHE->delete_all() + : FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Initialize the Cache Class + * + * @return bool + */ + protected function _cache_init() + { + if ( ! class_exists('CI_DB_Cache', FALSE)) + { + require_once(BASEPATH.'database/DB_cache.php'); + } + elseif (is_object($this->CACHE)) + { + return TRUE; + } + + $this->CACHE = new CI_DB_Cache($this); // pass db object to support multiple db connections and returned db objects + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Close DB Connection + * + * @return void + */ + public function close() + { + if ($this->conn_id) + { + $this->_close(); + $this->conn_id = FALSE; + } + } + + // -------------------------------------------------------------------- + + /** + * Close DB Connection + * + * This method would be overriden by most of the drivers. + * + * @return void + */ + protected function _close() + { + $this->conn_id = FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Display an error message + * + * @param string the error message + * @param string any "swap" values + * @param bool whether to localize the message + * @return string sends the application/views/errors/error_db.php template + */ + public function display_error($error = '', $swap = '', $native = FALSE) + { + $LANG =& load_class('Lang', 'core'); + $LANG->load('db'); + + $heading = $LANG->line('db_error_heading'); + + if ($native === TRUE) + { + $message = (array) $error; + } + else + { + $message = is_array($error) ? $error : array(str_replace('%s', $swap, $LANG->line($error))); + } + + // 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'], $call['class'])) + { + // We'll need this on Windows, as APPPATH and BASEPATH will always use forward slashes + if (DIRECTORY_SEPARATOR !== '/') + { + $call['file'] = str_replace('\\', '/', $call['file']); + } + + if (strpos($call['file'], BASEPATH.'database') === FALSE && strpos($call['class'], 'Loader') === FALSE) + { + // Found it - use a relative path for safety + $message[] = 'Filename: '.str_replace(array(APPPATH, BASEPATH), '', $call['file']); + $message[] = 'Line Number: '.$call['line']; + break; + } + } + } + + $error =& load_class('Exceptions', 'core'); + echo $error->show_error($heading, $message, 'error_db'); + exit(8); // EXIT_DATABASE + } + + // -------------------------------------------------------------------- + + /** + * Protect Identifiers + * + * This function is used extensively by the Query Builder class, and by + * 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: + * + * SELECT * FROM hostname.database.table.column AS c FROM hostname.database.table + * + * Or a query with aliasing: + * + * SELECT m.member_id, m.member_name FROM members AS m + * + * Since the column name can include up to four segments (host, DB, table, column) + * or also have an alias prefix, we need to do a bit of work to figure this out and + * insert the table prefix (if it exists) in the proper position, and escape only + * the correct identifiers. + * + * @param string + * @param bool + * @param mixed + * @param bool + * @return string + */ + public function protect_identifiers($item, $prefix_single = FALSE, $protect_identifiers = NULL, $field_exists = TRUE) + { + if ( ! is_bool($protect_identifiers)) + { + $protect_identifiers = $this->_protect_identifiers; + } + + if (is_array($item)) + { + $escaped_array = array(); + foreach ($item as $k => $v) + { + $escaped_array[$this->protect_identifiers($k)] = $this->protect_identifiers($v, $prefix_single, $protect_identifiers, $field_exists); + } + + return $escaped_array; + } + + // 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 + // 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 + // + // Added exception for single quotes as well, we don't want to alter + // literal strings. -- Narf + if (strpos($item, '(') !== FALSE OR strpos($item, "'") !== FALSE) + { + return $item; + } + + // Convert tabs or multiple spaces into single spaces + $item = preg_replace('/\s+/', ' ', $item); + + // If the item has an alias declaration we remove it and set it aside. + // Note: strripos() is used in order to support spaces in table names + if ($offset = strripos($item, ' AS ')) + { + $alias = ($protect_identifiers) + ? substr($item, $offset, 4).$this->escape_identifiers(substr($item, $offset + 4)) + : substr($item, $offset); + $item = substr($item, 0, $offset); + } + elseif ($offset = strrpos($item, ' ')) + { + $alias = ($protect_identifiers) + ? ' '.$this->escape_identifiers(substr($item, $offset + 1)) + : substr($item, $offset); + $item = substr($item, 0, $offset); + } + else + { + $alias = ''; + } + + // Break the string apart if it contains periods, then insert the table prefix + // in the correct location, assuming the period doesn't indicate that we're dealing + // with an alias. While we're at it, we will escape the components + 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 + if (in_array($parts[0], $this->qb_aliased_tables)) + { + if ($protect_identifiers === TRUE) + { + foreach ($parts as $key => $val) + { + if ( ! in_array($val, $this->_reserved_identifiers)) + { + $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 !== '') + { + // We now add the table prefix based on some logic. + // Do we have 4 segments (hostname.database.table.column)? + // If so, we add the table prefix to the column name in the 3rd segment. + if (isset($parts[3])) + { + $i = 2; + } + // Do we have 3 segments (database.table.column)? + // If so, we add the table prefix to the column name in 2nd position + elseif (isset($parts[2])) + { + $i = 1; + } + // Do we have 2 segments (table.column)? + // If so, we add the table prefix to the column name in 1st segment + else + { + $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) + { + $i++; + } + + // Verify table prefix and replace if necessary + if ($this->swap_pre !== '' && strpos($parts[$i], $this->swap_pre) === 0) + { + $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 + elseif (strpos($parts[$i], $this->dbprefix) !== 0) + { + $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; + } + + // Is there a table prefix? If not, no need to insert it + if ($this->dbprefix !== '') + { + // Verify table prefix and replace if necessary + if ($this->swap_pre !== '' && strpos($item, $this->swap_pre) === 0) + { + $item = preg_replace('/^'.$this->swap_pre.'(\S+?)/', $this->dbprefix.'\\1', $item); + } + // Do we prefix an item with no segments? + elseif ($prefix_single === TRUE && strpos($item, $this->dbprefix) !== 0) + { + $item = $this->dbprefix.$item; + } + } + + if ($protect_identifiers === TRUE && ! in_array($item, $this->_reserved_identifiers)) + { + $item = $this->escape_identifiers($item); + } + + return $item.$alias; + } + + // -------------------------------------------------------------------- + + /** + * Dummy method that allows Query Builder class to be disabled + * and keep count_all() working. + * + * @return void + */ + protected function _reset_select() + { + } + +} + +/* End of file DB_driver.php */ +/* Location: ./system/database/DB_driver.php */ \ No newline at end of file diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php new file mode 100755 index 0000000..111546e --- /dev/null +++ b/system/database/DB_forge.php @@ -0,0 +1,1063 @@ +db =& $db; + log_message('debug', 'Database Forge Class Initialized'); + } + + // -------------------------------------------------------------------- + + /** + * Create database + * + * @param string $db_name + * @return bool + */ + public function create_database($db_name) + { + if ($this->_create_database === FALSE) + { + return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE; + } + elseif ( ! $this->db->query(sprintf($this->_create_database, $db_name, $this->db->char_set, $this->db->dbcollat))) + { + return ($this->db->db_debug) ? $this->db->display_error('db_unable_to_drop') : FALSE; + } + + if ( ! empty($this->db->data_cache['db_names'])) + { + $this->db->data_cache['db_names'][] = $db_name; + } + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Drop database + * + * @param string $db_name + * @return bool + */ + public function drop_database($db_name) + { + if ($db_name === '') + { + show_error('A table name is required for that operation.'); + return FALSE; + } + elseif ($this->_drop_database === FALSE) + { + return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE; + } + elseif ( ! $this->db->query(sprintf($this->_drop_database, $db_name))) + { + return ($this->db->db_debug) ? $this->db->display_error('db_unable_to_drop') : FALSE; + } + + if ( ! empty($this->db->data_cache['db_names'])) + { + $key = array_search(strtolower($db_name), array_map('strtolower', $this->db->data_cache['db_names']), TRUE); + if ($key !== FALSE) + { + unset($this->db->data_cache['db_names'][$key]); + } + } + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Add Key + * + * @param string $key + * @param bool $primary + * @return CI_DB_forge + */ + public function add_key($key = '', $primary = FALSE) + { + if (empty($key)) + { + show_error('Key information is required for that operation.'); + } + + if ($primary === TRUE && is_array($key)) + { + foreach ($key as $one) + { + $this->add_key($one, $primary); + } + + return $this; + } + + if ($primary === TRUE) + { + $this->primary_keys[] = $key; + } + else + { + $this->keys[] = $key; + } + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * Add Field + * + * @param array $field + * @return CI_DB_forge + */ + public function add_field($field = '') + { + if (empty($field)) + { + show_error('Field information is required.'); + } + + if (is_string($field)) + { + if ($field === 'id') + { + $this->add_field(array( + 'id' => array( + 'type' => 'INT', + 'constraint' => 9, + 'auto_increment' => TRUE + ) + )); + $this->add_key('id', TRUE); + } + else + { + if (strpos($field, ' ') === FALSE) + { + show_error('Field information is required for that operation.'); + } + + $this->fields[] = $field; + } + } + + if (is_array($field)) + { + $this->fields = array_merge($this->fields, $field); + } + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * Create Table + * + * @param string $table Table name + * @param bool $if_not_exists Whether to add IF NOT EXISTS condition + * @param array $attributes Associative array of table attributes + * @return bool + */ + public function create_table($table = '', $if_not_exists = FALSE, array $attributes = array()) + { + if ($table === '') + { + show_error('A table name is required for that operation.'); + } + else + { + $table = $this->db->dbprefix.$table; + } + + if (count($this->fields) === 0) + { + show_error('Field information is required.'); + } + + $sql = $this->_create_table($table, $if_not_exists, $attributes); + + if (is_bool($sql)) + { + $this->_reset(); + if ($sql === FALSE) + { + return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE; + } + } + + if (($result = $this->db->query($sql)) !== FALSE) + { + empty($this->db->data_cache['table_names']) OR $this->db->data_cache['table_names'][] = $table; + + // Most databases don't support creating indexes from within the CREATE TABLE statement + if ( ! empty($this->keys)) + { + for ($i = 0, $sqls = $this->_process_indexes($table), $c = count($sqls); $i < $c; $i++) + { + $this->db->query($sqls[$i]); + } + } + } + + $this->_reset(); + return $result; + } + + // -------------------------------------------------------------------- + + /** + * Create Table + * + * @param string $table Table name + * @param bool $if_not_exists Whether to add 'IF NOT EXISTS' condition + * @param array $attributes Associative array of table attributes + * @return mixed + */ + protected function _create_table($table, $if_not_exists, $attributes) + { + if ($if_not_exists === TRUE && $this->_create_table_if === FALSE) + { + if ($this->db->table_exists($table)) + { + return TRUE; + } + else + { + $if_not_exists = FALSE; + } + } + + $sql = ($if_not_exists) + ? sprintf($this->_create_table_if, $this->db->escape_identifiers($table)) + : 'CREATE TABLE'; + + $columns = $this->_process_fields(TRUE); + for ($i = 0, $c = count($columns); $i < $c; $i++) + { + $columns[$i] = ($columns[$i]['_literal'] !== FALSE) + ? "\n\t".$columns[$i]['_literal'] + : "\n\t".$this->_process_column($columns[$i]); + } + + $columns = implode(',', $columns) + .$this->_process_primary_keys($table); + + // Are indexes created from within the CREATE TABLE statement? (e.g. in MySQL) + if ($this->_create_table_keys === TRUE) + { + $columns .= $this->_process_indexes($table); + } + + // _create_table will usually have the following format: "%s %s (%s\n)" + $sql = sprintf($this->_create_table.'%s', + $sql, + $this->db->escape_identifiers($table), + $columns, + $this->_create_table_attr($attributes) + ); + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * CREATE TABLE attributes + * + * @param array $attributes Associative array of table attributes + * @return string + */ + protected function _create_table_attr($attributes) + { + $sql = ''; + + foreach (array_keys($attributes) as $key) + { + if (is_string($key)) + { + $sql .= ' '.strtoupper($key).' '.$attributes[$key]; + } + } + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Drop Table + * + * @param string $table_name Table name + * @param bool $if_exists Whether to add an IF EXISTS condition + * @return bool + */ + public function drop_table($table_name, $if_exists = FALSE) + { + if ($table_name === '') + { + return ($this->db->db_debug) ? $this->db->display_error('db_table_name_required') : FALSE; + } + + $query = $this->_drop_table($this->db->dbprefix.$table_name, $if_exists); + if ($query === FALSE) + { + return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE; + } + elseif ($query === TRUE) + { + return TRUE; + } + + $query = $this->db->query($query); + + // Update table list cache + if ($query && ! empty($this->db->data_cache['table_names'])) + { + $key = array_search(strtolower($this->db->dbprefix.$table_name), array_map('strtolower', $this->db->data_cache['table_names']), TRUE); + if ($key !== FALSE) + { + unset($this->db->data_cache['table_names'][$key]); + } + } + + return $query; + } + + // -------------------------------------------------------------------- + + /** + * Drop Table + * + * Generates a platform-specific DROP TABLE string + * + * @param string $table Table name + * @param bool $if_exists Whether to add an IF EXISTS condition + * @return string + */ + protected function _drop_table($table, $if_exists) + { + $sql = 'DROP TABLE'; + + if ($if_exists) + { + if ($this->_drop_table_if === FALSE) + { + if ( ! $this->db->table_exists($table)) + { + return TRUE; + } + } + else + { + $sql = sprintf($this->_drop_table_if, $this->db->escape_identifiers($table)); + } + } + + return $sql.' '.$this->db->escape_identifiers($table); + } + + // -------------------------------------------------------------------- + + /** + * Rename Table + * + * @param string $table_name Old table name + * @param string $new_table_name New table name + * @return bool + */ + public function rename_table($table_name, $new_table_name) + { + if ($table_name === '' OR $new_table_name === '') + { + show_error('A table name is required for that operation.'); + return FALSE; + } + elseif ($this->_rename_table === FALSE) + { + return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE; + } + + $result = $this->db->query(sprintf($this->_rename_table, + $this->db->escape_identifiers($this->db->dbprefix.$table_name), + $this->db->escape_identifiers($this->db->dbprefix.$new_table_name)) + ); + + if ($result && ! empty($this->db->data_cache['table_names'])) + { + $key = array_search(strtolower($this->db->dbprefix.$table_name), array_map('strtolower', $this->db->data_cache['table_names']), TRUE); + if ($key !== FALSE) + { + $this->db->data_cache['table_names'][$key] = $this->db->dbprefix.$new_table_name; + } + } + + return $result; + } + + // -------------------------------------------------------------------- + + /** + * Column Add + * + * @todo Remove deprecated $_after option in 3.1+ + * @param string $table Table name + * @param array $field Column definition + * @param string $_after Column for AFTER clause (deprecated) + * @return bool + */ + public function add_column($table = '', $field = array(), $_after = NULL) + { + if ($table === '') + { + show_error('A table name is required for that operation.'); + } + + // Work-around for literal column definitions + if ( ! is_array($field)) + { + $field = array($field); + } + + foreach (array_keys($field) as $k) + { + // Backwards-compatibility work-around for MySQL/CUBRID AFTER clause (remove in 3.1+) + if ($_after !== NULL && is_array($field[$k]) && ! isset($field[$k]['after'])) + { + $field[$k]['after'] = $_after; + } + + $this->add_field(array($k => $field[$k])); + } + + $sqls = $this->_alter_table('ADD', $this->db->dbprefix.$table, $this->_process_fields()); + $this->_reset(); + if ($sqls === FALSE) + { + return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE; + } + + for ($i = 0, $c = count($sqls); $i < $c; $i++) + { + if ($this->db->query($sqls[$i]) === FALSE) + { + return FALSE; + } + } + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Column Drop + * + * @param string $table Table name + * @param string $column_name Column name + * @return bool + */ + public function drop_column($table = '', $column_name = '') + { + if ($table === '') + { + show_error('A table name is required for that operation.'); + } + + if ($column_name === '') + { + show_error('A column name is required for that operation.'); + } + + $sql = $this->_alter_table('DROP', $this->db->dbprefix.$table, $column_name); + if ($sql === FALSE) + { + return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE; + } + + return $this->db->query($sql); + } + + // -------------------------------------------------------------------- + + /** + * Column Modify + * + * @param string $table Table name + * @param string $field Column definition + * @return bool + */ + public function modify_column($table = '', $field = array()) + { + if ($table === '') + { + show_error('A table name is required for that operation.'); + } + + // Work-around for literal column definitions + if ( ! is_array($field)) + { + $field = array($field); + } + + foreach (array_keys($field) as $k) + { + $this->add_field(array($k => $field[$k])); + } + + if (count($this->fields) === 0) + { + show_error('Field information is required.'); + } + + $sqls = $this->_alter_table('CHANGE', $this->db->dbprefix.$table, $this->_process_fields()); + $this->_reset(); + if ($sqls === FALSE) + { + return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE; + } + + for ($i = 0, $c = count($sqls); $i < $c; $i++) + { + if ($this->db->query($sqls[$i]) === FALSE) + { + return FALSE; + } + } + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * ALTER TABLE + * + * @param string $alter_type ALTER type + * @param string $table Table name + * @param mixed $field Column definition + * @return string|string[] + */ + protected function _alter_table($alter_type, $table, $field) + { + $sql = 'ALTER TABLE '.$this->db->escape_identifiers($table).' '; + + // DROP has everything it needs now. + if ($alter_type === 'DROP') + { + return $sql.'DROP COLUMN '.$this->db->escape_identifiers($field); + } + + $sql .= ($alter_type === 'ADD') + ? 'ADD ' + : $alter_type.' COLUMN '; + + $sqls = array(); + for ($i = 0, $c = count($field); $i < $c; $i++) + { + $sqls[] = $sql + .($field[$i]['_literal'] !== FALSE ? $field[$i]['_literal'] : $this->_process_column($field[$i])); + } + + return $sqls; + } + + // -------------------------------------------------------------------- + + /** + * Process fields + * + * @param bool $create_table + * @return array + */ + protected function _process_fields($create_table = FALSE) + { + $fields = array(); + + foreach ($this->fields as $key => $attributes) + { + if (is_int($key) && ! is_array($attributes)) + { + $fields[] = array('_literal' => $attributes); + continue; + } + + $attributes = array_change_key_case($attributes, CASE_UPPER); + + if ($create_table === TRUE && empty($attributes['TYPE'])) + { + continue; + } + + isset($attributes['TYPE']) && $this->_attr_type($attributes); + + $field = array( + 'name' => $key, + 'new_name' => isset($attributes['NAME']) ? $attributes['NAME'] : NULL, + 'type' => isset($attributes['TYPE']) ? $attributes['TYPE'] : NULL, + 'length' => '', + 'unsigned' => '', + 'null' => '', + 'unique' => '', + 'default' => '', + 'auto_increment' => '', + '_literal' => FALSE + ); + + isset($attributes['TYPE']) && $this->_attr_unsigned($attributes, $field); + + if ($create_table === FALSE) + { + if (isset($attributes['AFTER'])) + { + $field['after'] = $attributes['AFTER']; + } + elseif (isset($attributes['FIRST'])) + { + $field['first'] = (bool) $attributes['FIRST']; + } + } + + $this->_attr_default($attributes, $field); + + if (isset($attributes['NULL'])) + { + if ($attributes['NULL'] === TRUE) + { + $field['null'] = empty($this->_null) ? '' : ' '.$this->_null; + } + else + { + $field['null'] = ' NOT NULL'; + } + } + elseif ($create_table === TRUE) + { + $field['null'] = ' NOT NULL'; + } + + $this->_attr_auto_increment($attributes, $field); + $this->_attr_unique($attributes, $field); + + if (isset($attributes['TYPE']) && ! empty($attributes['CONSTRAINT'])) + { + switch (strtoupper($attributes['TYPE'])) + { + case 'ENUM': + case 'SET': + $attributes['CONSTRAINT'] = $this->db->escape($attributes['CONSTRAINT']); + $field['length'] = is_array($attributes['CONSTRAINT']) + ? "('".implode("','", $attributes['CONSTRAINT'])."')" + : '('.$attributes['CONSTRAINT'].')'; + break; + default: + $field['length'] = is_array($attributes['CONSTRAINT']) + ? '('.implode(',', $attributes['CONSTRAINT']).')' + : '('.$attributes['CONSTRAINT'].')'; + break; + } + } + + $fields[] = $field; + } + + return $fields; + } + + // -------------------------------------------------------------------- + + /** + * Process column + * + * @param array $field + * @return string + */ + protected function _process_column($field) + { + return $this->db->escape_identifiers($field['name']) + .' '.$field['type'].$field['length'] + .$field['unsigned'] + .$field['default'] + .$field['null'] + .$field['auto_increment'] + .$field['unique']; + } + + // -------------------------------------------------------------------- + + /** + * Field attribute TYPE + * + * Performs a data type mapping between different databases. + * + * @param array &$attributes + * @return void + */ + protected function _attr_type(&$attributes) + { + // Usually overriden by drivers + } + + // -------------------------------------------------------------------- + + /** + * Field attribute UNSIGNED + * + * Depending on the _unsigned property value: + * + * - TRUE will always set $field['unsigned'] to 'UNSIGNED' + * - FALSE will always set $field['unsigned'] to '' + * - array(TYPE) will set $field['unsigned'] to 'UNSIGNED', + * if $attributes['TYPE'] is found in the array + * - array(TYPE => UTYPE) will change $field['type'], + * from TYPE to UTYPE in case of a match + * + * @param array &$attributes + * @param array &$field + * @return void + */ + protected function _attr_unsigned(&$attributes, &$field) + { + if (empty($attributes['UNSIGNED']) OR $attributes['UNSIGNED'] !== TRUE) + { + return; + } + + // Reset the attribute in order to avoid issues if we do type conversion + $attributes['UNSIGNED'] = FALSE; + + if (is_array($this->_unsigned)) + { + foreach (array_keys($this->_unsigned) as $key) + { + if (is_int($key) && strcasecmp($attributes['TYPE'], $this->_unsigned[$key]) === 0) + { + $field['unsigned'] = ' UNSIGNED'; + return; + } + elseif (is_string($key) && strcasecmp($attributes['TYPE'], $key) === 0) + { + $field['type'] = $key; + return; + } + } + + return; + } + + $field['unsigned'] = ($this->_unsigned === TRUE) ? ' UNSIGNED' : ''; + } + + // -------------------------------------------------------------------- + + /** + * Field attribute DEFAULT + * + * @param array &$attributes + * @param array &$field + * @return void + */ + protected function _attr_default(&$attributes, &$field) + { + if ($this->_default === FALSE) + { + return; + } + + if (array_key_exists('DEFAULT', $attributes)) + { + if ($attributes['DEFAULT'] === NULL) + { + $field['default'] = empty($this->_null) ? '' : $this->_default.$this->_null; + + // Override the NULL attribute if that's our default + $attributes['NULL'] = NULL; + $field['null'] = empty($this->_null) ? '' : ' '.$this->_null; + } + else + { + $field['default'] = $this->_default.$this->db->escape($attributes['DEFAULT']); + } + } + } + + // -------------------------------------------------------------------- + + /** + * Field attribute UNIQUE + * + * @param array &$attributes + * @param array &$field + * @return void + */ + protected function _attr_unique(&$attributes, &$field) + { + if ( ! empty($attributes['UNIQUE']) && $attributes['UNIQUE'] === TRUE) + { + $field['unique'] = ' UNIQUE'; + } + } + + // -------------------------------------------------------------------- + + /** + * Field attribute AUTO_INCREMENT + * + * @param array &$attributes + * @param array &$field + * @return void + */ + protected function _attr_auto_increment(&$attributes, &$field) + { + if ( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE && stripos($field['type'], 'int') !== FALSE) + { + $field['auto_increment'] = ' AUTO_INCREMENT'; + } + } + + // -------------------------------------------------------------------- + + /** + * Process primary keys + * + * @param string $table Table name + * @return string + */ + protected function _process_primary_keys($table) + { + $sql = ''; + + for ($i = 0, $c = count($this->primary_keys); $i < $c; $i++) + { + if ( ! isset($this->fields[$this->primary_keys[$i]])) + { + unset($this->primary_keys[$i]); + } + } + + if (count($this->primary_keys) > 0) + { + $sql .= ",\n\tCONSTRAINT ".$this->db->escape_identifiers('pk_'.$table) + .' PRIMARY KEY('.implode(', ', $this->db->escape_identifiers($this->primary_keys)).')'; + } + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Process indexes + * + * @param string $table + * @return string + */ + protected function _process_indexes($table) + { + $sqls = array(); + + for ($i = 0, $c = count($this->keys); $i < $c; $i++) + { + if (is_array($this->keys[$i])) + { + for ($i2 = 0, $c2 = count($this->keys[$i]); $i2 < $c2; $i2++) + { + if ( ! isset($this->fields[$this->keys[$i][$i2]])) + { + unset($this->keys[$i][$i2]); + continue; + } + } + } + elseif ( ! isset($this->fields[$this->keys[$i]])) + { + unset($this->keys[$i]); + continue; + } + + is_array($this->keys[$i]) OR $this->keys[$i] = array($this->keys[$i]); + + $sqls[] = 'CREATE INDEX '.$this->db->escape_identifiers($table.'_'.implode('_', $this->keys[$i])) + .' ON '.$this->db->escape_identifiers($table) + .' ('.implode(', ', $this->db->escape_identifiers($this->keys[$i])).');'; + } + + return $sqls; + } + + // -------------------------------------------------------------------- + + /** + * Reset + * + * Resets table creation vars + * + * @return void + */ + protected function _reset() + { + $this->fields = $this->keys = $this->primary_keys = array(); + } + +} + +/* End of file DB_forge.php */ +/* Location: ./system/database/DB_forge.php */ \ No newline at end of file diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php new file mode 100755 index 0000000..085c615 --- /dev/null +++ b/system/database/DB_query_builder.php @@ -0,0 +1,2710 @@ +_protect_identifiers; + + foreach ($select as $val) + { + $val = trim($val); + + if ($val !== '') + { + $this->qb_select[] = $val; + $this->qb_no_escape[] = $escape; + + if ($this->qb_caching === TRUE) + { + $this->qb_cache_select[] = $val; + $this->qb_cache_exists[] = 'select'; + $this->qb_cache_no_escape[] = $escape; + } + } + } + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * Select Max + * + * Generates a SELECT MAX(field) portion of a query + * + * @param string the field + * @param string an alias + * @return CI_DB_query_builder + */ + public function select_max($select = '', $alias = '') + { + return $this->_max_min_avg_sum($select, $alias, 'MAX'); + } + + // -------------------------------------------------------------------- + + /** + * Select Min + * + * Generates a SELECT MIN(field) portion of a query + * + * @param string the field + * @param string an alias + * @return CI_DB_query_builder + */ + public function select_min($select = '', $alias = '') + { + return $this->_max_min_avg_sum($select, $alias, 'MIN'); + } + + // -------------------------------------------------------------------- + + /** + * Select Average + * + * Generates a SELECT AVG(field) portion of a query + * + * @param string the field + * @param string an alias + * @return CI_DB_query_builder + */ + public function select_avg($select = '', $alias = '') + { + return $this->_max_min_avg_sum($select, $alias, 'AVG'); + } + + // -------------------------------------------------------------------- + + /** + * Select Sum + * + * Generates a SELECT SUM(field) portion of a query + * + * @param string the field + * @param string an alias + * @return CI_DB_query_builder + */ + public function select_sum($select = '', $alias = '') + { + return $this->_max_min_avg_sum($select, $alias, 'SUM'); + } + + // -------------------------------------------------------------------- + + /** + * SELECT [MAX|MIN|AVG|SUM]() + * + * @used-by select_max() + * @used-by select_min() + * @used-by select_avg() + * @used-by select_sum() + * + * @param string $select Field name + * @param string $alias + * @param string $type + * @return CI_DB_query_builder + */ + protected function _max_min_avg_sum($select = '', $alias = '', $type = 'MAX') + { + if ( ! is_string($select) OR $select === '') + { + $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 '.$this->escape_identifiers(trim($alias)); + + $this->qb_select[] = $sql; + $this->qb_no_escape[] = NULL; + + if ($this->qb_caching === TRUE) + { + $this->qb_cache_select[] = $sql; + $this->qb_cache_exists[] = 'select'; + } + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * Determines the alias name based on the table + * + * @param string $item + * @return string + */ + protected function _create_alias_from_table($item) + { + if (strpos($item, '.') !== FALSE) + { + $item = explode('.', $item); + return end($item); + } + + return $item; + } + + // -------------------------------------------------------------------- + + /** + * DISTINCT + * + * Sets a flag which tells the query string compiler to add DISTINCT + * + * @param bool $val + * @return CI_DB_query_builder + */ + public function distinct($val = TRUE) + { + $this->qb_distinct = is_bool($val) ? $val : TRUE; + return $this; + } + + // -------------------------------------------------------------------- + + /** + * From + * + * Generates the FROM portion of the query + * + * @param mixed $from can be a string or array + * @return CI_DB_query_builder + */ + public function from($from) + { + foreach ((array) $from as $val) + { + if (strpos($val, ',') !== FALSE) + { + foreach (explode(',', $val) as $v) + { + $v = trim($v); + $this->_track_aliases($v); + + $this->qb_from[] = $v = $this->protect_identifiers($v, TRUE, NULL, FALSE); + + if ($this->qb_caching === TRUE) + { + $this->qb_cache_from[] = $v; + $this->qb_cache_exists[] = 'from'; + } + } + } + else + { + $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 + $this->_track_aliases($val); + + $this->qb_from[] = $val = $this->protect_identifiers($val, TRUE, NULL, FALSE); + + if ($this->qb_caching === TRUE) + { + $this->qb_cache_from[] = $val; + $this->qb_cache_exists[] = 'from'; + } + } + } + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * JOIN + * + * Generates the JOIN portion of the query + * + * @param string + * @param string the join condition + * @param string the type of join + * @param string whether not to try to escape identifiers + * @return CI_DB_query_builder + */ + public function join($table, $cond, $type = '', $escape = NULL) + { + if ($type !== '') + { + $type = strtoupper(trim($type)); + + if ( ! in_array($type, array('LEFT', 'RIGHT', 'OUTER', 'INNER', 'LEFT OUTER', 'RIGHT OUTER'), TRUE)) + { + $type = ''; + } + else + { + $type .= ' '; + } + } + + // Extract any aliases that might exist. We use this information + // in the protect_identifiers to know whether to add a table prefix + $this->_track_aliases($table); + + is_bool($escape) OR $escape = $this->_protect_identifiers; + + // Split multiple conditions + if ($escape === TRUE && preg_match_all('/\sAND\s|\sOR\s/i', $cond, $m, PREG_OFFSET_CAPTURE)) + { + $newcond = ''; + $m[0][] = array('', strlen($cond)); + + for ($i = 0, $c = count($m[0]), $s = 0; + $i < $c; + $s = $m[0][$i][1] + strlen($m[0][$i][0]), $i++) + { + $temp = substr($cond, $s, ($m[0][$i][1] - $s)); + + $newcond .= preg_match("/([\[\]\w\.'-]+)(\s*[^\"\[`'\w]+\s*)(.+)/i", $temp, $match) + ? $this->protect_identifiers($match[1]).$match[2].$this->protect_identifiers($match[3]) + : $temp; + + $newcond .= $m[0][$i][0]; + } + + $cond = ' ON '.$newcond; + } + // Split apart the condition and protect the identifiers + elseif ($escape === TRUE && preg_match("/([\[\]\w\.'-]+)(\s*[^\"\[`'\w]+\s*)(.+)/i", $cond, $match)) + { + $cond = ' ON '.$this->protect_identifiers($match[1]).$match[2].$this->protect_identifiers($match[3]); + } + elseif ( ! $this->_has_operator($cond)) + { + $cond = ' USING ('.($escape ? $this->escape_identifiers($cond) : $cond).')'; + } + else + { + $cond = ' ON '.$cond; + } + + // Do we want to escape the table name? + if ($escape === TRUE) + { + $table = $this->protect_identifiers($table, TRUE, NULL, FALSE); + } + + // Assemble the JOIN statement + $this->qb_join[] = $join = $type.'JOIN '.$table.$cond; + + if ($this->qb_caching === TRUE) + { + $this->qb_cache_join[] = $join; + $this->qb_cache_exists[] = 'join'; + } + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * WHERE + * + * Generates the WHERE portion of the query. + * Separates multiple calls with 'AND'. + * + * @param mixed + * @param mixed + * @param bool + * @return CI_DB_query_builder + */ + public function where($key, $value = NULL, $escape = NULL) + { + return $this->_wh('qb_where', $key, $value, 'AND ', $escape); + } + + // -------------------------------------------------------------------- + + /** + * OR WHERE + * + * Generates the WHERE portion of the query. + * Separates multiple calls with 'OR'. + * + * @param mixed + * @param mixed + * @param bool + * @return CI_DB_query_builder + */ + public function or_where($key, $value = NULL, $escape = NULL) + { + return $this->_wh('qb_where', $key, $value, 'OR ', $escape); + } + + // -------------------------------------------------------------------- + + /** + * WHERE, HAVING + * + * @used-by where() + * @used-by or_where() + * @used-by having() + * @used-by or_having() + * + * @param string $qb_key 'qb_where' or 'qb_having' + * @param mixed $key + * @param mixed $value + * @param string $type + * @param bool $escape + * @return CI_DB_query_builder + */ + protected function _wh($qb_key, $key, $value = NULL, $type = 'AND ', $escape = NULL) + { + $qb_cache_key = ($qb_key === 'qb_having') ? 'qb_cache_having' : 'qb_cache_where'; + + if ( ! is_array($key)) + { + $key = array($key => $value); + } + + // If the escape value was not set will will base it on the global setting + is_bool($escape) OR $escape = $this->_protect_identifiers; + + foreach ($key as $k => $v) + { + $prefix = (count($this->$qb_key) === 0 && count($this->$qb_cache_key) === 0) + ? $this->_group_get_type('') + : $this->_group_get_type($type); + + if ($v !== NULL) + { + if ($escape === TRUE) + { + $v = ' '.$this->escape($v); + } + + if ( ! $this->_has_operator($k)) + { + $k .= ' = '; + } + } + elseif ( ! $this->_has_operator($k)) + { + // value appears not to have been set, assign the test to IS NULL + $k .= ' IS NULL'; + } + + $this->{$qb_key}[] = array('condition' => $prefix.$k.$v, 'escape' => $escape); + if ($this->qb_caching === TRUE) + { + $this->{$qb_cache_key}[] = array('condition' => $prefix.$k.$v, 'escape' => $escape); + $this->qb_cache_exists[] = substr($qb_key, 3); + } + + } + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * WHERE IN + * + * Generates a WHERE field IN('item', 'item') SQL query, + * joined with 'AND' if appropriate. + * + * @param string $key The field to search + * @param array $values The values searched on + * @param bool $escape + * @return CI_DB_query_builder + */ + public function where_in($key = NULL, $values = NULL, $escape = NULL) + { + return $this->_where_in($key, $values, FALSE, 'AND ', $escape); + } + + // -------------------------------------------------------------------- + + /** + * OR WHERE IN + * + * Generates a WHERE field IN('item', 'item') SQL query, + * joined with 'OR' if appropriate. + * + * @param string $key The field to search + * @param array $values The values searched on + * @param bool $escape + * @return CI_DB_query_builder + */ + public function or_where_in($key = NULL, $values = NULL, $escape = NULL) + { + return $this->_where_in($key, $values, FALSE, 'OR ', $escape); + } + + // -------------------------------------------------------------------- + + /** + * WHERE NOT IN + * + * Generates a WHERE field NOT IN('item', 'item') SQL query, + * joined with 'AND' if appropriate. + * + * @param string $key The field to search + * @param array $values The values searched on + * @param bool $escape + * @return CI_DB_query_builder + */ + public function where_not_in($key = NULL, $values = NULL, $escape = NULL) + { + return $this->_where_in($key, $values, TRUE, 'AND ', $escape); + } + + // -------------------------------------------------------------------- + + /** + * OR WHERE NOT IN + * + * Generates a WHERE field NOT IN('item', 'item') SQL query, + * joined with 'OR' if appropriate. + * + * @param string $key The field to search + * @param array $values The values searched on + * @param bool $escape + * @return CI_DB_query_builder + */ + public function or_where_not_in($key = NULL, $values = NULL, $escape = NULL) + { + return $this->_where_in($key, $values, TRUE, 'OR ', $escape); + } + + // -------------------------------------------------------------------- + + /** + * Internal WHERE IN + * + * @used-by where_in() + * @used-by or_where_in() + * @used-by where_not_in() + * @used-by or_where_not_in() + * + * @param string $key The field to search + * @param array $values The values searched on + * @param bool $not If the statement would be IN or NOT IN + * @param string $type + * @param bool $escape + * @return CI_DB_query_builder + */ + protected function _where_in($key = NULL, $values = NULL, $not = FALSE, $type = 'AND ', $escape = NULL) + { + if ($key === NULL OR $values === NULL) + { + return $this; + } + + if ( ! is_array($values)) + { + $values = array($values); + } + + is_bool($escape) OR $escape = $this->_protect_identifiers; + + $not = ($not) ? ' NOT' : ''; + + $where_in = array(); + foreach ($values as $value) + { + $where_in[] = $this->escape($value); + } + + $prefix = (count($this->qb_where) === 0) ? $this->_group_get_type('') : $this->_group_get_type($type); + $where_in = array( + 'condition' => $prefix.$key.$not.' IN('.implode(', ', $where_in).')', + 'escape' => $escape + ); + + $this->qb_where[] = $where_in; + if ($this->qb_caching === TRUE) + { + $this->qb_cache_where[] = $where_in; + $this->qb_cache_exists[] = 'where'; + } + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * LIKE + * + * Generates a %LIKE% portion of the query. + * Separates multiple calls with 'AND'. + * + * @param mixed $field + * @param string $match + * @param string $side + * @param bool $escape + * @return CI_DB_query_builder + */ + public function like($field, $match = '', $side = 'both', $escape = NULL) + { + return $this->_like($field, $match, 'AND ', $side, '', $escape); + } + + // -------------------------------------------------------------------- + + /** + * NOT LIKE + * + * Generates a NOT LIKE portion of the query. + * Separates multiple calls with 'AND'. + * + * @param mixed $field + * @param string $match + * @param string $side + * @param bool $escape + * @return CI_DB_query_builder + */ + public function not_like($field, $match = '', $side = 'both', $escape = NULL) + { + return $this->_like($field, $match, 'AND ', $side, 'NOT', $escape); + } + + // -------------------------------------------------------------------- + + /** + * OR LIKE + * + * Generates a %LIKE% portion of the query. + * Separates multiple calls with 'OR'. + * + * @param mixed $field + * @param string $match + * @param string $side + * @param bool $escape + * @return CI_DB_query_builder + */ + public function or_like($field, $match = '', $side = 'both', $escape = NULL) + { + return $this->_like($field, $match, 'OR ', $side, '', $escape); + } + + // -------------------------------------------------------------------- + + /** + * OR NOT LIKE + * + * Generates a NOT LIKE portion of the query. + * Separates multiple calls with 'OR'. + * + * @param mixed $field + * @param string $match + * @param string $side + * @param bool $escape + * @return CI_DB_query_builder + */ + public function or_not_like($field, $match = '', $side = 'both', $escape = NULL) + { + return $this->_like($field, $match, 'OR ', $side, 'NOT', $escape); + } + + // -------------------------------------------------------------------- + + /** + * Internal LIKE + * + * @used-by like() + * @used-by or_like() + * @used-by not_like() + * @used-by or_not_like() + * + * @param mixed $field + * @param string $match + * @param string $type + * @param string $side + * @param string $not + * @param bool $escape + * @return CI_DB_query_builder + */ + protected function _like($field, $match = '', $type = 'AND ', $side = 'both', $not = '', $escape = NULL) + { + if ( ! is_array($field)) + { + $field = array($field => $match); + } + + is_bool($escape) OR $escape = $this->_protect_identifiers; + + foreach ($field as $k => $v) + { + $prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0) + ? $this->_group_get_type('') : $this->_group_get_type($type); + + $v = $this->escape_like_str($v); + + if ($side === 'none') + { + $like_statement = "{$prefix} {$k} {$not} LIKE '{$v}'"; + } + elseif ($side === 'before') + { + $like_statement = "{$prefix} {$k} {$not} LIKE '%{$v}'"; + } + elseif ($side === 'after') + { + $like_statement = "{$prefix} {$k} {$not} LIKE '{$v}%'"; + } + else + { + $like_statement = "{$prefix} {$k} {$not} LIKE '%{$v}%'"; + } + + // some platforms require an escape sequence definition for LIKE wildcards + if ($this->_like_escape_str !== '') + { + $like_statement .= sprintf($this->_like_escape_str, $this->_like_escape_chr); + } + + $this->qb_where[] = array('condition' => $like_statement, 'escape' => $escape); + if ($this->qb_caching === TRUE) + { + $this->qb_cache_where[] = array('condition' => $like_statement, 'escape' => $escape); + $this->qb_cache_exists[] = 'where'; + } + } + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * Starts a query group. + * + * @param string $not (Internal use only) + * @param string $type (Internal use only) + * @return CI_DB_query_builder + */ + public function group_start($not = '', $type = 'AND ') + { + $type = $this->_group_get_type($type); + + $this->qb_where_group_started = TRUE; + $prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0) ? '' : $type; + $where = array( + 'condition' => $prefix.$not.str_repeat(' ', ++$this->qb_where_group_count).' (', + 'escape' => FALSE + ); + + $this->qb_where[] = $where; + if ($this->qb_caching) + { + $this->qb_cache_where[] = $where; + } + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * Starts a query group, but ORs the group + * + * @return CI_DB_query_builder + */ + public function or_group_start() + { + return $this->group_start('', 'OR '); + } + + // -------------------------------------------------------------------- + + /** + * Starts a query group, but NOTs the group + * + * @return CI_DB_query_builder + */ + public function not_group_start() + { + return $this->group_start('NOT ', 'AND '); + } + + // -------------------------------------------------------------------- + + /** + * Starts a query group, but OR NOTs the group + * + * @return CI_DB_query_builder + */ + public function or_not_group_start() + { + return $this->group_start('NOT ', 'OR '); + } + + // -------------------------------------------------------------------- + + /** + * Ends a query group + * + * @return CI_DB_query_builder + */ + public function group_end() + { + $this->qb_where_group_started = FALSE; + $where = array( + 'condition' => str_repeat(' ', $this->qb_where_group_count--).')', + 'escape' => FALSE + ); + + $this->qb_where[] = $where; + if ($this->qb_caching) + { + $this->qb_cache_where[] = $where; + } + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * Group_get_type + * + * @used-by group_start() + * @used-by _like() + * @used-by _wh() + * @used-by _where_in() + * + * @param string $type + * @return string + */ + protected function _group_get_type($type) + { + if ($this->qb_where_group_started) + { + $type = ''; + $this->qb_where_group_started = FALSE; + } + + return $type; + } + + // -------------------------------------------------------------------- + + /** + * GROUP BY + * + * @param string $by + * @param bool $escape + * @return CI_DB_query_builder + */ + public function group_by($by, $escape = NULL) + { + is_bool($escape) OR $escape = $this->_protect_identifiers; + + if (is_string($by)) + { + $by = ($escape === TRUE) + ? explode(',', $by) + : array($by); + } + + foreach ($by as $val) + { + $val = trim($val); + + if ($val !== '') + { + $val = array('field' => $val, 'escape' => $escape); + + $this->qb_groupby[] = $val; + if ($this->qb_caching === TRUE) + { + $this->qb_cache_groupby[] = $val; + $this->qb_cache_exists[] = 'groupby'; + } + } + } + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * HAVING + * + * Separates multiple calls with 'AND'. + * + * @param string $key + * @param string $value + * @param bool $escape + * @return object + */ + public function having($key, $value = NULL, $escape = NULL) + { + return $this->_wh('qb_having', $key, $value, 'AND ', $escape); + } + + // -------------------------------------------------------------------- + + /** + * OR HAVING + * + * Separates multiple calls with 'OR'. + * + * @param string $key + * @param string $value + * @param bool $escape + * @return object + */ + public function or_having($key, $value = NULL, $escape = NULL) + { + return $this->_wh('qb_having', $key, $value, 'OR ', $escape); + } + + // -------------------------------------------------------------------- + + /** + * ORDER BY + * + * @param string $orderby + * @param string $direction ASC, DESC or RANDOM + * @param bool $escape + * @return CI_DB_query_builder + */ + public function order_by($orderby, $direction = '', $escape = NULL) + { + $direction = strtoupper(trim($direction)); + + if ($direction === 'RANDOM') + { + $direction = ''; + + // Do we have a seed value? + $orderby = ctype_digit((string) $orderby) + ? sprintf($this->_random_keyword[1], $orderby) + : $this->_random_keyword[0]; + } + elseif (empty($orderby)) + { + return $this; + } + elseif ($direction !== '') + { + $direction = in_array($direction, array('ASC', 'DESC'), TRUE) ? ' '.$direction : ''; + } + + is_bool($escape) OR $escape = $this->_protect_identifiers; + + if ($escape === FALSE) + { + $qb_orderby[] = array('field' => $orderby, 'direction' => $direction, 'escape' => FALSE); + } + else + { + $qb_orderby = array(); + foreach (explode(',', $orderby) as $field) + { + $qb_orderby[] = ($direction === '' && preg_match('/\s+(ASC|DESC)$/i', rtrim($field), $match, PREG_OFFSET_CAPTURE)) + ? array('field' => ltrim(substr($field, 0, $match[0][1])), 'direction' => ' '.$match[1][0], 'escape' => TRUE) + : array('field' => trim($field), 'direction' => $direction, 'escape' => TRUE); + } + } + + $this->qb_orderby = array_merge($this->qb_orderby, $qb_orderby); + if ($this->qb_caching === TRUE) + { + $this->qb_cache_orderby = array_merge($this->qb_cache_orderby, $qb_orderby); + $this->qb_cache_exists[] = 'orderby'; + } + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * LIMIT + * + * @param int $value LIMIT value + * @param int $offset OFFSET value + * @return CI_DB_query_builder + */ + public function limit($value, $offset = FALSE) + { + is_null($value) OR $this->qb_limit = (int) $value; + empty($offset) OR $this->qb_offset = (int) $offset; + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * Sets the OFFSET value + * + * @param int $offset OFFSET value + * @return CI_DB_query_builder + */ + public function offset($offset) + { + empty($offset) OR $this->qb_offset = (int) $offset; + return $this; + } + + // -------------------------------------------------------------------- + + /** + * LIMIT string + * + * Generates a platform-specific LIMIT clause. + * + * @param string $sql SQL Query + * @return string + */ + protected function _limit($sql) + { + return $sql.' LIMIT '.($this->qb_offset ? $this->qb_offset.', ' : '').$this->qb_limit; + } + + // -------------------------------------------------------------------- + + /** + * The "set" function. + * + * Allows key/value pairs to be set for inserting or updating + * + * @param mixed + * @param string + * @param bool + * @return CI_DB_query_builder + */ + public function set($key, $value = '', $escape = NULL) + { + $key = $this->_object_to_array($key); + + if ( ! is_array($key)) + { + $key = array($key => $value); + } + + is_bool($escape) OR $escape = $this->_protect_identifiers; + + foreach ($key as $k => $v) + { + $this->qb_set[$this->protect_identifiers($k, FALSE, $escape)] = ($escape) + ? $this->escape($v) : $v; + } + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * Get SELECT query string + * + * Compiles a SELECT query string and returns the sql. + * + * @param string the table name to select from (optional) + * @param bool TRUE: resets QB values; FALSE: leave QB vaules alone + * @return string + */ + public function get_compiled_select($table = '', $reset = TRUE) + { + if ($table !== '') + { + $this->_track_aliases($table); + $this->from($table); + } + + $select = $this->_compile_select(); + + if ($reset === TRUE) + { + $this->_reset_select(); + } + + return $select; + } + + // -------------------------------------------------------------------- + + /** + * Get + * + * Compiles the select statement based on the other functions called + * and runs the query + * + * @param string the table + * @param string the limit clause + * @param string the offset clause + * @return object + */ + public function get($table = '', $limit = NULL, $offset = NULL) + { + if ($table !== '') + { + $this->_track_aliases($table); + $this->from($table); + } + + if ( ! empty($limit)) + { + $this->limit($limit, $offset); + } + + $result = $this->query($this->_compile_select()); + $this->_reset_select(); + return $result; + } + + // -------------------------------------------------------------------- + + /** + * "Count All Results" query + * + * Generates a platform-specific query string that counts all records + * returned by an Query Builder query. + * + * @param string + * @return int + */ + public function count_all_results($table = '') + { + if ($table !== '') + { + $this->_track_aliases($table); + $this->from($table); + } + + $result = ($this->qb_distinct === TRUE) + ? $this->query($this->_count_string.$this->protect_identifiers('numrows')."\nFROM (\n".$this->_compile_select()."\n) CI_count_all_results") + : $this->query($this->_compile_select($this->_count_string.$this->protect_identifiers('numrows'))); + $this->_reset_select(); + + if ($result->num_rows() === 0) + { + return 0; + } + + $row = $result->row(); + return (int) $row->numrows; + } + + // -------------------------------------------------------------------- + + /** + * Get_Where + * + * Allows the where clause, limit and offset to be added directly + * + * @param string $table + * @param string $where + * @param int $limit + * @param int $offset + * @return object + */ + public function get_where($table = '', $where = NULL, $limit = NULL, $offset = NULL) + { + if ($table !== '') + { + $this->from($table); + } + + if ($where !== NULL) + { + $this->where($where); + } + + if ( ! empty($limit)) + { + $this->limit($limit, $offset); + } + + $result = $this->query($this->_compile_select()); + $this->_reset_select(); + return $result; + } + + // -------------------------------------------------------------------- + + /** + * Insert_Batch + * + * Compiles batch insert strings and runs the queries + * + * @param string $table Table to insert into + * @param array $set An associative array of insert values + * @param bool $escape Whether to escape values and identifiers + * @return int Number of rows inserted or FALSE on failure + */ + public function insert_batch($table = '', $set = NULL, $escape = NULL) + { + if ($set !== NULL) + { + $this->set_insert_batch($set, '', $escape); + } + + if (count($this->qb_set) === 0) + { + // No valid data array. Folds in cases where keys and values did not match up + return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE; + } + + if ($table === '') + { + if ( ! isset($this->qb_from[0])) + { + return ($this->db_debug) ? $this->display_error('db_must_set_table') : FALSE; + } + + $table = $this->qb_from[0]; + } + + // Batch this baby + $affected_rows = 0; + for ($i = 0, $total = count($this->qb_set); $i < $total; $i += 100) + { + $this->query($this->_insert_batch($this->protect_identifiers($table, TRUE, $escape, FALSE), $this->qb_keys, array_slice($this->qb_set, $i, 100))); + $affected_rows += $this->affected_rows(); + } + + $this->_reset_write(); + return $affected_rows; + } + + // -------------------------------------------------------------------- + + /** + * Insert batch statement + * + * Generates a platform-specific insert string from the supplied data. + * + * @param string $table Table name + * @param array $keys INSERT keys + * @param array $values INSERT values + * @return string + */ + protected function _insert_batch($table, $keys, $values) + { + return 'INSERT INTO '.$table.' ('.implode(', ', $keys).') VALUES '.implode(', ', $values); + } + + // -------------------------------------------------------------------- + + /** + * The "set_insert_batch" function. Allows key/value pairs to be set for batch inserts + * + * @param mixed + * @param string + * @param bool + * @return CI_DB_query_builder + */ + public function set_insert_batch($key, $value = '', $escape = NULL) + { + $key = $this->_object_to_array_batch($key); + + if ( ! is_array($key)) + { + $key = array($key => $value); + } + + is_bool($escape) OR $escape = $this->_protect_identifiers; + + $keys = array_keys($this->_object_to_array(current($key))); + sort($keys); + + foreach ($key as $row) + { + $row = $this->_object_to_array($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->qb_set[] = array(); + return; + } + + ksort($row); // puts $row in the same order as our keys + + if ($escape !== FALSE) + { + $clean = array(); + foreach ($row as $value) + { + $clean[] = $this->escape($value); + } + + $row = $clean; + } + + $this->qb_set[] = '('.implode(',', $row).')'; + } + + foreach ($keys as $k) + { + $this->qb_keys[] = $this->protect_identifiers($k, FALSE, $escape); + } + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * Get INSERT query string + * + * Compiles an insert query and returns the sql + * + * @param string the table to insert into + * @param bool TRUE: reset QB values; FALSE: leave QB values alone + * @return string + */ + public function get_compiled_insert($table = '', $reset = TRUE) + { + if ($this->_validate_insert($table) === FALSE) + { + return FALSE; + } + + $sql = $this->_insert( + $this->protect_identifiers( + $this->qb_from[0], TRUE, NULL, FALSE + ), + array_keys($this->qb_set), + array_values($this->qb_set) + ); + + if ($reset === TRUE) + { + $this->_reset_write(); + } + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Insert + * + * Compiles an insert string and runs the query + * + * @param string the table to insert data into + * @param array an associative array of insert values + * @param bool $escape Whether to escape values and identifiers + * @return object + */ + public function insert($table = '', $set = NULL, $escape = NULL) + { + if ($set !== NULL) + { + $this->set($set, '', $escape); + } + + if ($this->_validate_insert($table) === FALSE) + { + return FALSE; + } + + $sql = $this->_insert( + $this->protect_identifiers( + $this->qb_from[0], TRUE, $escape, FALSE + ), + array_keys($this->qb_set), + array_values($this->qb_set) + ); + + $this->_reset_write(); + return $this->query($sql); + } + + // -------------------------------------------------------------------- + + /** + * Validate Insert + * + * This method is used by both insert() and get_compiled_insert() to + * validate that the there data is actually being set and that table + * has been chosen to be inserted into. + * + * @param string the table to insert data into + * @return string + */ + protected function _validate_insert($table = '') + { + if (count($this->qb_set) === 0) + { + return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE; + } + + if ($table !== '') + { + $this->qb_from[0] = $table; + } + elseif ( ! isset($this->qb_from[0])) + { + return ($this->db_debug) ? $this->display_error('db_must_set_table') : FALSE; + } + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Replace + * + * Compiles an replace into string and runs the query + * + * @param string the table to replace data into + * @param array an associative array of insert values + * @return object + */ + public function replace($table = '', $set = NULL) + { + if ($set !== NULL) + { + $this->set($set); + } + + if (count($this->qb_set) === 0) + { + return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE; + } + + if ($table === '') + { + if ( ! isset($this->qb_from[0])) + { + return ($this->db_debug) ? $this->display_error('db_must_set_table') : FALSE; + } + + $table = $this->qb_from[0]; + } + + $sql = $this->_replace($this->protect_identifiers($table, TRUE, NULL, FALSE), array_keys($this->qb_set), array_values($this->qb_set)); + + $this->_reset_write(); + return $this->query($sql); + } + + // -------------------------------------------------------------------- + + /** + * Replace statement + * + * Generates a platform-specific replace string from the supplied data + * + * @param string the table name + * @param array the insert keys + * @param array the insert values + * @return string + */ + protected function _replace($table, $keys, $values) + { + return 'REPLACE INTO '.$table.' ('.implode(', ', $keys).') VALUES ('.implode(', ', $values).')'; + } + + // -------------------------------------------------------------------- + + /** + * FROM tables + * + * Groups tables in FROM clauses if needed, so there is no confusion + * about operator precedence. + * + * Note: This is only used (and overriden) by MySQL and CUBRID. + * + * @return string + */ + protected function _from_tables() + { + return implode(', ', $this->qb_from); + } + + // -------------------------------------------------------------------- + + /** + * Get UPDATE query string + * + * Compiles an update query and returns the sql + * + * @param string the table to update + * @param bool TRUE: reset QB values; FALSE: leave QB values alone + * @return string + */ + public function get_compiled_update($table = '', $reset = TRUE) + { + // Combine any cached components with the current statements + $this->_merge_cache(); + + if ($this->_validate_update($table) === FALSE) + { + return FALSE; + } + + $sql = $this->_update($this->protect_identifiers($this->qb_from[0], TRUE, NULL, FALSE), $this->qb_set); + + if ($reset === TRUE) + { + $this->_reset_write(); + } + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * UPDATE + * + * Compiles an update string and runs the query. + * + * @param string $table + * @param array $set An associative array of update values + * @param mixed $where + * @param int $limit + * @return object + */ + public function update($table = '', $set = NULL, $where = NULL, $limit = NULL) + { + // Combine any cached components with the current statements + $this->_merge_cache(); + + if ($set !== NULL) + { + $this->set($set); + } + + if ($this->_validate_update($table) === FALSE) + { + return FALSE; + } + + if ($where !== NULL) + { + $this->where($where); + } + + if ( ! empty($limit)) + { + $this->limit($limit); + } + + $sql = $this->_update($this->protect_identifiers($this->qb_from[0], TRUE, NULL, FALSE), $this->qb_set); + $this->_reset_write(); + return $this->query($sql); + } + + // -------------------------------------------------------------------- + + /** + * Validate Update + * + * This method is used by both update() and get_compiled_update() to + * validate that data is actually being set and that a table has been + * chosen to be update. + * + * @param string the table to update data on + * @return bool + */ + protected function _validate_update($table = '') + { + if (count($this->qb_set) === 0) + { + return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE; + } + + if ($table !== '') + { + $this->qb_from[0] = $table; + } + elseif ( ! isset($this->qb_from[0])) + { + return ($this->db_debug) ? $this->display_error('db_must_set_table') : FALSE; + } + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Update_Batch + * + * Compiles an update string and runs the query + * + * @param string the table to retrieve the results from + * @param array an associative array of update values + * @param string the where key + * @return int number of rows affected or FALSE on failure + */ + public function update_batch($table = '', $set = NULL, $index = NULL) + { + // Combine any cached components with the current statements + $this->_merge_cache(); + + if ($index === NULL) + { + return ($this->db_debug) ? $this->display_error('db_must_use_index') : FALSE; + } + + if ($set !== NULL) + { + $this->set_update_batch($set, $index); + } + + if (count($this->qb_set) === 0) + { + return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE; + } + + if ($table === '') + { + if ( ! isset($this->qb_from[0])) + { + return ($this->db_debug) ? $this->display_error('db_must_set_table') : FALSE; + } + + $table = $this->qb_from[0]; + } + + // Batch this baby + $affected_rows = 0; + for ($i = 0, $total = count($this->qb_set); $i < $total; $i += 100) + { + $this->query($this->_update_batch($this->protect_identifiers($table, TRUE, NULL, FALSE), array_slice($this->qb_set, $i, 100), $this->protect_identifiers($index))); + $affected_rows += $this->affected_rows(); + $this->qb_where = array(); + } + + $this->_reset_write(); + return $affected_rows; + } + + // -------------------------------------------------------------------- + + /** + * Update_Batch statement + * + * Generates a platform-specific batch update string from the supplied data + * + * @param string $table Table name + * @param array $values Update data + * @param string $index WHERE key + * @return string + */ + protected function _update_batch($table, $values, $index) + { + $ids = array(); + 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]; + } + } + } + + $cases = ''; + foreach ($final as $k => $v) + { + $cases .= $k." = CASE \n" + .implode("\n", $v)."\n" + .'ELSE '.$k.' END, '; + } + + $this->where($index.' IN('.implode(',', $ids).')', NULL, FALSE); + + return 'UPDATE '.$table.' SET '.substr($cases, 0, -2).$this->_compile_wh('qb_where'); + } + + // -------------------------------------------------------------------- + + /** + * The "set_update_batch" function. Allows key/value pairs to be set for batch updating + * + * @param array + * @param string + * @param bool + * @return CI_DB_query_builder + */ + public function set_update_batch($key, $index = '', $escape = NULL) + { + $key = $this->_object_to_array_batch($key); + + if ( ! is_array($key)) + { + // @todo error + } + + is_bool($escape) OR $escape = $this->_protect_identifiers; + + foreach ($key as $k => $v) + { + $index_set = FALSE; + $clean = array(); + foreach ($v as $k2 => $v2) + { + if ($k2 === $index) + { + $index_set = TRUE; + } + + $clean[$this->protect_identifiers($k2, FALSE, $escape)] = ($escape === FALSE) ? $v2 : $this->escape($v2); + } + + if ($index_set === FALSE) + { + return $this->display_error('db_batch_missing_index'); + } + + $this->qb_set[] = $clean; + } + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * Empty Table + * + * Compiles a delete string and runs "DELETE FROM table" + * + * @param string the table to empty + * @return object + */ + public function empty_table($table = '') + { + if ($table === '') + { + if ( ! isset($this->qb_from[0])) + { + return ($this->db_debug) ? $this->display_error('db_must_set_table') : FALSE; + } + + $table = $this->qb_from[0]; + } + else + { + $table = $this->protect_identifiers($table, TRUE, NULL, FALSE); + } + + $sql = $this->_delete($table); + $this->_reset_write(); + return $this->query($sql); + } + + // -------------------------------------------------------------------- + + /** + * Truncate + * + * Compiles a truncate string and runs the query + * If the database does not support the truncate() command + * This function maps to "DELETE FROM table" + * + * @param string the table to truncate + * @return object + */ + public function truncate($table = '') + { + if ($table === '') + { + if ( ! isset($this->qb_from[0])) + { + return ($this->db_debug) ? $this->display_error('db_must_set_table') : FALSE; + } + + $table = $this->qb_from[0]; + } + else + { + $table = $this->protect_identifiers($table, TRUE, NULL, FALSE); + } + + $sql = $this->_truncate($table); + $this->_reset_write(); + return $this->query($sql); + } + + // -------------------------------------------------------------------- + + /** + * Truncate statement + * + * Generates a platform-specific truncate string from the supplied data + * + * If the database does not support the truncate() command, + * then this method maps to 'DELETE FROM table' + * + * @param string the table name + * @return string + */ + protected function _truncate($table) + { + return 'TRUNCATE '.$table; + } + + // -------------------------------------------------------------------- + + /** + * Get DELETE query string + * + * Compiles a delete query string and returns the sql + * + * @param string the table to delete from + * @param bool TRUE: reset QB values; FALSE: leave QB values alone + * @return string + */ + public function get_compiled_delete($table = '', $reset = TRUE) + { + $this->return_delete_sql = TRUE; + $sql = $this->delete($table, '', NULL, $reset); + $this->return_delete_sql = FALSE; + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Delete + * + * Compiles a delete string and runs the query + * + * @param mixed the table(s) to delete from. String or array + * @param mixed the where clause + * @param mixed the limit clause + * @param bool + * @return mixed + */ + public function delete($table = '', $where = '', $limit = NULL, $reset_data = TRUE) + { + // Combine any cached components with the current statements + $this->_merge_cache(); + + if ($table === '') + { + if ( ! isset($this->qb_from[0])) + { + return ($this->db_debug) ? $this->display_error('db_must_set_table') : FALSE; + } + + $table = $this->qb_from[0]; + } + elseif (is_array($table)) + { + foreach ($table as $single_table) + { + $this->delete($single_table, $where, $limit, $reset_data); + } + return; + } + else + { + $table = $this->protect_identifiers($table, TRUE, NULL, FALSE); + } + + if ($where !== '') + { + $this->where($where); + } + + if ( ! empty($limit)) + { + $this->limit($limit); + } + + if (count($this->qb_where) === 0) + { + return ($this->db_debug) ? $this->display_error('db_del_must_use_where') : FALSE; + } + + $sql = $this->_delete($table); + if ($reset_data) + { + $this->_reset_write(); + } + + return ($this->return_delete_sql === TRUE) ? $sql : $this->query($sql); + } + + // -------------------------------------------------------------------- + + /** + * Delete statement + * + * Generates a platform-specific delete string from the supplied data + * + * @param string the table name + * @return string + */ + protected function _delete($table) + { + return 'DELETE FROM '.$table.$this->_compile_wh('qb_where') + .($this->qb_limit ? ' LIMIT '.$this->qb_limit : ''); + } + + // -------------------------------------------------------------------- + + /** + * DB Prefix + * + * Prepends a database prefix if one exists in configuration + * + * @param string the table + * @return string + */ + public function dbprefix($table = '') + { + if ($table === '') + { + $this->display_error('db_table_name_required'); + } + + return $this->dbprefix.$table; + } + + // -------------------------------------------------------------------- + + /** + * Set DB Prefix + * + * Set's the DB Prefix to something new without needing to reconnect + * + * @param string the prefix + * @return string + */ + public function set_dbprefix($prefix = '') + { + return $this->dbprefix = $prefix; + } + + // -------------------------------------------------------------------- + + /** + * Track Aliases + * + * Used to track SQL statements written with aliased tables. + * + * @param string The table to inspect + * @return string + */ + protected function _track_aliases($table) + { + if (is_array($table)) + { + foreach ($table as $t) + { + $this->_track_aliases($t); + } + 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('/\s+AS\s+/i', ' ', $table); + + // Grab the alias + $table = trim(strrchr($table, ' ')); + + // Store the alias, if it doesn't already exist + if ( ! in_array($table, $this->qb_aliased_tables)) + { + $this->qb_aliased_tables[] = $table; + } + } + } + + // -------------------------------------------------------------------- + + /** + * Compile the SELECT statement + * + * Generates a query string based on which functions were used. + * Should not be called directly. + * + * @param bool $select_override + * @return string + */ + protected function _compile_select($select_override = FALSE) + { + // Combine any cached components with the current statements + $this->_merge_cache(); + + // Write the "select" portion of the query + if ($select_override !== FALSE) + { + $sql = $select_override; + } + else + { + $sql = ( ! $this->qb_distinct) ? 'SELECT ' : 'SELECT DISTINCT '; + + if (count($this->qb_select) === 0) + { + $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 + foreach ($this->qb_select as $key => $val) + { + $no_escape = isset($this->qb_no_escape[$key]) ? $this->qb_no_escape[$key] : NULL; + $this->qb_select[$key] = $this->protect_identifiers($val, FALSE, $no_escape); + } + + $sql .= implode(', ', $this->qb_select); + } + } + + // Write the "FROM" portion of the query + if (count($this->qb_from) > 0) + { + $sql .= "\nFROM ".$this->_from_tables(); + } + + // Write the "JOIN" portion of the query + if (count($this->qb_join) > 0) + { + $sql .= "\n".implode("\n", $this->qb_join); + } + + $sql .= $this->_compile_wh('qb_where') + .$this->_compile_group_by() + .$this->_compile_wh('qb_having') + .$this->_compile_order_by(); // ORDER BY + + // LIMIT + if ($this->qb_limit) + { + return $this->_limit($sql."\n"); + } + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Compile WHERE, HAVING statements + * + * Escapes identifiers in WHERE and HAVING statements at execution time. + * + * Required so that aliases are tracked properly, regardless of wether + * where(), or_where(), having(), or_having are called prior to from(), + * join() and dbprefix is added only if needed. + * + * @param string $qb_key 'qb_where' or 'qb_having' + * @return string SQL statement + */ + protected function _compile_wh($qb_key) + { + if (count($this->$qb_key) > 0) + { + for ($i = 0, $c = count($this->$qb_key); $i < $c; $i++) + { + // Is this condition already compiled? + if (is_string($this->{$qb_key}[$i])) + { + continue; + } + elseif ($this->{$qb_key}[$i]['escape'] === FALSE) + { + $this->{$qb_key}[$i] = $this->{$qb_key}[$i]['condition']; + continue; + } + + // Split multiple conditions + $conditions = preg_split( + '/(\s*AND\s+|\s*OR\s+)/i', + $this->{$qb_key}[$i]['condition'], + -1, + PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY + ); + + for ($ci = 0, $cc = count($conditions); $ci < $cc; $ci++) + { + if (($op = $this->_get_operator($conditions[$ci])) === FALSE + OR ! preg_match('/^(\(?)(.*)('.preg_quote($op, '/').')\s*(.*(? '(test <= foo)', /* the whole thing */ + // 1 => '(', /* optional */ + // 2 => 'test', /* the field name */ + // 3 => ' <= ', /* $op */ + // 4 => 'foo', /* optional, if $op is e.g. 'IS NULL' */ + // 5 => ')' /* optional */ + // ); + + if ( ! empty($matches[4])) + { + $this->_is_literal($matches[4]) OR $matches[4] = $this->protect_identifiers(trim($matches[4])); + $matches[4] = ' '.$matches[4]; + } + + $conditions[$ci] = $matches[1].$this->protect_identifiers(trim($matches[2])) + .' '.trim($matches[3]).$matches[4].$matches[5]; + } + + $this->{$qb_key}[$i] = implode('', $conditions); + } + + return ($qb_key === 'qb_having' ? "\nHAVING " : "\nWHERE ") + .implode("\n", $this->$qb_key); + } + + return ''; + } + + // -------------------------------------------------------------------- + + /** + * Compile GROUP BY + * + * Escapes identifiers in GROUP BY statements at execution time. + * + * Required so that aliases are tracked properly, regardless of wether + * group_by() is called prior to from(), join() and dbprefix is added + * only if needed. + * + * @return string SQL statement + */ + protected function _compile_group_by() + { + if (count($this->qb_groupby) > 0) + { + for ($i = 0, $c = count($this->qb_groupby); $i < $c; $i++) + { + // Is it already compiled? + if (is_string($this->qb_groupby[$i])) + { + continue; + } + + $this->qb_groupby[$i] = ($this->qb_groupby[$i]['escape'] === FALSE OR $this->_is_literal($this->qb_groupby[$i]['field'])) + ? $this->qb_groupby[$i]['field'] + : $this->protect_identifiers($this->qb_groupby[$i]['field']); + } + + return "\nGROUP BY ".implode(', ', $this->qb_groupby); + } + + return ''; + } + + // -------------------------------------------------------------------- + + /** + * Compile ORDER BY + * + * Escapes identifiers in ORDER BY statements at execution time. + * + * Required so that aliases are tracked properly, regardless of wether + * order_by() is called prior to from(), join() and dbprefix is added + * only if needed. + * + * @return string SQL statement + */ + protected function _compile_order_by() + { + if (is_array($this->qb_orderby) && count($this->qb_orderby) > 0) + { + for ($i = 0, $c = count($this->qb_orderby); $i < $c; $i++) + { + if ($this->qb_orderby[$i]['escape'] !== FALSE && ! $this->_is_literal($this->qb_orderby[$i]['field'])) + { + $this->qb_orderby[$i]['field'] = $this->protect_identifiers($this->qb_orderby[$i]['field']); + } + + $this->qb_orderby[$i] = $this->qb_orderby[$i]['field'].$this->qb_orderby[$i]['direction']; + } + + return $this->qb_orderby = "\nORDER BY ".implode(', ', $this->qb_orderby); + } + elseif (is_string($this->qb_orderby)) + { + return $this->qb_orderby; + } + + return ''; + } + + // -------------------------------------------------------------------- + + /** + * Object to Array + * + * Takes an object as input and converts the class variables to array key/vals + * + * @param object + * @return array + */ + protected function _object_to_array($object) + { + if ( ! is_object($object)) + { + 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') + { + $array[$key] = $val; + } + } + + return $array; + } + + // -------------------------------------------------------------------- + + /** + * Object to Array + * + * Takes an object as input and converts the class variables to array key/vals + * + * @param object + * @return array + */ + protected 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; + } + } + } + + return $array; + } + + // -------------------------------------------------------------------- + + /** + * Start Cache + * + * Starts QB caching + * + * @return void + */ + public function start_cache() + { + $this->qb_caching = TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Stop Cache + * + * Stops QB caching + * + * @return void + */ + public function stop_cache() + { + $this->qb_caching = FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Flush Cache + * + * Empties the QB cache + * + * @return void + */ + public function flush_cache() + { + $this->_reset_run(array( + 'qb_cache_select' => array(), + 'qb_cache_from' => array(), + 'qb_cache_join' => array(), + 'qb_cache_where' => array(), + 'qb_cache_groupby' => array(), + 'qb_cache_having' => array(), + 'qb_cache_orderby' => array(), + 'qb_cache_set' => array(), + 'qb_cache_exists' => array(), + 'qb_cache_no_escape' => array() + )); + } + + // -------------------------------------------------------------------- + + /** + * Merge Cache + * + * When called, this function merges any cached QB arrays with + * locally called ones. + * + * @return void + */ + protected function _merge_cache() + { + if (count($this->qb_cache_exists) === 0) + { + return; + } + elseif (in_array('select', $this->qb_cache_exists, TRUE)) + { + $qb_no_escape = $this->qb_cache_no_escape; + } + + foreach (array_unique($this->qb_cache_exists) as $val) // select, from, etc. + { + $qb_variable = 'qb_'.$val; + $qb_cache_var = 'qb_cache_'.$val; + $qb_new = $this->$qb_cache_var; + + for ($i = 0, $c = count($this->$qb_variable); $i < $c; $i++) + { + if ( ! in_array($this->{$qb_variable}[$i], $qb_new, TRUE)) + { + $qb_new[] = $this->{$qb_variable}[$i]; + if ($val === 'select') + { + $qb_no_escape[] = $this->qb_no_escape[$i]; + } + } + } + + $this->$qb_variable = $qb_new; + if ($val === 'select') + { + $this->qb_no_escape = $qb_no_escape; + } + } + + // If we are "protecting identifiers" we need to examine the "from" + // portion of the query to determine if there are any aliases + if ($this->_protect_identifiers === TRUE && count($this->qb_cache_from) > 0) + { + $this->_track_aliases($this->qb_from); + } + } + + // -------------------------------------------------------------------- + + /** + * Is literal + * + * Determines if a string represents a literal value or a field name + * + * @param string $str + * @return bool + */ + protected function _is_literal($str) + { + $str = trim($str); + + if (empty($str) OR ctype_digit($str) OR (string) (float) $str === $str OR in_array(strtoupper($str), array('TRUE', 'FALSE'), TRUE)) + { + return TRUE; + } + + static $_str; + + if (empty($_str)) + { + $_str = ($this->_escape_char !== '"') + ? array('"', "'") : array("'"); + } + + return in_array($str[0], $_str, TRUE); + } + + // -------------------------------------------------------------------- + + /** + * Reset Query Builder values. + * + * Publicly-visible method to reset the QB values. + * + * @return void + */ + public function reset_query() + { + $this->_reset_select(); + $this->_reset_write(); + } + + // -------------------------------------------------------------------- + + /** + * Resets the query builder values. Called by the get() function + * + * @param array An array of fields to reset + * @return void + */ + protected function _reset_run($qb_reset_items) + { + foreach ($qb_reset_items as $item => $default_value) + { + $this->$item = $default_value; + } + } + + // -------------------------------------------------------------------- + + /** + * Resets the query builder values. Called by the get() function + * + * @return void + */ + protected function _reset_select() + { + $this->_reset_run(array( + 'qb_select' => array(), + 'qb_from' => array(), + 'qb_join' => array(), + 'qb_where' => array(), + 'qb_groupby' => array(), + 'qb_having' => array(), + 'qb_orderby' => array(), + 'qb_aliased_tables' => array(), + 'qb_no_escape' => array(), + 'qb_distinct' => FALSE, + 'qb_limit' => FALSE, + 'qb_offset' => FALSE + ) + ); + } + + // -------------------------------------------------------------------- + + /** + * Resets the query builder "write" values. + * + * Called by the insert() update() insert_batch() update_batch() and delete() functions + * + * @return void + */ + protected function _reset_write() + { + $this->_reset_run(array( + 'qb_set' => array(), + 'qb_from' => array(), + 'qb_join' => array(), + 'qb_where' => array(), + 'qb_orderby' => array(), + 'qb_keys' => array(), + 'qb_limit' => FALSE + ) + ); + } + +} + +/* End of file DB_query_builder.php */ +/* Location: ./system/database/DB_query_builder.php */ \ No newline at end of file diff --git a/system/database/DB_result.php b/system/database/DB_result.php new file mode 100755 index 0000000..b02d016 --- /dev/null +++ b/system/database/DB_result.php @@ -0,0 +1,658 @@ +conn_id = $driver_object->conn_id; + $this->result_id = $driver_object->result_id; + } + + // -------------------------------------------------------------------- + + /** + * Number of rows in the result set + * + * @return int + */ + public function num_rows() + { + if (is_int($this->num_rows)) + { + return $this->num_rows; + } + elseif (count($this->result_array) > 0) + { + return $this->num_rows = count($this->result_array); + } + elseif (count($this->result_object) > 0) + { + return $this->num_rows = count($this->result_object); + } + + return $this->num_rows = count($this->result_array()); + } + + // -------------------------------------------------------------------- + + /** + * Query result. Acts as a wrapper function for the following functions. + * + * @param string $type 'object', 'array' or a custom class name + * @return array + */ + public function result($type = 'object') + { + if ($type === 'array') + { + return $this->result_array(); + } + elseif ($type === 'object') + { + return $this->result_object(); + } + else + { + return $this->custom_result_object($type); + } + } + + // -------------------------------------------------------------------- + + /** + * Custom query result. + * + * @param string $class_name + * @return array + */ + public function custom_result_object($class_name) + { + if (isset($this->custom_result_object[$class_name])) + { + return $this->custom_result_object[$class_name]; + } + elseif ( ! $this->result_id OR $this->num_rows === 0) + { + return array(); + } + + // Don't fetch the result set again if we already have it + $_data = NULL; + if (($c = count($this->result_array)) > 0) + { + $_data = 'result_array'; + } + elseif (($c = count($this->result_object)) > 0) + { + $_data = 'result_object'; + } + + if ($_data !== NULL) + { + for ($i = 0; $i < $c; $i++) + { + $this->custom_result_object[$class_name][$i] = new $class_name(); + + foreach ($this->{$_data}[$i] as $key => $value) + { + $this->custom_result_object[$class_name][$i]->$key = $value; + } + } + + return $this->custom_result_object[$class_name]; + } + + is_null($this->row_data) OR $this->data_seek(0); + $this->custom_result_object[$class_name] = array(); + + while ($row = $this->_fetch_object($class_name)) + { + $this->custom_result_object[$class_name][] = $row; + } + + return $this->custom_result_object[$class_name]; + } + + // -------------------------------------------------------------------- + + /** + * Query result. "object" version. + * + * @return array + */ + public function result_object() + { + if (count($this->result_object) > 0) + { + return $this->result_object; + } + + // In the event that query caching is on, the result_id variable + // will not be a valid resource so we'll simply return an empty + // array. + if ( ! $this->result_id OR $this->num_rows === 0) + { + return array(); + } + + if (($c = count($this->result_array)) > 0) + { + for ($i = 0; $i < $c; $i++) + { + $this->result_object[$i] = (object) $this->result_array[$i]; + } + + return $this->result_object; + } + + is_null($this->row_data) OR $this->data_seek(0); + while ($row = $this->_fetch_object()) + { + $this->result_object[] = $row; + } + + return $this->result_object; + } + + // -------------------------------------------------------------------- + + /** + * Query result. "array" version. + * + * @return array + */ + public function result_array() + { + if (count($this->result_array) > 0) + { + return $this->result_array; + } + + // In the event that query caching is on, the result_id variable + // will not be a valid resource so we'll simply return an empty + // array. + if ( ! $this->result_id OR $this->num_rows === 0) + { + return array(); + } + + if (($c = count($this->result_object)) > 0) + { + for ($i = 0; $i < $c; $i++) + { + $this->result_array[$i] = (array) $this->result_object[$i]; + } + + return $this->result_array; + } + + is_null($this->row_data) OR $this->data_seek(0); + while ($row = $this->_fetch_assoc()) + { + $this->result_array[] = $row; + } + + return $this->result_array; + } + + // -------------------------------------------------------------------- + + /** + * Row + * + * A wrapper method. + * + * @param mixed $n + * @param string $type 'object' or 'array' + * @return mixed + */ + public function row($n = 0, $type = 'object') + { + if ( ! is_numeric($n)) + { + // We cache the row data for subsequent uses + is_array($this->row_data) OR $this->row_data = $this->row_array(0); + + // array_key_exists() instead of isset() to allow for NULL values + if (empty($this->row_data) OR ! array_key_exists($n, $this->row_data)) + { + return NULL; + } + + return $this->row_data[$n]; + } + + if ($type === 'object') return $this->row_object($n); + elseif ($type === 'array') return $this->row_array($n); + else return $this->custom_row_object($n, $type); + } + + // -------------------------------------------------------------------- + + /** + * Assigns an item into a particular column slot + * + * @param mixed $key + * @param mixed $value + * @return void + */ + public function set_row($key, $value = NULL) + { + // We cache the row data for subsequent uses + if ( ! is_array($this->row_data)) + { + $this->row_data = $this->row_array(0); + } + + if (is_array($key)) + { + foreach ($key as $k => $v) + { + $this->row_data[$k] = $v; + } + return; + } + + if ($key !== '' && $value !== NULL) + { + $this->row_data[$key] = $value; + } + } + + // -------------------------------------------------------------------- + + /** + * Returns a single result row - custom object version + * + * @param int $n + * @param string $type + * @return object + */ + public function custom_row_object($n, $type) + { + isset($this->custom_result_object[$type]) OR $this->custom_result_object($type); + + if (count($this->custom_result_object[$type]) === 0) + { + return NULL; + } + + if ($n !== $this->current_row && isset($this->custom_result_object[$type][$n])) + { + $this->current_row = $n; + } + + return $this->custom_result_object[$type][$this->current_row]; + } + + // -------------------------------------------------------------------- + + /** + * Returns a single result row - object version + * + * @param int $n + * @return object + */ + public function row_object($n = 0) + { + $result = $this->result_object(); + if (count($result) === 0) + { + return NULL; + } + + if ($n !== $this->current_row && isset($result[$n])) + { + $this->current_row = $n; + } + + return $result[$this->current_row]; + } + + // -------------------------------------------------------------------- + + /** + * Returns a single result row - array version + * + * @param int $n + * @return array + */ + public function row_array($n = 0) + { + $result = $this->result_array(); + if (count($result) === 0) + { + return NULL; + } + + if ($n !== $this->current_row && isset($result[$n])) + { + $this->current_row = $n; + } + + return $result[$this->current_row]; + } + + // -------------------------------------------------------------------- + + /** + * Returns the "first" row + * + * @param string $type + * @return mixed + */ + public function first_row($type = 'object') + { + $result = $this->result($type); + return (count($result) === 0) ? NULL : $result[0]; + } + + // -------------------------------------------------------------------- + + /** + * Returns the "last" row + * + * @param string $type + * @return mixed + */ + public function last_row($type = 'object') + { + $result = $this->result($type); + return (count($result) === 0) ? NULL : $result[count($result) - 1]; + } + + // -------------------------------------------------------------------- + + /** + * Returns the "next" row + * + * @param string $type + * @return mixed + */ + public function next_row($type = 'object') + { + $result = $this->result($type); + if (count($result) === 0) + { + return NULL; + } + + return isset($result[$this->current_row + 1]) + ? $result[++$this->current_row] + : NULL; + } + + // -------------------------------------------------------------------- + + /** + * Returns the "previous" row + * + * @param string $type + * @return mixed + */ + public function previous_row($type = 'object') + { + $result = $this->result($type); + if (count($result) === 0) + { + return NULL; + } + + if (isset($result[$this->current_row - 1])) + { + --$this->current_row; + } + return $result[$this->current_row]; + } + + // -------------------------------------------------------------------- + + /** + * Returns an unbuffered row and move pointer to next row + * + * @param string $type 'array', 'object' or a custom class name + * @return mixed + */ + public function unbuffered_row($type = 'object') + { + if ($type === 'array') + { + return $this->_fetch_assoc(); + } + elseif ($type === 'object') + { + return $this->_fetch_object(); + } + + return $this->_fetch_object($type); + } + + // -------------------------------------------------------------------- + + /** + * The following methods are normally overloaded by the identically named + * methods in the platform-specific driver -- except when query caching + * is used. When caching is enabled we do not load the other driver. + * These functions are primarily here to prevent undefined function errors + * when a cached result object is in use. They are not otherwise fully + * operational due to the unavailability of the database resource IDs with + * cached results. + */ + + // -------------------------------------------------------------------- + + /** + * Number of fields in the result set + * + * Overriden by driver result classes. + * + * @return int + */ + public function num_fields() + { + return 0; + } + + // -------------------------------------------------------------------- + + /** + * Fetch Field Names + * + * Generates an array of column names. + * + * Overriden by driver result classes. + * + * @return array + */ + public function list_fields() + { + return array(); + } + + // -------------------------------------------------------------------- + + /** + * Field data + * + * Generates an array of objects containing field meta-data. + * + * Overriden by driver result classes. + * + * @return array + */ + public function field_data() + { + return array(); + } + + // -------------------------------------------------------------------- + + /** + * Free the result + * + * Overriden by driver result classes. + * + * @return void + */ + public function free_result() + { + $this->result_id = FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Data Seek + * + * Moves the internal pointer to the desired offset. We call + * this internally before fetching results to make sure the + * result set starts at zero. + * + * Overriden by driver result classes. + * + * @param int $n + * @return bool + */ + public function data_seek($n = 0) + { + return FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Result - associative array + * + * Returns the result set as an array. + * + * Overriden by driver result classes. + * + * @return array + */ + protected function _fetch_assoc() + { + return array(); + } + + // -------------------------------------------------------------------- + + /** + * Result - object + * + * Returns the result set as an object. + * + * Overriden by driver result classes. + * + * @param string $class_name + * @return object + */ + protected function _fetch_object($class_name = 'stdClass') + { + return array(); + } + +} + +/* End of file DB_result.php */ +/* Location: ./system/database/DB_result.php */ \ No newline at end of file diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php new file mode 100755 index 0000000..a696112 --- /dev/null +++ b/system/database/DB_utility.php @@ -0,0 +1,415 @@ +db =& $db; + log_message('debug', 'Database Utility Class Initialized'); + } + + // -------------------------------------------------------------------- + + /** + * List databases + * + * @return array + */ + public function list_databases() + { + // Is there a cached result? + if (isset($this->db->data_cache['db_names'])) + { + return $this->db->data_cache['db_names']; + } + elseif ($this->_list_databases === FALSE) + { + return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE; + } + + $this->db->data_cache['db_names'] = array(); + + $query = $this->db->query($this->_list_databases); + if ($query === FALSE) + { + return $this->db->data_cache['db_names']; + } + + for ($i = 0, $query = $query->result_array(), $c = count($query); $i < $c; $i++) + { + $this->db->data_cache['db_names'][] = current($query[$i]); + } + + return $this->db->data_cache['db_names']; + } + + // -------------------------------------------------------------------- + + /** + * Determine if a particular database exists + * + * @param string $database_name + * @return bool + */ + public function database_exists($database_name) + { + return in_array($database_name, $this->list_databases()); + } + + // -------------------------------------------------------------------- + + /** + * Optimize Table + * + * @param string $table_name + * @return mixed + */ + public function optimize_table($table_name) + { + if ($this->_optimize_table === FALSE) + { + return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE; + } + + $query = $this->db->query(sprintf($this->_optimize_table, $this->db->escape_identifiers($table_name))); + if ($query !== FALSE) + { + $query = $query->result_array(); + return current($query); + } + + return FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Optimize Database + * + * @return mixed + */ + public function optimize_database() + { + if ($this->_optimize_table === FALSE) + { + return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE; + } + + $result = array(); + foreach ($this->db->list_tables() as $table_name) + { + $res = $this->db->query(sprintf($this->_optimize_table, $this->db->escape_identifiers($table_name))); + if (is_bool($res)) + { + return $res; + } + + // Build the result array... + $res = $res->result_array(); + $res = current($res); + $key = str_replace($this->db->database.'.', '', current($res)); + $keys = array_keys($res); + unset($res[$keys[0]]); + + $result[$key] = $res; + } + + return $result; + } + + // -------------------------------------------------------------------- + + /** + * Repair Table + * + * @param string $table_name + * @return mixed + */ + public function repair_table($table_name) + { + if ($this->_repair_table === FALSE) + { + return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE; + } + + $query = $this->db->query(sprintf($this->_repair_table, $this->db->escape_identifiers($table_name))); + if (is_bool($query)) + { + return $query; + } + + $query = $query->result_array(); + return current($query); + } + + // -------------------------------------------------------------------- + + /** + * Generate CSV from a query result object + * + * @param object $query Query result object + * @param string $delim Delimiter (default: ,) + * @param string $newline Newline character (default: \n) + * @param string $enclosure Enclosure (default: ") + * @return string + */ + public function csv_from_result($query, $delim = ',', $newline = "\n", $enclosure = '"') + { + if ( ! is_object($query) OR ! method_exists($query, 'list_fields')) + { + show_error('You must submit a valid result object'); + } + + $out = ''; + // First generate the headings from the table column names + foreach ($query->list_fields() as $name) + { + $out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $name).$enclosure.$delim; + } + + $out = substr(rtrim($out), 0, -strlen($delim)).$newline; + + // Next blast through the result array and build out the rows + while ($row = $query->unbuffered_row('array')) + { + foreach ($row as $item) + { + $out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $item).$enclosure.$delim; + } + $out = substr(rtrim($out), 0, -strlen($delim)).$newline; + } + + return $out; + } + + // -------------------------------------------------------------------- + + /** + * Generate XML data from a query result object + * + * @param object $query Query result object + * @param array $params Any preferences + * @return string + */ + public function xml_from_result($query, $params = array()) + { + if ( ! is_object($query) OR ! method_exists($query, 'list_fields')) + { + show_error('You must submit a valid result object'); + } + + // Set our default values + foreach (array('root' => 'root', 'element' => 'element', 'newline' => "\n", 'tab' => "\t") as $key => $val) + { + if ( ! isset($params[$key])) + { + $params[$key] = $val; + } + } + + // Create variables for convenience + extract($params); + + // Load the xml helper + get_instance()->load->helper('xml'); + + // Generate the result + $xml = '<'.$root.'>'.$newline; + while ($row = $query->unbuffered_row()) + { + $xml .= $tab.'<'.$element.'>'.$newline; + foreach ($row as $key => $val) + { + $xml .= $tab.$tab.'<'.$key.'>'.xml_convert($val).''.$newline; + } + $xml .= $tab.''.$newline; + } + + return $xml.''.$newline; + } + + // -------------------------------------------------------------------- + + /** + * Database Backup + * + * @param array $params + * @return void + */ + public function backup($params = array()) + { + // If the parameters have not been submitted as an + // array then we know that it is simply the table + // name, which is a valid short cut. + if (is_string($params)) + { + $params = array('tables' => $params); + } + + // Set up our default preferences + $prefs = array( + 'tables' => array(), + 'ignore' => array(), + 'filename' => '', + 'format' => 'gzip', // gzip, zip, txt + 'add_drop' => TRUE, + 'add_insert' => TRUE, + 'newline' => "\n", + 'foreign_key_checks' => TRUE + ); + + // Did the user submit any preferences? If so set them.... + if (count($params) > 0) + { + foreach ($prefs as $key => $val) + { + if (isset($params[$key])) + { + $prefs[$key] = $params[$key]; + } + } + } + + // Are we backing up a complete database or individual tables? + // If no table names were submitted we'll fetch the entire table list + if (count($prefs['tables']) === 0) + { + $prefs['tables'] = $this->db->list_tables(); + } + + // Validate the format + if ( ! in_array($prefs['format'], array('gzip', 'zip', 'txt'), TRUE)) + { + $prefs['format'] = 'txt'; + } + + // Is the encoder supported? If not, we'll either issue an + // error or use plain text depending on the debug settings + if (($prefs['format'] === 'gzip' && ! function_exists('gzencode')) + OR ($prefs['format'] === 'zip' && ! function_exists('gzcompress'))) + { + if ($this->db->db_debug) + { + return $this->db->display_error('db_unsupported_compression'); + } + + $prefs['format'] = 'txt'; + } + + // Was a Zip file requested? + if ($prefs['format'] === 'zip') + { + // Set the filename if not provided (only needed with Zip files) + if ($prefs['filename'] === '') + { + $prefs['filename'] = (count($prefs['tables']) === 1 ? $prefs['tables'] : $this->db->database) + .date('Y-m-d_H-i', time()).'.sql'; + } + else + { + // If they included the .zip file extension we'll remove it + if (preg_match('|.+?\.zip$|', $prefs['filename'])) + { + $prefs['filename'] = str_replace('.zip', '', $prefs['filename']); + } + + // Tack on the ".sql" file extension if needed + if ( ! preg_match('|.+?\.sql$|', $prefs['filename'])) + { + $prefs['filename'] .= '.sql'; + } + } + + // Load the Zip class and output it + $CI =& get_instance(); + $CI->load->library('zip'); + $CI->zip->add_data($prefs['filename'], $this->_backup($prefs)); + return $CI->zip->get_zip(); + } + elseif ($prefs['format'] === 'txt') // Was a text file requested? + { + return $this->_backup($prefs); + } + elseif ($prefs['format'] === 'gzip') // Was a Gzip file requested? + { + return gzencode($this->_backup($prefs)); + } + + return; + } + +} + +/* End of file DB_utility.php */ +/* Location: ./system/database/DB_utility.php */ \ No newline at end of file diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php new file mode 100755 index 0000000..138b0ed --- /dev/null +++ b/system/database/drivers/cubrid/cubrid_driver.php @@ -0,0 +1,427 @@ +dsn, $matches)) + { + if (stripos($matches[2], 'autocommit=off') !== FALSE) + { + $this->auto_commit = FALSE; + } + } + else + { + // If no port is defined by the user, use the default value + empty($this->port) OR $this->port = 33000; + } + } + + // -------------------------------------------------------------------- + + /** + * Non-persistent database connection + * + * @param bool $persistent + * @return resource + */ + public function db_connect($persistent = FALSE) + { + if (preg_match('/^CUBRID:[^:]+(:[0-9][1-9]{0,4})?:[^:]+:([^:]*):([^:]*):(\?.+)?$/', $this->dsn, $matches)) + { + $func = ($persistent !== TRUE) ? 'cubrid_connect_with_url' : 'cubrid_pconnect_with_url'; + return ($matches[2] === '' && $matches[3] === '' && $this->username !== '' && $this->password !== '') + ? $func($this->dsn, $this->username, $this->password) + : $func($this->dsn); + } + + $func = ($persistent !== TRUE) ? 'cubrid_connect' : 'cubrid_pconnect'; + return ($this->username !== '') + ? $func($this->hostname, $this->port, $this->database, $this->username, $this->password) + : $func($this->hostname, $this->port, $this->database); + } + + // -------------------------------------------------------------------- + + /** + * Reconnect + * + * Keep / reestablish the db connection if no queries have been + * sent for a length of time exceeding the server's idle timeout + * + * @return void + */ + public function reconnect() + { + if (cubrid_ping($this->conn_id) === FALSE) + { + $this->conn_id = FALSE; + } + } + + // -------------------------------------------------------------------- + + /** + * Database version number + * + * @return string + */ + public function version() + { + if (isset($this->data_cache['version'])) + { + return $this->data_cache['version']; + } + elseif ( ! $this->conn_id) + { + $this->initialize(); + } + + return ( ! $this->conn_id OR ($version = cubrid_get_server_info($this->conn_id)) === FALSE) + ? FALSE + : $this->data_cache['version'] = $version; + } + + // -------------------------------------------------------------------- + + /** + * Execute the query + * + * @param string $sql an SQL query + * @return resource + */ + protected function _execute($sql) + { + return cubrid_query($sql, $this->conn_id); + } + + // -------------------------------------------------------------------- + + /** + * Begin Transaction + * + * @param bool $test_mode + * @return bool + */ + public function trans_begin($test_mode = FALSE) + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $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); + + if (cubrid_get_autocommit($this->conn_id)) + { + cubrid_set_autocommit($this->conn_id, CUBRID_AUTOCOMMIT_FALSE); + } + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Commit Transaction + * + * @return bool + */ + public function trans_commit() + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $this->_trans_depth > 0) + { + return TRUE; + } + + cubrid_commit($this->conn_id); + + if ($this->auto_commit && ! cubrid_get_autocommit($this->conn_id)) + { + cubrid_set_autocommit($this->conn_id, CUBRID_AUTOCOMMIT_TRUE); + } + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Rollback Transaction + * + * @return bool + */ + public function trans_rollback() + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $this->_trans_depth > 0) + { + return TRUE; + } + + cubrid_rollback($this->conn_id); + + if ($this->auto_commit && ! cubrid_get_autocommit($this->conn_id)) + { + cubrid_set_autocommit($this->conn_id, CUBRID_AUTOCOMMIT_TRUE); + } + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Platform-dependant string escape + * + * @param string + * @return string + */ + protected function _escape_str($str) + { + if (function_exists('cubrid_real_escape_string') && + (is_resource($this->conn_id) + OR (get_resource_type($this->conn_id) === 'Unknown' && preg_match('/Resource id #/', strval($this->conn_id))))) + { + return cubrid_real_escape_string($str, $this->conn_id); + } + + return addslashes($str); + } + + // -------------------------------------------------------------------- + + /** + * Affected Rows + * + * @return int + */ + public function affected_rows() + { + return cubrid_affected_rows(); + } + + // -------------------------------------------------------------------- + + /** + * Insert ID + * + * @return int + */ + public function insert_id() + { + return cubrid_insert_id($this->conn_id); + } + + // -------------------------------------------------------------------- + + /** + * List table query + * + * Generates a platform-specific query string so that the table names can be fetched + * + * @param bool $prefix_limit + * @return string + */ + protected function _list_tables($prefix_limit = FALSE) + { + $sql = 'SHOW TABLES'; + + if ($prefix_limit !== FALSE && $this->dbprefix !== '') + { + return $sql." LIKE '".$this->escape_like_str($this->dbprefix)."%'"; + } + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Show column query + * + * Generates a platform-specific query string so that the column names can be fetched + * + * @param string $table + * @return string + */ + protected function _list_columns($table = '') + { + return 'SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE); + } + + // -------------------------------------------------------------------- + + /** + * Returns an object with field data + * + * @param string $table + * @return array + */ + public function field_data($table = '') + { + if ($table === '') + { + return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; + } + + if (($query = $this->query('SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE))) === FALSE) + { + return FALSE; + } + $query = $query->result_object(); + + $retval = array(); + for ($i = 0, $c = count($query); $i < $c; $i++) + { + $retval[$i] = new stdClass(); + $retval[$i]->name = $query[$i]->Field; + + sscanf($query[$i]->Type, '%[a-z](%d)', + $retval[$i]->type, + $retval[$i]->max_length + ); + + $retval[$i]->default = $query[$i]->Default; + $retval[$i]->primary_key = (int) ($query[$i]->Key === 'PRI'); + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Error + * + * Returns an array containing code and message of the last + * database error that has occured. + * + * @return array + */ + public function error() + { + return array('code' => cubrid_errno($this->conn_id), 'message' => cubrid_error($this->conn_id)); + } + + // -------------------------------------------------------------------- + + /** + * FROM tables + * + * Groups tables in FROM clauses if needed, so there is no confusion + * about operator precedence. + * + * @return string + */ + protected function _from_tables() + { + if ( ! empty($this->qb_join) && count($this->qb_from) > 1) + { + return '('.implode(', ', $this->qb_from).')'; + } + + return implode(', ', $this->qb_from); + } + + // -------------------------------------------------------------------- + + /** + * Close DB Connection + * + * @return void + */ + protected function _close() + { + cubrid_close($this->conn_id); + } + +} + +/* End of file cubrid_driver.php */ +/* Location: ./system/database/drivers/cubrid/cubrid_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php new file mode 100755 index 0000000..807dd6d --- /dev/null +++ b/system/database/drivers/cubrid/cubrid_forge.php @@ -0,0 +1,219 @@ + 'INTEGER', + 'SMALLINT' => 'INTEGER', + 'INT' => 'BIGINT', + 'INTEGER' => 'BIGINT', + 'BIGINT' => 'NUMERIC', + 'FLOAT' => 'DOUBLE', + 'REAL' => 'DOUBLE' + ); + + // -------------------------------------------------------------------- + + /** + * ALTER TABLE + * + * @param string $alter_type ALTER type + * @param string $table Table name + * @param mixed $field Column definition + * @return string|string[] + */ + protected function _alter_table($alter_type, $table, $field) + { + if (in_array($alter_type, array('DROP', 'ADD'), TRUE)) + { + return parent::_alter_table($alter_type, $table, $field); + } + + $sql = 'ALTER TABLE '.$this->db->escape_identifiers($table); + $sqls = array(); + for ($i = 0, $c = count($field); $i < $c; $i++) + { + if ($field[$i]['_literal'] !== FALSE) + { + $sqls[] = $sql.' CHANGE '.$field[$i]['_literal']; + } + else + { + $alter_type = empty($field[$i]['new_name']) ? ' MODIFY ' : ' CHANGE '; + $sqls[] = $sql.$alter_type.$this->_process_column($field[$i]); + } + } + + return $sqls; + } + + // -------------------------------------------------------------------- + + /** + * Process column + * + * @param array $field + * @return string + */ + protected function _process_column($field) + { + $extra_clause = isset($field['after']) + ? ' AFTER '.$this->db->escape_identifiers($field['after']) : ''; + + if (empty($extra_clause) && isset($field['first']) && $field['first'] === TRUE) + { + $extra_clause = ' FIRST'; + } + + return $this->db->escape_identifiers($field['name']) + .(empty($field['new_name']) ? '' : ' '.$this->db->escape_identifiers($field['new_name'])) + .' '.$field['type'].$field['length'] + .$field['unsigned'] + .$field['null'] + .$field['default'] + .$field['auto_increment'] + .$field['unique'] + .$extra_clause; + } + + // -------------------------------------------------------------------- + + /** + * Field attribute TYPE + * + * Performs a data type mapping between different databases. + * + * @param array &$attributes + * @return void + */ + protected function _attr_type(&$attributes) + { + switch (strtoupper($attributes['TYPE'])) + { + case 'TINYINT': + $attributes['TYPE'] = 'SMALLINT'; + $attributes['UNSIGNED'] = FALSE; + return; + case 'MEDIUMINT': + $attributes['TYPE'] = 'INTEGER'; + $attributes['UNSIGNED'] = FALSE; + return; + default: return; + } + } + + // -------------------------------------------------------------------- + + /** + * Process indexes + * + * @param string $table (ignored) + * @return string + */ + protected function _process_indexes($table) + { + $sql = ''; + + for ($i = 0, $c = count($this->keys); $i < $c; $i++) + { + if (is_array($this->keys[$i])) + { + for ($i2 = 0, $c2 = count($this->keys[$i]); $i2 < $c2; $i2++) + { + if ( ! isset($this->fields[$this->keys[$i][$i2]])) + { + unset($this->keys[$i][$i2]); + continue; + } + } + } + elseif ( ! isset($this->fields[$this->keys[$i]])) + { + unset($this->keys[$i]); + continue; + } + + is_array($this->keys[$i]) OR $this->keys[$i] = array($this->keys[$i]); + + $sql .= ",\n\tKEY ".$this->db->escape_identifiers(implode('_', $this->keys[$i])) + .' ('.implode(', ', $this->db->escape_identifiers($this->keys[$i])).')'; + } + + $this->keys = array(); + + return $sql; + } + +} + +/* End of file cubrid_forge.php */ +/* Location: ./system/database/drivers/cubrid/cubrid_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/cubrid/cubrid_result.php b/system/database/drivers/cubrid/cubrid_result.php new file mode 100755 index 0000000..d2bdeb0 --- /dev/null +++ b/system/database/drivers/cubrid/cubrid_result.php @@ -0,0 +1,170 @@ +num_rows) + ? $this->num_rows + : $this->num_rows = cubrid_num_rows($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Number of fields in the result set + * + * @return int + */ + public function num_fields() + { + return cubrid_num_fields($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Fetch Field Names + * + * Generates an array of column names + * + * @return array + */ + public function list_fields() + { + return cubrid_column_names($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Field data + * + * Generates an array of objects containing field meta-data + * + * @return array + */ + public function field_data() + { + $retval = array(); + + for ($i = 0, $c = $this->num_fields(); $i < $c; $i++) + { + $retval[$i] = new stdClass(); + $retval[$i]->name = cubrid_field_name($this->result_id, $i); + $retval[$i]->type = cubrid_field_type($this->result_id, $i); + $retval[$i]->max_length = cubrid_field_len($this->result_id, $i); + $retval[$i]->primary_key = (int) (strpos(cubrid_field_flags($this->result_id, $i), 'primary_key') !== FALSE); + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Free the result + * + * @return void + */ + public function free_result() + { + if (is_resource($this->result_id) OR + (get_resource_type($this->result_id) === 'Unknown' && preg_match('/Resource id #/', strval($this->result_id)))) + { + cubrid_close_request($this->result_id); + $this->result_id = FALSE; + } + } + + // -------------------------------------------------------------------- + + /** + * Data Seek + * + * Moves the internal pointer to the desired offset. We call + * this internally before fetching results to make sure the + * result set starts at zero. + * + * @param int $n + * @return bool + */ + public function data_seek($n = 0) + { + return cubrid_data_seek($this->result_id, $n); + } + + // -------------------------------------------------------------------- + + /** + * Result - associative array + * + * Returns the result set as an array + * + * @return array + */ + protected function _fetch_assoc() + { + return cubrid_fetch_assoc($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Result - object + * + * Returns the result set as an object + * + * @param string $class_name + * @return object + */ + protected function _fetch_object($class_name = 'stdClass') + { + return cubrid_fetch_object($this->result_id, $class_name); + } + +} + +/* End of file cubrid_result.php */ +/* Location: ./system/database/drivers/cubrid/cubrid_result.php */ \ No newline at end of file diff --git a/system/database/drivers/cubrid/cubrid_utility.php b/system/database/drivers/cubrid/cubrid_utility.php new file mode 100755 index 0000000..54e6b4a --- /dev/null +++ b/system/database/drivers/cubrid/cubrid_utility.php @@ -0,0 +1,71 @@ +db->data_cache['db_names'])) + { + return $this->db->data_cache['db_names']; + } + + return $this->db->data_cache['db_names'] = cubrid_list_dbs($this->db->conn_id); + } + + // -------------------------------------------------------------------- + + /** + * CUBRID Export + * + * @param array Preferences + * @return mixed + */ + protected function _backup($params = array()) + { + // No SQL based support in CUBRID as of version 8.4.0. Database or + // table backup can be performed using CUBRID Manager + // database administration tool. + return $this->db->display_error('db_unsupported_feature'); + } +} + +/* End of file cubrid_utility.php */ +/* Location: ./system/database/drivers/cubrid/cubrid_utility.php */ \ No newline at end of file diff --git a/system/database/drivers/cubrid/index.html b/system/database/drivers/cubrid/index.html new file mode 100755 index 0000000..c942a79 --- /dev/null +++ b/system/database/drivers/cubrid/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

    Directory access is forbidden.

    + + + \ No newline at end of file diff --git a/system/database/drivers/ibase/ibase_driver.php b/system/database/drivers/ibase/ibase_driver.php new file mode 100755 index 0000000..b19985c --- /dev/null +++ b/system/database/drivers/ibase/ibase_driver.php @@ -0,0 +1,401 @@ +hostname.':'.$this->database, $this->username, $this->password, $this->char_set) + : ibase_connect($this->hostname.':'.$this->database, $this->username, $this->password, $this->char_set); + } + + // -------------------------------------------------------------------- + + /** + * Database version number + * + * @return string + */ + public function version() + { + if (isset($this->data_cache['version'])) + { + return $this->data_cache['version']; + } + + if (($service = ibase_service_attach($this->hostname, $this->username, $this->password))) + { + $this->data_cache['version'] = ibase_server_info($service, IBASE_SVC_SERVER_VERSION); + + // Don't keep the service open + ibase_service_detach($service); + return $this->data_cache['version']; + } + + return FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Execute the query + * + * @param string $sql an SQL query + * @return resource + */ + protected function _execute($sql) + { + return ibase_query($this->conn_id, $sql); + } + + // -------------------------------------------------------------------- + + /** + * Begin Transaction + * + * @param bool $test_mode + * @return bool + */ + public function trans_begin($test_mode = FALSE) + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $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); + + $this->_ibase_trans = ibase_trans($this->conn_id); + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Commit Transaction + * + * @return bool + */ + public function trans_commit() + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $this->_trans->depth > 0) + { + return TRUE; + } + + return ibase_commit($this->_ibase_trans); + } + + // -------------------------------------------------------------------- + + /** + * Rollback Transaction + * + * @return bool + */ + public function trans_rollback() + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $this->_trans_depth > 0) + { + return TRUE; + } + + return ibase_rollback($this->_ibase_trans); + } + + // -------------------------------------------------------------------- + + /** + * Affected Rows + * + * @return int + */ + public function affected_rows() + { + return ibase_affected_rows($this->conn_id); + } + + // -------------------------------------------------------------------- + + /** + * Insert ID + * + * @param string $generator_name + * @param int $inc_by + * @return int + */ + public function insert_id($generator_name, $inc_by = 0) + { + //If a generator hasn't been used before it will return 0 + return ibase_gen_id('"'.$generator_name.'"', $inc_by); + } + + // -------------------------------------------------------------------- + + /** + * List table query + * + * Generates a platform-specific query string so that the table names can be fetched + * + * @param bool $prefix_limit + * @return string + */ + protected function _list_tables($prefix_limit = FALSE) + { + $sql = 'SELECT "RDB$RELATION_NAME" FROM "RDB$RELATIONS" WHERE "RDB$RELATION_NAME" NOT LIKE \'RDB$%\' AND "RDB$RELATION_NAME" NOT LIKE \'MON$%\''; + + if ($prefix_limit !== FALSE && $this->dbprefix !== '') + { + return $sql.' AND "RDB$RELATION_NAME" LIKE \''.$this->escape_like_str($this->dbprefix)."%' " + .sprintf($this->_like_escape_str, $this->_like_escape_chr); + } + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Show column query + * + * Generates a platform-specific query string so that the column names can be fetched + * + * @param string $table + * @return string + */ + protected function _list_columns($table = '') + { + return 'SELECT "RDB$FIELD_NAME" FROM "RDB$RELATION_FIELDS" WHERE "RDB$RELATION_NAME" = '.$this->escape($table); + } + + // -------------------------------------------------------------------- + + /** + * Returns an object with field data + * + * @param string $table + * @return array + */ + public function field_data($table = '') + { + if ($table === '') + { + return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; + } + + $sql = 'SELECT "rfields"."RDB$FIELD_NAME" AS "name", + CASE "fields"."RDB$FIELD_TYPE" + WHEN 7 THEN \'SMALLINT\' + WHEN 8 THEN \'INTEGER\' + WHEN 9 THEN \'QUAD\' + WHEN 10 THEN \'FLOAT\' + WHEN 11 THEN \'DFLOAT\' + WHEN 12 THEN \'DATE\' + WHEN 13 THEN \'TIME\' + WHEN 14 THEN \'CHAR\' + WHEN 16 THEN \'INT64\' + WHEN 27 THEN \'DOUBLE\' + WHEN 35 THEN \'TIMESTAMP\' + WHEN 37 THEN \'VARCHAR\' + WHEN 40 THEN \'CSTRING\' + WHEN 261 THEN \'BLOB\' + ELSE NULL + END AS "type", + "fields"."RDB$FIELD_LENGTH" AS "max_length", + "rfields"."RDB$DEFAULT_VALUE" AS "default" + FROM "RDB$RELATION_FIELDS" "rfields" + JOIN "RDB$FIELDS" "fields" ON "rfields"."RDB$FIELD_SOURCE" = "fields"."RDB$FIELD_NAME" + WHERE "rfields"."RDB$RELATION_NAME" = '.$this->escape($table).' + ORDER BY "rfields"."RDB$FIELD_POSITION"'; + + return (($query = $this->query($sql)) !== FALSE) + ? $query->result_object() + : FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Error + * + * Returns an array containing code and message of the last + * database error that has occured. + * + * @return array + */ + public function error() + { + return array('code' => ibase_errcode(), 'message' => ibase_errmsg()); + } + + // -------------------------------------------------------------------- + + /** + * Update statement + * + * Generates a platform-specific update string from the supplied data + * + * @param string $table + * @param array $values + * @return string + */ + protected function _update($table, $values) + { + $this->qb_limit = FALSE; + return parent::_update($table, $values); + } + + // -------------------------------------------------------------------- + + /** + * Truncate statement + * + * Generates a platform-specific truncate string from the supplied data + * + * If the database does not support the TRUNCATE statement, + * then this method maps to 'DELETE FROM table' + * + * @param string $table + * @return string + */ + protected function _truncate($table) + { + return 'DELETE FROM '.$table; + } + + // -------------------------------------------------------------------- + + /** + * Delete statement + * + * Generates a platform-specific delete string from the supplied data + * + * @param string $table + * @return string + */ + protected function _delete($table) + { + $this->qb_limit = FALSE; + return parent::_delete($table); + } + + // -------------------------------------------------------------------- + + /** + * LIMIT + * + * Generates a platform-specific LIMIT clause + * + * @param string $sql SQL Query + * @return string + */ + protected function _limit($sql) + { + // Limit clause depends on if Interbase or Firebird + if (stripos($this->version(), 'firebird') !== FALSE) + { + $select = 'FIRST '.$this->qb_limit + .($this->qb_offset ? ' SKIP '.$this->qb_offset : ''); + } + else + { + $select = 'ROWS ' + .($this->qb_offset ? $this->qb_offset.' TO '.($this->qb_limit + $this->qb_offset) : $this->qb_limit); + } + + return preg_replace('`SELECT`i', 'SELECT '.$select, $sql, 1); + } + + // -------------------------------------------------------------------- + + /** + * Close DB Connection + * + * @return void + */ + protected function _close() + { + ibase_close($this->conn_id); + } + +} + +/* End of file ibase_driver.php */ +/* Location: ./system/database/drivers/ibase/ibase_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/ibase/ibase_forge.php b/system/database/drivers/ibase/ibase_forge.php new file mode 100755 index 0000000..19ac86c --- /dev/null +++ b/system/database/drivers/ibase/ibase_forge.php @@ -0,0 +1,243 @@ + 'INTEGER', + 'INTEGER' => 'INT64', + 'FLOAT' => 'DOUBLE PRECISION' + ); + + /** + * NULL value representation in CREATE/ALTER TABLE statements + * + * @var string + */ + protected $_null = 'NULL'; + + // -------------------------------------------------------------------- + + /** + * Create database + * + * @param string $db_name + * @return string + */ + public function create_database($db_name) + { + // Firebird databases are flat files, so a path is required + + // Hostname is needed for remote access + empty($this->db->hostname) OR $db_name = $this->hostname.':'.$db_name; + + return parent::create_database('"'.$db_name.'"'); + } + + // -------------------------------------------------------------------- + + /** + * Drop database + * + * @param string $db_name (ignored) + * @return bool + */ + public function drop_database($db_name = '') + { + if ( ! ibase_drop_db($this->conn_id)) + { + return ($this->db->db_debug) ? $this->db->display_error('db_unable_to_drop') : FALSE; + } + elseif ( ! empty($this->db->data_cache['db_names'])) + { + $key = array_search(strtolower($this->db->database), array_map('strtolower', $this->db->data_cache['db_names']), TRUE); + if ($key !== FALSE) + { + unset($this->db->data_cache['db_names'][$key]); + } + } + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * ALTER TABLE + * + * @param string $alter_type ALTER type + * @param string $table Table name + * @param mixed $field Column definition + * @return string|string[] + */ + protected function _alter_table($alter_type, $table, $field) + { + if (in_array($alter_type, array('DROP', 'ADD'), TRUE)) + { + return parent::_alter_table($alter_type, $table, $field); + } + + $sql = 'ALTER TABLE '.$this->db->escape_identifiers($table); + $sqls = array(); + for ($i = 0, $c = count($field); $i < $c; $i++) + { + if ($field[$i]['_literal'] !== FALSE) + { + return FALSE; + } + + if (isset($field[$i]['type'])) + { + $sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identififers($field[$i]['name']) + .' TYPE '.$field[$i]['type'].$field[$i]['length']; + } + + if ( ! empty($field[$i]['default'])) + { + $sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identifiers($field[$i]['name']) + .' SET DEFAULT '.$field[$i]['default']; + } + + if (isset($field[$i]['null'])) + { + $sqls[] = 'UPDATE "RDB$RELATION_FIELDS" SET "RDB$NULL_FLAG" = ' + .($field[$i]['null'] === TRUE ? 'NULL' : '1') + .' WHERE "RDB$FIELD_NAME" = '.$this->db->escape($field[$i]['name']) + .' AND "RDB$RELATION_NAME" = '.$this->db->escape($table); + } + + if ( ! empty($field[$i]['new_name'])) + { + $sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identifiers($field[$i]['name']) + .' TO '.$this->db->escape_identifiers($field[$i]['new_name']); + } + } + + return $sqls; + } + + // -------------------------------------------------------------------- + + /** + * Process column + * + * @param array $field + * @return string + */ + protected function _process_column($field) + { + return $this->db->escape_identifiers($field['name']) + .' '.$field['type'].$field['length'] + .$field['null'] + .$field['unique'] + .$field['default']; + } + + // -------------------------------------------------------------------- + + /** + * Field attribute TYPE + * + * Performs a data type mapping between different databases. + * + * @param array &$attributes + * @return void + */ + protected function _attr_type(&$attributes) + { + switch (strtoupper($attributes['TYPE'])) + { + case 'TINYINT': + $attributes['TYPE'] = 'SMALLINT'; + $attributes['UNSIGNED'] = FALSE; + return; + case 'MEDIUMINT': + $attributes['TYPE'] = 'INTEGER'; + $attributes['UNSIGNED'] = FALSE; + return; + case 'INT': + $attributes['TYPE'] = 'INTEGER'; + return; + case 'BIGINT': + $attributes['TYPE'] = 'INT64'; + return; + default: return; + } + } + + // -------------------------------------------------------------------- + + /** + * Field attribute AUTO_INCREMENT + * + * @param array &$attributes + * @param array &$field + * @return void + */ + protected function _attr_auto_increment(&$attributes, &$field) + { + // Not supported + } + +} + +/* End of file ibase_forge.php */ +/* Location: ./system/database/drivers/ibase/ibase_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/ibase/ibase_result.php b/system/database/drivers/ibase/ibase_result.php new file mode 100755 index 0000000..cb2c7f4 --- /dev/null +++ b/system/database/drivers/ibase/ibase_result.php @@ -0,0 +1,154 @@ +result_id); + } + + // -------------------------------------------------------------------- + + /** + * Fetch Field Names + * + * Generates an array of column names + * + * @return array + */ + public function list_fields() + { + $field_names = array(); + for ($i = 0, $num_fields = $this->num_fields(); $i < $num_fields; $i++) + { + $info = ibase_field_info($this->result_id, $i); + $field_names[] = $info['name']; + } + + return $field_names; + } + + // -------------------------------------------------------------------- + + /** + * Field data + * + * Generates an array of objects containing field meta-data + * + * @return array + */ + public function field_data() + { + $retval = array(); + for ($i = 0, $c = $this->num_fields(); $i < $c; $i++) + { + $info = ibase_field_info($this->result_id, $i); + + $retval[$i] = new stdClass(); + $retval[$i]->name = $info['name']; + $retval[$i]->type = $info['type']; + $retval[$i]->max_length = $info['length']; + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Free the result + * + * @return void + */ + public function free_result() + { + ibase_free_result($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Result - associative array + * + * Returns the result set as an array + * + * @return array + */ + protected function _fetch_assoc() + { + return ibase_fetch_assoc($this->result_id, IBASE_FETCH_BLOBS); + } + + // -------------------------------------------------------------------- + + /** + * Result - object + * + * Returns the result set as an object + * + * @param string $class_name + * @return object + */ + protected function _fetch_object($class_name = 'stdClass') + { + $row = ibase_fetch_object($this->result_id, IBASE_FETCH_BLOBS); + + if ($class_name === 'stdClass' OR ! $row) + { + return $row; + } + + $class_name = new $class_name(); + foreach ($row as $key => $value) + { + $class_name->$key = $value; + } + + return $class_name; + } + +} + +/* End of file ibase_result.php */ +/* Location: ./system/database/drivers/ibase/ibase_result.php */ \ No newline at end of file diff --git a/system/database/drivers/ibase/ibase_utility.php b/system/database/drivers/ibase/ibase_utility.php new file mode 100755 index 0000000..a17b19e --- /dev/null +++ b/system/database/drivers/ibase/ibase_utility.php @@ -0,0 +1,61 @@ +db->hostname, $this->db->username, $this->db->password)) + { + $res = ibase_backup($service, $this->db->database, $filename.'.fbk'); + + // Close the service connection + ibase_service_detach($service); + return $res; + } + + return FALSE; + } + +} + +/* End of file ibase_utility.php */ +/* Location: ./system/database/drivers/ibase/ibase_utility.php */ \ No newline at end of file diff --git a/system/database/drivers/ibase/index.html b/system/database/drivers/ibase/index.html new file mode 100755 index 0000000..c942a79 --- /dev/null +++ b/system/database/drivers/ibase/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

    Directory access is forbidden.

    + + + \ No newline at end of file diff --git a/system/database/drivers/index.html b/system/database/drivers/index.html new file mode 100755 index 0000000..c942a79 --- /dev/null +++ b/system/database/drivers/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

    Directory access is forbidden.

    + + + \ No newline at end of file diff --git a/system/database/drivers/mssql/index.html b/system/database/drivers/mssql/index.html new file mode 100755 index 0000000..c942a79 --- /dev/null +++ b/system/database/drivers/mssql/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

    Directory access is forbidden.

    + + + \ No newline at end of file diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php new file mode 100755 index 0000000..f4a1661 --- /dev/null +++ b/system/database/drivers/mssql/mssql_driver.php @@ -0,0 +1,528 @@ +port)) + { + $this->hostname .= (DIRECTORY_SEPARATOR === '\\' ? ',' : ':').$this->port; + } + } + + // -------------------------------------------------------------------- + + /** + * Non-persistent database connection + * + * @param bool $persistent + * @return resource + */ + public function db_connect($persistent = FALSE) + { + $this->conn_id = ($persistent) + ? mssql_pconnect($this->hostname, $this->username, $this->password) + : mssql_connect($this->hostname, $this->username, $this->password); + + if ( ! $this->conn_id) + { + return FALSE; + } + + // ---------------------------------------------------------------- + + // Select the DB... assuming a database name is specified in the config file + if ($this->database !== '' && ! $this->db_select()) + { + log_message('error', 'Unable to select database: '.$this->database); + + return ($this->db_debug === TRUE) + ? $this->display_error('db_unable_to_select', $this->database) + : FALSE; + } + + // Determine how identifiers are escaped + $query = $this->query('SELECT CASE WHEN (@@OPTIONS | 256) = @@OPTIONS THEN 1 ELSE 0 END AS qi'); + $query = $query->row_array(); + $this->_quoted_identifier = empty($query) ? FALSE : (bool) $query['qi']; + $this->_escape_char = ($this->_quoted_identifier) ? '"' : array('[', ']'); + + return $this->conn_id; + } + + // -------------------------------------------------------------------- + + /** + * Select the database + * + * @param string $database + * @return bool + */ + public function db_select($database = '') + { + if ($database === '') + { + $database = $this->database; + } + + // Note: Escaping is required in the event that the DB name + // contains reserved characters + if (mssql_select_db($this->escape_identifiers($database), $this->conn_id)) + { + $this->database = $database; + return TRUE; + } + + return FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Execute the query + * + * @param string $sql an SQL query + * @return mixed resource if rows are returned, bool otherwise + */ + protected function _execute($sql) + { + return mssql_query($sql, $this->conn_id); + } + + // -------------------------------------------------------------------- + + /** + * Begin Transaction + * + * @param bool $test_mode + * @return bool + */ + public function trans_begin($test_mode = FALSE) + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $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); + + return $this->simple_query('BEGIN TRAN'); + } + + // -------------------------------------------------------------------- + + /** + * Commit Transaction + * + * @return bool + */ + public function trans_commit() + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $this->_trans_depth > 0) + { + return TRUE; + } + + return $this->simple_query('COMMIT TRAN'); + } + + // -------------------------------------------------------------------- + + /** + * Rollback Transaction + * + * @return bool + */ + public function trans_rollback() + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $this->_trans_depth > 0) + { + return TRUE; + } + + return $this->simple_query('ROLLBACK TRAN'); + } + + // -------------------------------------------------------------------- + + /** + * Affected Rows + * + * @return int + */ + public function affected_rows() + { + return mssql_rows_affected($this->conn_id); + } + + // -------------------------------------------------------------------- + + /** + * Insert ID + * + * Returns the last id created in the Identity column. + * + * @return string + */ + public function insert_id() + { + $query = version_compare($this->version(), '8', '>=') + ? 'SELECT SCOPE_IDENTITY() AS last_id' + : 'SELECT @@IDENTITY AS last_id'; + + $query = $this->query($query); + $query = $query->row(); + return $query->last_id; + } + + // -------------------------------------------------------------------- + + /** + * Set client character set + * + * @param string $charset + * @return bool + */ + protected function _db_set_charset($charset) + { + return (ini_set('mssql.charset', $charset) !== FALSE); + } + + // -------------------------------------------------------------------- + + /** + * Version number query string + * + * @return string + */ + protected function _version() + { + return 'SELECT @@VERSION AS ver'; + } + + // -------------------------------------------------------------------- + + /** + * List table query + * + * Generates a platform-specific query string so that the table names can be fetched + * + * @param bool $prefix_limit + * @return string + */ + protected function _list_tables($prefix_limit = FALSE) + { + $sql = 'SELECT '.$this->escape_identifiers('name') + .' FROM '.$this->escape_identifiers('sysobjects') + .' WHERE '.$this->escape_identifiers('type')." = 'U'"; + + if ($prefix_limit !== FALSE && $this->dbprefix !== '') + { + $sql .= ' AND '.$this->escape_identifiers('name')." LIKE '".$this->escape_like_str($this->dbprefix)."%' " + .sprintf($this->_like_escape_str, $this->_like_escape_chr); + } + + return $sql.' ORDER BY '.$this->escape_identifiers('name'); + } + + // -------------------------------------------------------------------- + + /** + * List column query + * + * Generates a platform-specific query string so that the column names can be fetched + * + * @param string $table + * @return string + */ + protected function _list_columns($table = '') + { + return 'SELECT COLUMN_NAME + FROM INFORMATION_SCHEMA.Columns + WHERE UPPER(TABLE_NAME) = '.$this->escape(strtoupper($table)); + } + + // -------------------------------------------------------------------- + + /** + * Returns an object with field data + * + * @param string $table + * @return array + */ + public function field_data($table = '') + { + if ($table === '') + { + return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; + } + + $sql = 'SELECT COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, NUMERIC_PRECISION, COLUMN_DEFAULT + FROM INFORMATION_SCHEMA.Columns + WHERE UPPER(TABLE_NAME) = '.$this->escape(strtoupper($table)); + + if (($query = $this->query($sql)) === FALSE) + { + return FALSE; + } + $query = $query->result_object(); + + $retval = array(); + for ($i = 0, $c = count($query); $i < $c; $i++) + { + $retval[$i] = new stdClass(); + $retval[$i]->name = $query[$i]->COLUMN_NAME; + $retval[$i]->type = $query[$i]->DATA_TYPE; + $retval[$i]->max_length = ($query[$i]->CHARACTER_MAXIMUM_LENGTH > 0) ? $query[$i]->CHARACTER_MAXIMUM_LENGTH : $query[$i]->NUMERIC_PRECISION; + $retval[$i]->default = $query[$i]->COLUMN_DEFAULT; + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Error + * + * Returns an array containing code and message of the last + * database error that has occured. + * + * @return array + */ + public function error() + { + $query = $this->query('SELECT @@ERROR AS code'); + $query = $query->row(); + return array('code' => $query->code, 'message' => mssql_get_last_message()); + } + + // -------------------------------------------------------------------- + + /** + * Update statement + * + * Generates a platform-specific update string from the supplied data + * + * @param string $table + * @param array $values + * @return string + */ + protected function _update($table, $values) + { + $this->qb_limit = FALSE; + $this->qb_orderby = array(); + return parent::_update($table, $values); + } + + // -------------------------------------------------------------------- + + /** + * Truncate statement + * + * Generates a platform-specific truncate string from the supplied data + * + * If the database does not support the TRUNCATE statement, + * then this method maps to 'DELETE FROM table' + * + * @param string $table + * @return string + */ + protected function _truncate($table) + { + return 'TRUNCATE TABLE '.$table; + } + + // -------------------------------------------------------------------- + + /** + * Delete statement + * + * Generates a platform-specific delete string from the supplied data + * + * @param string $table + * @return string + */ + protected function _delete($table) + { + if ($this->qb_limit) + { + return 'WITH ci_delete AS (SELECT TOP '.$this->qb_limit.' * FROM '.$table.$this->_compile_wh('qb_where').') DELETE FROM ci_delete'; + } + + return parent::_delete($table); + } + + // -------------------------------------------------------------------- + + /** + * LIMIT + * + * Generates a platform-specific LIMIT clause + * + * @param string $sql SQL Query + * @return string + */ + protected function _limit($sql) + { + $limit = $this->qb_offset + $this->qb_limit; + + // As of SQL Server 2005 (9.0.*) ROW_NUMBER() is supported, + // however an ORDER BY clause is required for it to work + if (version_compare($this->version(), '9', '>=') && $this->qb_offset && ! empty($this->qb_orderby)) + { + $orderby = $this->_compile_order_by(); + + // We have to strip the ORDER BY clause + $sql = trim(substr($sql, 0, strrpos($sql, $orderby))); + + // Get the fields to select from our subquery, so that we can avoid CI_rownum appearing in the actual results + if (count($this->qb_select) === 0) + { + $select = '*'; // Inevitable + } + else + { + // Use only field names and their aliases, everything else is out of our scope. + $select = array(); + $field_regexp = ($this->_quoted_identifier) + ? '("[^\"]+")' : '(\[[^\]]+\])'; + for ($i = 0, $c = count($this->qb_select); $i < $c; $i++) + { + $select[] = preg_match('/(?:\s|\.)'.$field_regexp.'$/i', $this->qb_select[$i], $m) + ? $m[1] : $this->qb_select[$i]; + } + $select = implode(', ', $select); + } + + return 'SELECT '.$select." FROM (\n\n" + .preg_replace('/^(SELECT( DISTINCT)?)/i', '\\1 ROW_NUMBER() OVER('.trim($orderby).') AS '.$this->escape_identifiers('CI_rownum').', ', $sql) + ."\n\n) ".$this->escape_identifiers('CI_subquery') + ."\nWHERE ".$this->escape_identifiers('CI_rownum').' BETWEEN '.($this->qb_offset + 1).' AND '.$limit; + } + + return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$limit.' ', $sql); + } + + // -------------------------------------------------------------------- + + /** + * Insert batch statement + * + * Generates a platform-specific insert string from the supplied data. + * + * @param string $table Table name + * @param array $keys INSERT keys + * @param array $values INSERT values + * @return string|bool + */ + protected function _insert_batch($table, $keys, $values) + { + // Multiple-value inserts are only supported as of SQL Server 2008 + if (version_compare($this->version(), '10', '>=')) + { + return parent::_insert_batch($table, $keys, $values); + } + + return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Close DB Connection + * + * @return void + */ + protected function _close() + { + mssql_close($this->conn_id); + } + +} + +/* End of file mssql_driver.php */ +/* Location: ./system/database/drivers/mssql/mssql_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/mssql/mssql_forge.php b/system/database/drivers/mssql/mssql_forge.php new file mode 100755 index 0000000..eeb01ba --- /dev/null +++ b/system/database/drivers/mssql/mssql_forge.php @@ -0,0 +1,136 @@ + 'SMALLINT', + 'SMALLINT' => 'INT', + 'INT' => 'BIGINT', + 'REAL' => 'FLOAT' + ); + + // -------------------------------------------------------------------- + + /** + * ALTER TABLE + * + * @param string $alter_type ALTER type + * @param string $table Table name + * @param mixed $field Column definition + * @return string|string[] + */ + protected function _alter_table($alter_type, $table, $field) + { + if (in_array($alter_type, array('ADD', 'DROP'), TRUE)) + { + return parent::_alter_table($alter_type, $table, $field); + } + + $sql = 'ALTER TABLE '.$this->db->escape_identifiers($table).' ALTER COLUMN '; + $sqls = array(); + for ($i = 0, $c = count($field); $i < $c; $i++) + { + $sqls[] = $sql.$this->_process_column($field[$i]); + } + + return $sqls; + } + + // -------------------------------------------------------------------- + + /** + * Field attribute TYPE + * + * Performs a data type mapping between different databases. + * + * @param array &$attributes + * @return void + */ + protected function _attr_type(&$attributes) + { + switch (strtoupper($attributes['TYPE'])) + { + case 'MEDIUMINT': + $attributes['TYPE'] = 'INTEGER'; + $attributes['UNSIGNED'] = FALSE; + return; + case 'INTEGER': + $attributes['TYPE'] = 'INT'; + return; + default: return; + } + } + + // -------------------------------------------------------------------- + + /** + * Field attribute AUTO_INCREMENT + * + * @param array &$attributes + * @param array &$field + * @return void + */ + protected function _attr_auto_increment(&$attributes, &$field) + { + if ( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE && stripos($field['type'], 'int') !== FALSE) + { + $field['auto_increment'] = ' IDENTITY(1,1)'; + } + } + +} + +/* End of file mssql_forge.php */ +/* Location: ./system/database/drivers/mssql/mssql_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/mssql/mssql_result.php b/system/database/drivers/mssql/mssql_result.php new file mode 100755 index 0000000..f3ee987 --- /dev/null +++ b/system/database/drivers/mssql/mssql_result.php @@ -0,0 +1,189 @@ +num_rows) + ? $this->num_rows + : $this->num_rows = mssql_num_rows($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Number of fields in the result set + * + * @return int + */ + public function num_fields() + { + return mssql_num_fields($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Fetch Field Names + * + * Generates an array of column names + * + * @return array + */ + public function list_fields() + { + $field_names = array(); + mssql_field_seek($this->result_id, 0); + while ($field = mssql_fetch_field($this->result_id)) + { + $field_names[] = $field->name; + } + + return $field_names; + } + + // -------------------------------------------------------------------- + + /** + * Field data + * + * Generates an array of objects containing field meta-data + * + * @return array + */ + public function field_data() + { + $retval = array(); + for ($i = 0, $c = $this->num_field(); $i < $c; $i++) + { + $field = mssql_fetch_field($this->result_id, $i); + + $retval[$i] = new stdClass(); + $retval[$i]->name = $field->name; + $retval[$i]->type = $field->type; + $retval[$i]->max_length = $field->max_length; + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Free the result + * + * @return void + */ + public function free_result() + { + if (is_resource($this->result_id)) + { + mssql_free_result($this->result_id); + $this->result_id = FALSE; + } + } + + // -------------------------------------------------------------------- + + /** + * Data Seek + * + * Moves the internal pointer to the desired offset. We call + * this internally before fetching results to make sure the + * result set starts at zero. + * + * @param int $n + * @return bool + */ + public function data_seek($n = 0) + { + return mssql_data_seek($this->result_id, $n); + } + + // -------------------------------------------------------------------- + + /** + * Result - associative array + * + * Returns the result set as an array + * + * @return array + */ + protected function _fetch_assoc() + { + return mssql_fetch_assoc($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Result - object + * + * Returns the result set as an object + * + * @param string $class_name + * @return object + */ + protected function _fetch_object($class_name = 'stdClass') + { + $row = mssql_fetch_object($this->result_id); + + if ($class_name === 'stdClass' OR ! $row) + { + return $row; + } + + $class_name = new $class_name(); + foreach ($row as $key => $value) + { + $class_name->$key = $value; + } + + return $class_name; + } + +} + +/* End of file mssql_result.php */ +/* Location: ./system/database/drivers/mssql/mssql_result.php */ \ No newline at end of file diff --git a/system/database/drivers/mssql/mssql_utility.php b/system/database/drivers/mssql/mssql_utility.php new file mode 100755 index 0000000..97212bd --- /dev/null +++ b/system/database/drivers/mssql/mssql_utility.php @@ -0,0 +1,67 @@ +db->display_error('db_unsupported_feature'); + } + +} + +/* 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 new file mode 100755 index 0000000..c942a79 --- /dev/null +++ b/system/database/drivers/mysql/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

    Directory access is forbidden.

    + + + \ No newline at end of file diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php new file mode 100755 index 0000000..7cbcf10 --- /dev/null +++ b/system/database/drivers/mysql/mysql_driver.php @@ -0,0 +1,496 @@ +port)) + { + $this->hostname .= ':'.$this->port; + } + } + + // -------------------------------------------------------------------- + + /** + * Non-persistent database connection + * + * @param bool $persistent + * @return resource + */ + public function db_connect($persistent = FALSE) + { + $client_flags = ($this->compress === FALSE) ? 0 : MYSQL_CLIENT_COMPRESS; + + if ($this->encrypt === TRUE) + { + $client_flags = $client_flags | MYSQL_CLIENT_SSL; + } + + // Error suppression is necessary mostly due to PHP 5.5+ issuing E_DEPRECATED messages + $this->conn_id = ($persistent === TRUE) + ? @mysql_pconnect($this->hostname, $this->username, $this->password, $client_flags) + : @mysql_connect($this->hostname, $this->username, $this->password, TRUE, $client_flags); + + // ---------------------------------------------------------------- + + // Select the DB... assuming a database name is specified in the config file + if ($this->database !== '' && ! $this->db_select()) + { + log_message('error', 'Unable to select database: '.$this->database); + + return ($this->db_debug === TRUE) + ? $this->display_error('db_unable_to_select', $this->database) + : FALSE; + } + + if ($this->stricton && is_resource($this->conn_id)) + { + $this->simple_query('SET SESSION sql_mode="STRICT_ALL_TABLES"'); + } + + return $this->conn_id; + } + + // -------------------------------------------------------------------- + + /** + * Reconnect + * + * Keep / reestablish the db connection if no queries have been + * sent for a length of time exceeding the server's idle timeout + * + * @return void + */ + public function reconnect() + { + if (mysql_ping($this->conn_id) === FALSE) + { + $this->conn_id = FALSE; + } + } + + // -------------------------------------------------------------------- + + /** + * Select the database + * + * @param string $database + * @return bool + */ + public function db_select($database = '') + { + if ($database === '') + { + $database = $this->database; + } + + if (mysql_select_db($database, $this->conn_id)) + { + $this->database = $database; + return TRUE; + } + + return FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Set client character set + * + * @param string $charset + * @return bool + */ + protected function _db_set_charset($charset) + { + return mysql_set_charset($charset, $this->conn_id); + } + + // -------------------------------------------------------------------- + + /** + * Database version number + * + * @return string + */ + public function version() + { + if (isset($this->data_cache['version'])) + { + return $this->data_cache['version']; + } + elseif ( ! $this->conn_id) + { + $this->initialize(); + } + + if ( ! $this->conn_id OR ($version = mysql_get_server_info($this->conn_id)) === FALSE) + { + return FALSE; + } + + return $this->data_cache['version'] = $version; + } + + // -------------------------------------------------------------------- + + /** + * Execute the query + * + * @param string $sql an SQL query + * @return mixed + */ + protected function _execute($sql) + { + return mysql_query($this->_prep_query($sql), $this->conn_id); + } + + // -------------------------------------------------------------------- + + /** + * Prep the query + * + * If needed, each database adapter can prep the query string + * + * @param string $sql an SQL query + * @return string + */ + protected function _prep_query($sql) + { + // mysql_affected_rows() returns 0 for "DELETE FROM TABLE" queries. This hack + // modifies the query so that it a proper number of affected rows is returned. + if ($this->delete_hack === TRUE && preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $sql)) + { + return trim($sql).' WHERE 1=1'; + } + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Begin Transaction + * + * @param bool $test_mode + * @return bool + */ + public function trans_begin($test_mode = FALSE) + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $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); + + $this->simple_query('SET AUTOCOMMIT=0'); + $this->simple_query('START TRANSACTION'); // can also be BEGIN or BEGIN WORK + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Commit Transaction + * + * @return bool + */ + public function trans_commit() + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $this->_trans_depth > 0) + { + return TRUE; + } + + $this->simple_query('COMMIT'); + $this->simple_query('SET AUTOCOMMIT=1'); + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Rollback Transaction + * + * @return bool + */ + public function trans_rollback() + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $this->_trans_depth > 0) + { + return TRUE; + } + + $this->simple_query('ROLLBACK'); + $this->simple_query('SET AUTOCOMMIT=1'); + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Platform-dependant string escape + * + * @param string + * @return string + */ + protected function _escape_str($str) + { + return is_resource($this->conn_id) + ? mysql_real_escape_string($str, $this->conn_id) + : addslashes($str); + } + + // -------------------------------------------------------------------- + + /** + * Affected Rows + * + * @return int + */ + public function affected_rows() + { + return mysql_affected_rows($this->conn_id); + } + + // -------------------------------------------------------------------- + + /** + * Insert ID + * + * @return int + */ + public function insert_id() + { + return mysql_insert_id($this->conn_id); + } + + // -------------------------------------------------------------------- + + /** + * List table query + * + * Generates a platform-specific query string so that the table names can be fetched + * + * @param bool $prefix_limit + * @return string + */ + protected function _list_tables($prefix_limit = FALSE) + { + $sql = 'SHOW TABLES FROM '.$this->escape_identifiers($this->database); + + if ($prefix_limit !== FALSE && $this->dbprefix !== '') + { + return $sql." LIKE '".$this->escape_like_str($this->dbprefix)."%'"; + } + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Show column query + * + * Generates a platform-specific query string so that the column names can be fetched + * + * @param string $table + * @return string + */ + protected function _list_columns($table = '') + { + return 'SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE); + } + + // -------------------------------------------------------------------- + + /** + * Returns an object with field data + * + * @param string $table + * @return array + */ + public function field_data($table = '') + { + if ($table === '') + { + return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; + } + + if (($query = $this->query('SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE))) === FALSE) + { + return FALSE; + } + $query = $query->result_object(); + + $retval = array(); + for ($i = 0, $c = count($query); $i < $c; $i++) + { + $retval[$i] = new stdClass(); + $retval[$i]->name = $query[$i]->Field; + + sscanf($query[$i]->Type, '%[a-z](%d)', + $retval[$i]->type, + $retval[$i]->max_length + ); + + $retval[$i]->default = $query[$i]->Default; + $retval[$i]->primary_key = (int) ($query[$i]->Key === 'PRI'); + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Error + * + * Returns an array containing code and message of the last + * database error that has occured. + * + * @return array + */ + public function error() + { + return array('code' => mysql_errno($this->conn_id), 'message' => mysql_error($this->conn_id)); + } + + // -------------------------------------------------------------------- + + /** + * FROM tables + * + * Groups tables in FROM clauses if needed, so there is no confusion + * about operator precedence. + * + * @return string + */ + protected function _from_tables() + { + if ( ! empty($this->qb_join) && count($this->qb_from) > 1) + { + return '('.implode(', ', $this->qb_from).')'; + } + + return implode(', ', $this->qb_from); + } + + // -------------------------------------------------------------------- + + /** + * Close DB Connection + * + * @return void + */ + protected function _close() + { + // Error suppression to avoid annoying E_WARNINGs in cases + // where the connection has already been closed for some reason. + @mysql_close($this->conn_id); + } + +} + +/* End of file mysql_driver.php */ +/* Location: ./system/database/drivers/mysql/mysql_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/mysql/mysql_forge.php b/system/database/drivers/mysql/mysql_forge.php new file mode 100755 index 0000000..cc886e8 --- /dev/null +++ b/system/database/drivers/mysql/mysql_forge.php @@ -0,0 +1,233 @@ +db->char_set) && ! strpos($sql, 'CHARACTER SET') && ! strpos($sql, 'CHARSET')) + { + $sql .= ' DEFAULT CHARACTER SET = '.$this->db->char_set; + } + + if ( ! empty($this->db->dbcollat) && ! strpos($sql, 'COLLATE')) + { + $sql .= ' COLLATE = '.$this->db->dbcollat; + } + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * ALTER TABLE + * + * @param string $alter_type ALTER type + * @param string $table Table name + * @param mixed $field Column definition + * @return string|string[] + */ + protected function _alter_table($alter_type, $table, $field) + { + if ($alter_type === 'DROP') + { + return parent::_alter_table($alter_type, $table, $field); + } + + $sql = 'ALTER TABLE '.$this->db->escape_identifiers($table); + for ($i = 0, $c = count($field); $i < $c; $i++) + { + if ($field[$i]['_literal'] !== FALSE) + { + $field[$i] = ($alter_type === 'ADD') + ? "\n\tADD ".$field[$i]['_literal'] + : "\n\tMODIFY ".$field[$i]['_literal']; + } + else + { + if ($alter_type === 'ADD') + { + $field[$i]['_literal'] = "\n\tADD "; + } + else + { + $field[$i]['_literal'] = empty($field[$i]['new_name']) ? "\n\tMODIFY " : "\n\tCHANGE "; + } + + $field[$i] = $field[$i]['_literal'].$this->_process_column($field[$i]); + } + } + + return array($sql.implode(',', $field)); + } + + // -------------------------------------------------------------------- + + /** + * Process column + * + * @param array $field + * @return string + */ + protected function _process_column($field) + { + $extra_clause = isset($field['after']) + ? ' AFTER '.$this->db->escape_identifiers($field['after']) : ''; + + if (empty($extra_clause) && isset($field['first']) && $field['first'] === TRUE) + { + $extra_clause = ' FIRST'; + } + + return $this->db->escape_identifiers($field['name']) + .(empty($field['new_name']) ? '' : ' '.$this->db->escape_identifiers($field['new_name'])) + .' '.$field['type'].$field['length'] + .$field['unsigned'] + .$field['null'] + .$field['default'] + .$field['auto_increment'] + .$field['unique'] + .$extra_clause; + } + + // -------------------------------------------------------------------- + + /** + * Process indexes + * + * @param string $table (ignored) + * @return string + */ + protected function _process_indexes($table) + { + $sql = ''; + + for ($i = 0, $c = count($this->keys); $i < $c; $i++) + { + if (is_array($this->keys[$i])) + { + for ($i2 = 0, $c2 = count($this->keys[$i]); $i2 < $c2; $i2++) + { + if ( ! isset($this->fields[$this->keys[$i][$i2]])) + { + unset($this->keys[$i][$i2]); + continue; + } + } + } + elseif ( ! isset($this->fields[$this->keys[$i]])) + { + unset($this->keys[$i]); + continue; + } + + is_array($this->keys[$i]) OR $this->keys[$i] = array($this->keys[$i]); + + $sql .= ",\n\tKEY ".$this->db->escape_identifiers(implode('_', $this->keys[$i])) + .' ('.implode(', ', $this->db->escape_identifiers($this->keys[$i])).')'; + } + + $this->keys = array(); + + return $sql; + } + +} + +/* End of file mysql_forge.php */ +/* Location: ./system/database/drivers/mysql/mysql_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/mysql/mysql_result.php b/system/database/drivers/mysql/mysql_result.php new file mode 100755 index 0000000..68860e6 --- /dev/null +++ b/system/database/drivers/mysql/mysql_result.php @@ -0,0 +1,192 @@ +num_rows = mysql_num_rows($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Number of rows in the result set + * + * @return int + */ + public function num_rows() + { + return $this->num_rows; + } + + // -------------------------------------------------------------------- + + /** + * Number of fields in the result set + * + * @return int + */ + public function num_fields() + { + return mysql_num_fields($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Fetch Field Names + * + * Generates an array of column names + * + * @return array + */ + public function list_fields() + { + $field_names = array(); + mysql_field_seek($this->result_id, 0); + while ($field = mysql_fetch_field($this->result_id)) + { + $field_names[] = $field->name; + } + + return $field_names; + } + + // -------------------------------------------------------------------- + + /** + * Field data + * + * Generates an array of objects containing field meta-data + * + * @return array + */ + public function field_data() + { + $retval = array(); + for ($i = 0, $c = $this->num_fields(); $i < $c; $i++) + { + $retval[$i] = new stdClass(); + $retval[$i]->name = mysql_field_name($this->result_id, $i); + $retval[$i]->type = mysql_field_type($this->result_id, $i); + $retval[$i]->max_length = mysql_field_len($this->result_id, $i); + $retval[$i]->primary_key = (int) (strpos(mysql_field_flags($this->result_id, $i), 'primary_key') !== FALSE); + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Free the result + * + * @return void + */ + public function free_result() + { + if (is_resource($this->result_id)) + { + mysql_free_result($this->result_id); + $this->result_id = FALSE; + } + } + + // -------------------------------------------------------------------- + + /** + * Data Seek + * + * Moves the internal pointer to the desired offset. We call + * this internally before fetching results to make sure the + * result set starts at zero. + * + * @param int $n + * @return bool + */ + public function data_seek($n = 0) + { + return $this->num_rows + ? mysql_data_seek($this->result_id, $n) + : FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Result - associative array + * + * Returns the result set as an array + * + * @return array + */ + protected function _fetch_assoc() + { + return mysql_fetch_assoc($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Result - object + * + * Returns the result set as an object + * + * @param string $class_name + * @return object + */ + protected function _fetch_object($class_name = 'stdClass') + { + return mysql_fetch_object($this->result_id, $class_name); + } + +} + +/* End of file mysql_result.php */ +/* Location: ./system/database/drivers/mysql/mysql_result.php */ \ No newline at end of file diff --git a/system/database/drivers/mysql/mysql_utility.php b/system/database/drivers/mysql/mysql_utility.php new file mode 100755 index 0000000..91de871 --- /dev/null +++ b/system/database/drivers/mysql/mysql_utility.php @@ -0,0 +1,203 @@ +db->query('SHOW CREATE TABLE '.$this->db->escape_identifiers($this->db->database.'.'.$table)); + + // No result means the table name was invalid + if ($query === FALSE) + { + continue; + } + + // Write out the table schema + $output .= '#'.$newline.'# TABLE STRUCTURE FOR: '.$table.$newline.'#'.$newline.$newline; + + if ($add_drop === TRUE) + { + $output .= 'DROP TABLE IF EXISTS '.$this->db->protect_identifiers($table).';'.$newline.$newline; + } + + $i = 0; + $result = $query->result_array(); + foreach ($result[0] as $val) + { + if ($i++ % 2) + { + $output .= $val.';'.$newline.$newline; + } + } + + // If inserts are not needed we're done... + if ($add_insert === FALSE) + { + continue; + } + + // Grab all the data from the current table + $query = $this->db->query('SELECT * FROM '.$this->db->protect_identifiers($table)); + + if ($query->num_rows() === 0) + { + continue; + } + + // Fetch the field names and determine if the field is an + // integer type. We use this info to decide whether to + // surround the data with quotes or not + + $i = 0; + $field_str = ''; + $is_int = array(); + while ($field = mysql_fetch_field($query->result_id)) + { + // Most versions of MySQL store timestamp as a string + $is_int[$i] = in_array(strtolower(mysql_field_type($query->result_id, $i)), + array('tinyint', 'smallint', 'mediumint', 'int', 'bigint'), //, 'timestamp'), + TRUE); + + // Create a string of field names + $field_str .= $this->db->escape_identifiers($field->name).', '; + $i++; + } + + // Trim off the end comma + $field_str = preg_replace('/, $/' , '', $field_str); + + // Build the insert string + foreach ($query->result_array() as $row) + { + $val_str = ''; + + $i = 0; + foreach ($row as $v) + { + // Is the value NULL? + if ($v === NULL) + { + $val_str .= 'NULL'; + } + else + { + // Escape the data if it's not an integer + $val_str .= ($is_int[$i] === FALSE) ? $this->db->escape($v) : $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 '.$this->db->protect_identifiers($table).' ('.$field_str.') VALUES ('.$val_str.');'.$newline; + } + + $output .= $newline.$newline; + } + + // Do we need to include a statement to re-enable foreign key checks? + if ($foreign_key_checks === FALSE) + { + $output .= 'SET foreign_key_checks = 1;'.$newline; + } + + return $output; + } + +} + +/* End of file mysql_utility.php */ +/* Location: ./system/database/drivers/mysql/mysql_utility.php */ \ No newline at end of file diff --git a/system/database/drivers/mysqli/index.html b/system/database/drivers/mysqli/index.html new file mode 100755 index 0000000..c942a79 --- /dev/null +++ b/system/database/drivers/mysqli/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

    Directory access is forbidden.

    + + + \ No newline at end of file diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php new file mode 100755 index 0000000..09277fc --- /dev/null +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -0,0 +1,473 @@ +hostname : $this->hostname; + $port = empty($this->port) ? NULL : $this->port; + $client_flags = ($this->compress === TRUE) ? MYSQLI_CLIENT_COMPRESS : 0; + $mysqli = mysqli_init(); + + if ($this->stricton) + { + $mysqli->options(MYSQLI_INIT_COMMAND, 'SET SESSION sql_mode="STRICT_ALL_TABLES"'); + } + + return $mysqli->real_connect($hostname, $this->username, $this->password, $this->database, $port, NULL, $client_flags) + ? $mysqli : FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Reconnect + * + * Keep / reestablish the db connection if no queries have been + * sent for a length of time exceeding the server's idle timeout + * + * @return void + */ + public function reconnect() + { + if ($this->conn_id !== FALSE && $this->conn_id->ping() === FALSE) + { + $this->conn_id = FALSE; + } + } + + // -------------------------------------------------------------------- + + /** + * Select the database + * + * @param string $database + * @return bool + */ + public function db_select($database = '') + { + if ($database === '') + { + $database = $this->database; + } + + if ($this->conn_id->select_db($database)) + { + $this->database = $database; + return TRUE; + } + + return FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Set client character set + * + * @param string $charset + * @return bool + */ + protected function _db_set_charset($charset) + { + return $this->conn_id->set_charset($charset); + } + + // -------------------------------------------------------------------- + + /** + * Database version number + * + * @return string + */ + public function version() + { + if (isset($this->data_cache['version'])) + { + return $this->data_cache['version']; + } + elseif ( ! $this->conn_id) + { + $this->initialize(); + } + + return $this->data_cache['version'] = $this->conn_id->server_info; + } + + // -------------------------------------------------------------------- + + /** + * Execute the query + * + * @param string $sql an SQL query + * @return mixed + */ + protected function _execute($sql) + { + return $this->conn_id->query($this->_prep_query($sql)); + } + + // -------------------------------------------------------------------- + + /** + * Prep the query + * + * If needed, each database adapter can prep the query string + * + * @param string $sql an SQL query + * @return string + */ + protected function _prep_query($sql) + { + // mysqli_affected_rows() returns 0 for "DELETE FROM TABLE" queries. This hack + // modifies the query so that it a proper number of affected rows is returned. + if ($this->delete_hack === TRUE && preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $sql)) + { + return trim($sql).' WHERE 1=1'; + } + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Begin Transaction + * + * @param bool $test_mode + * @return bool + */ + public function trans_begin($test_mode = FALSE) + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $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); + + $this->conn_id->autocommit(FALSE); + return is_php('5.5') + ? $this->conn_id->begin_transaction() + : $this->simple_query('START TRANSACTION'); // can also be BEGIN or BEGIN WORK + } + + // -------------------------------------------------------------------- + + /** + * Commit Transaction + * + * @return bool + */ + public function trans_commit() + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $this->_trans_depth > 0) + { + return TRUE; + } + + if ($this->conn_id->commit()) + { + $this->conn_id->autocommit(TRUE); + return TRUE; + } + + return FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Rollback Transaction + * + * @return bool + */ + public function trans_rollback() + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $this->_trans_depth > 0) + { + return TRUE; + } + + if ($this->conn_id->rollback()) + { + $this->conn_id->autocommit(TRUE); + return TRUE; + } + + return FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Platform-dependant string escape + * + * @param string + * @return string + */ + protected function _escape_str($str) + { + return is_object($this->conn_id) + ? $this->conn_id->real_escape_string($str) + : addslashes($str); + } + + // -------------------------------------------------------------------- + + /** + * Affected Rows + * + * @return int + */ + public function affected_rows() + { + return $this->conn_id->affected_rows; + } + + // -------------------------------------------------------------------- + + /** + * Insert ID + * + * @return int + */ + public function insert_id() + { + return $this->conn_id->insert_id; + } + + // -------------------------------------------------------------------- + + /** + * List table query + * + * Generates a platform-specific query string so that the table names can be fetched + * + * @param bool $prefix_limit + * @return string + */ + protected function _list_tables($prefix_limit = FALSE) + { + $sql = 'SHOW TABLES FROM '.$this->escape_identifiers($this->database); + + if ($prefix_limit !== FALSE && $this->dbprefix !== '') + { + return $sql." LIKE '".$this->escape_like_str($this->dbprefix)."%'"; + } + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Show column query + * + * Generates a platform-specific query string so that the column names can be fetched + * + * @param string $table + * @return string + */ + protected function _list_columns($table = '') + { + return 'SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE); + } + + // -------------------------------------------------------------------- + + /** + * Returns an object with field data + * + * @param string $table + * @return array + */ + public function field_data($table = '') + { + if ($table === '') + { + return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; + } + + if (($query = $this->query('SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE))) === FALSE) + { + return FALSE; + } + $query = $query->result_object(); + + $retval = array(); + for ($i = 0, $c = count($query); $i < $c; $i++) + { + $retval[$i] = new stdClass(); + $retval[$i]->name = $query[$i]->Field; + + sscanf($query[$i]->Type, '%[a-z](%d)', + $retval[$i]->type, + $retval[$i]->max_length + ); + + $retval[$i]->default = $query[$i]->Default; + $retval[$i]->primary_key = (int) ($query[$i]->Key === 'PRI'); + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Error + * + * Returns an array containing code and message of the last + * database error that has occured. + * + * @return array + */ + public function error() + { + if ( ! empty($this->conn_id->connect_errno)) + { + return array( + 'code' => $this->conn_id->connect_errno, + 'message' => is_php('5.2.9') ? $this->conn_id->connect_error : mysqli_connect_error() + ); + } + + return array('code' => $this->conn_id->errno, 'message' => $this->conn_id->error); + } + + // -------------------------------------------------------------------- + + /** + * FROM tables + * + * Groups tables in FROM clauses if needed, so there is no confusion + * about operator precedence. + * + * @return string + */ + protected function _from_tables() + { + if ( ! empty($this->qb_join) && count($this->qb_from) > 1) + { + return '('.implode(', ', $this->qb_from).')'; + } + + return implode(', ', $this->qb_from); + } + + // -------------------------------------------------------------------- + + /** + * Close DB Connection + * + * @return void + */ + protected function _close() + { + $this->conn_id->close(); + } + +} + +/* End of file mysqli_driver.php */ +/* Location: ./system/database/drivers/mysqli/mysqli_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/mysqli/mysqli_forge.php b/system/database/drivers/mysqli/mysqli_forge.php new file mode 100755 index 0000000..3a19405 --- /dev/null +++ b/system/database/drivers/mysqli/mysqli_forge.php @@ -0,0 +1,233 @@ +db->char_set) && ! strpos($sql, 'CHARACTER SET') && ! strpos($sql, 'CHARSET')) + { + $sql .= ' DEFAULT CHARACTER SET = '.$this->db->char_set; + } + + if ( ! empty($this->db->dbcollat) && ! strpos($sql, 'COLLATE')) + { + $sql .= ' COLLATE = '.$this->db->dbcollat; + } + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * ALTER TABLE + * + * @param string $alter_type ALTER type + * @param string $table Table name + * @param mixed $field Column definition + * @return string|string[] + */ + protected function _alter_table($alter_type, $table, $field) + { + if ($alter_type === 'DROP') + { + return parent::_alter_table($alter_type, $table, $field); + } + + $sql = 'ALTER TABLE '.$this->db->escape_identifiers($table); + for ($i = 0, $c = count($field); $i < $c; $i++) + { + if ($field[$i]['_literal'] !== FALSE) + { + $field[$i] = ($alter_type === 'ADD') + ? "\n\tADD ".$field[$i]['_literal'] + : "\n\tMODIFY ".$field[$i]['_literal']; + } + else + { + if ($alter_type === 'ADD') + { + $field[$i]['_literal'] = "\n\tADD "; + } + else + { + $field[$i]['_literal'] = empty($field[$i]['new_name']) ? "\n\tMODIFY " : "\n\tCHANGE "; + } + + $field[$i] = $field[$i]['_literal'].$this->_process_column($field[$i]); + } + } + + return array($sql.implode(',', $field)); + } + + // -------------------------------------------------------------------- + + /** + * Process column + * + * @param array $field + * @return string + */ + protected function _process_column($field) + { + $extra_clause = isset($field['after']) + ? ' AFTER '.$this->db->escape_identifiers($field['after']) : ''; + + if (empty($extra_clause) && isset($field['first']) && $field['first'] === TRUE) + { + $extra_clause = ' FIRST'; + } + + return $this->db->escape_identifiers($field['name']) + .(empty($field['new_name']) ? '' : ' '.$this->db->escape_identifiers($field['new_name'])) + .' '.$field['type'].$field['length'] + .$field['unsigned'] + .$field['null'] + .$field['default'] + .$field['auto_increment'] + .$field['unique'] + .$extra_clause; + } + + // -------------------------------------------------------------------- + + /** + * Process indexes + * + * @param string $table (ignored) + * @return string + */ + protected function _process_indexes($table) + { + $sql = ''; + + for ($i = 0, $c = count($this->keys); $i < $c; $i++) + { + if (is_array($this->keys[$i])) + { + for ($i2 = 0, $c2 = count($this->keys[$i]); $i2 < $c2; $i2++) + { + if ( ! isset($this->fields[$this->keys[$i][$i2]])) + { + unset($this->keys[$i][$i2]); + continue; + } + } + } + elseif ( ! isset($this->fields[$this->keys[$i]])) + { + unset($this->keys[$i]); + continue; + } + + is_array($this->keys[$i]) OR $this->keys[$i] = array($this->keys[$i]); + + $sql .= ",\n\tKEY ".$this->db->escape_identifiers(implode('_', $this->keys[$i])) + .' ('.implode(', ', $this->db->escape_identifiers($this->keys[$i])).')'; + } + + $this->keys = array(); + + return $sql; + } + +} + +/* End of file mysqli_forge.php */ +/* Location: ./system/database/drivers/mysqli/mysqli_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/mysqli/mysqli_result.php b/system/database/drivers/mysqli/mysqli_result.php new file mode 100755 index 0000000..7f5792a --- /dev/null +++ b/system/database/drivers/mysqli/mysqli_result.php @@ -0,0 +1,177 @@ +num_rows) + ? $this->num_rows + : $this->num_rows = $this->result_id->num_rows; + } + + // -------------------------------------------------------------------- + + /** + * Number of fields in the result set + * + * @return int + */ + public function num_fields() + { + return $this->result_id->field_count; + } + + // -------------------------------------------------------------------- + + /** + * Fetch Field Names + * + * Generates an array of column names + * + * @return array + */ + public function list_fields() + { + $field_names = array(); + $this->result_id->field_seek(0); + while ($field = $this->result_id->fetch_field()) + { + $field_names[] = $field->name; + } + + return $field_names; + } + + // -------------------------------------------------------------------- + + /** + * Field data + * + * Generates an array of objects containing field meta-data + * + * @return array + */ + public function field_data() + { + $retval = array(); + $field_data = $this->result_id->fetch_fields(); + for ($i = 0, $c = count($field_data); $i < $c; $i++) + { + $retval[$i] = new stdClass(); + $retval[$i]->name = $field_data[$i]->name; + $retval[$i]->type = $field_data[$i]->type; + $retval[$i]->max_length = $field_data[$i]->max_length; + $retval[$i]->primary_key = (int) ($field_data[$i]->flags & 2); + $retval[$i]->default = $field_data[$i]->def; + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Free the result + * + * @return void + */ + public function free_result() + { + if (is_object($this->result_id)) + { + $this->result_id->free(); + $this->result_id = FALSE; + } + } + + // -------------------------------------------------------------------- + + /** + * Data Seek + * + * Moves the internal pointer to the desired offset. We call + * this internally before fetching results to make sure the + * result set starts at zero. + * + * @param int $n + * @return bool + */ + public function data_seek($n = 0) + { + return $this->result_id->data_seek($n); + } + + // -------------------------------------------------------------------- + + /** + * Result - associative array + * + * Returns the result set as an array + * + * @return array + */ + protected function _fetch_assoc() + { + return $this->result_id->fetch_assoc(); + } + + // -------------------------------------------------------------------- + + /** + * Result - object + * + * Returns the result set as an object + * + * @param string $class_name + * @return object + */ + protected function _fetch_object($class_name = 'stdClass') + { + return $this->result_id->fetch_object($class_name); + } + +} + +/* End of file mysqli_result.php */ +/* Location: ./system/database/drivers/mysqli/mysqli_result.php */ \ No newline at end of file diff --git a/system/database/drivers/mysqli/mysqli_utility.php b/system/database/drivers/mysqli/mysqli_utility.php new file mode 100755 index 0000000..1c94757 --- /dev/null +++ b/system/database/drivers/mysqli/mysqli_utility.php @@ -0,0 +1,203 @@ +db->query('SHOW CREATE TABLE '.$this->db->escape_identifiers($this->db->database.'.'.$table)); + + // No result means the table name was invalid + if ($query === FALSE) + { + continue; + } + + // Write out the table schema + $output .= '#'.$newline.'# TABLE STRUCTURE FOR: '.$table.$newline.'#'.$newline.$newline; + + if ($add_drop === TRUE) + { + $output .= 'DROP TABLE IF EXISTS '.$this->db->protect_identifiers($table).';'.$newline.$newline; + } + + $i = 0; + $result = $query->result_array(); + foreach ($result[0] as $val) + { + if ($i++ % 2) + { + $output .= $val.';'.$newline.$newline; + } + } + + // If inserts are not needed we're done... + if ($add_insert === FALSE) + { + continue; + } + + // Grab all the data from the current table + $query = $this->db->query('SELECT * FROM '.$this->db->protect_identifiers($table)); + + if ($query->num_rows() === 0) + { + continue; + } + + // Fetch the field names and determine if the field is an + // integer type. We use this info to decide whether to + // surround the data with quotes or not + + $i = 0; + $field_str = ''; + $is_int = array(); + while ($field = $query->result_id->fetch_field()) + { + // Most versions of MySQL store timestamp as a string + $is_int[$i] = in_array(strtolower($field->type), + array('tinyint', 'smallint', 'mediumint', 'int', 'bigint'), //, 'timestamp'), + TRUE); + + // Create a string of field names + $field_str .= $this->db->escape_identifiers($field->name).', '; + $i++; + } + + // Trim off the end comma + $field_str = preg_replace('/, $/' , '', $field_str); + + // Build the insert string + foreach ($query->result_array() as $row) + { + $val_str = ''; + + $i = 0; + foreach ($row as $v) + { + // Is the value NULL? + if ($v === NULL) + { + $val_str .= 'NULL'; + } + else + { + // Escape the data if it's not an integer + $val_str .= ($is_int[$i] === FALSE) ? $this->db->escape($v) : $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 '.$this->db->protect_identifiers($table).' ('.$field_str.') VALUES ('.$val_str.');'.$newline; + } + + $output .= $newline.$newline; + } + + // Do we need to include a statement to re-enable foreign key checks? + if ($foreign_key_checks === FALSE) + { + $output .= 'SET foreign_key_checks = 1;'.$newline; + } + + return $output; + } + +} + +/* End of file mysqli_utility.php */ +/* Location: ./system/database/drivers/mysqli/mysqli_utility.php */ \ No newline at end of file diff --git a/system/database/drivers/oci8/index.html b/system/database/drivers/oci8/index.html new file mode 100755 index 0000000..c942a79 --- /dev/null +++ b/system/database/drivers/oci8/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

    Directory access is forbidden.

    + + + \ No newline at end of file diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php new file mode 100755 index 0000000..f34c0d1 --- /dev/null +++ b/system/database/drivers/oci8/oci8_driver.php @@ -0,0 +1,706 @@ + '/^\(DESCRIPTION=(\(.+\)){2,}\)$/', // TNS + // Easy Connect string (Oracle 10g+) + 'ec' => '/^(\/\/)?[a-z0-9.:_-]+(:[1-9][0-9]{0,4})?(\/[a-z0-9$_]+)?(:[^\/])?(\/[a-z0-9$_]+)?$/i', + 'in' => '/^[a-z0-9$_]+$/i' // Instance name (defined in tnsnames.ora) + ); + + /* Space characters don't have any effect when actually + * connecting, but can be a hassle while validating the DSN. + */ + $this->dsn = str_replace(array("\n", "\r", "\t", ' '), '', $this->dsn); + + if ($this->dsn !== '') + { + foreach ($valid_dsns as $regexp) + { + if (preg_match($regexp, $this->dsn)) + { + return; + } + } + } + + // Legacy support for TNS in the hostname configuration field + $this->hostname = str_replace(array("\n", "\r", "\t", ' '), '', $this->hostname); + if (preg_match($valid_dsns['tns'], $this->hostname)) + { + $this->dsn = $this->hostname; + return; + } + elseif ($this->hostname !== '' && strpos($this->hostname, '/') === FALSE && strpos($this->hostname, ':') === FALSE + && (( ! empty($this->port) && ctype_digit($this->port)) OR $this->database !== '')) + { + /* If the hostname field isn't empty, doesn't contain + * ':' and/or '/' and if port and/or database aren't + * empty, then the hostname field is most likely indeed + * just a hostname. Therefore we'll try and build an + * Easy Connect string from these 3 settings, assuming + * that the database field is a service name. + */ + $this->dsn = $this->hostname + .(( ! empty($this->port) && ctype_digit($this->port)) ? ':'.$this->port : '') + .($this->database !== '' ? '/'.ltrim($this->database, '/') : ''); + + if (preg_match($valid_dsns['ec'], $this->dsn)) + { + return; + } + } + + /* At this point, we can only try and validate the hostname and + * database fields separately as DSNs. + */ + if (preg_match($valid_dsns['ec'], $this->hostname) OR preg_match($valid_dsns['in'], $this->hostname)) + { + $this->dsn = $this->hostname; + return; + } + + $this->database = str_replace(array("\n", "\r", "\t", ' '), '', $this->database); + foreach ($valid_dsns as $regexp) + { + if (preg_match($regexp, $this->database)) + { + return; + } + } + + /* Well - OK, an empty string should work as well. + * PHP will try to use environment variables to + * determine which Oracle instance to connect to. + */ + $this->dsn = ''; + } + + // -------------------------------------------------------------------- + + /** + * Non-persistent database connection + * + * @param bool $persistent + * @return resource + */ + public function db_connect($persistent = FALSE) + { + $func = ($persistent === TRUE) ? 'oci_pconnect' : 'oci_connect'; + return empty($this->char_set) + ? $func($this->username, $this->password, $this->dsn) + : $func($this->username, $this->password, $this->dsn, $this->char_set); + } + + // -------------------------------------------------------------------- + + /** + * Database version number + * + * @return string + */ + public function version() + { + if (isset($this->data_cache['version'])) + { + return $this->data_cache['version']; + } + elseif ( ! $this->conn_id) + { + $this->initialize(); + } + + if ( ! $this->conn_id OR ($version = oci_server_version($this->conn_id)) === FALSE) + { + return FALSE; + } + + return $this->data_cache['version'] = $version; + } + + // -------------------------------------------------------------------- + + /** + * Execute the query + * + * @param string $sql an SQL query + * @return resource + */ + protected function _execute($sql) + { + /* Oracle must parse the query before it is run. All of the actions with + * the query are based on the statement id returned by oci_parse(). + */ + $this->stmt_id = FALSE; + $this->_set_stmt_id($sql); + oci_set_prefetch($this->stmt_id, 1000); + return oci_execute($this->stmt_id, $this->commit_mode); + } + + // -------------------------------------------------------------------- + + /** + * Generate a statement ID + * + * @param string $sql an SQL query + * @return void + */ + protected function _set_stmt_id($sql) + { + if ( ! is_resource($this->stmt_id)) + { + $this->stmt_id = oci_parse($this->conn_id, $sql); + } + } + + // -------------------------------------------------------------------- + + /** + * Get cursor. Returns a cursor from the database + * + * @return resource + */ + public function get_cursor() + { + return $this->curs_id = oci_new_cursor($this->conn_id); + } + + // -------------------------------------------------------------------- + + /** + * Stored Procedure. Executes a stored procedure + * + * @param string package name in which the stored procedure is in + * @param string stored procedure name to execute + * @param array parameters + * @return mixed + * + * params array keys + * + * KEY OPTIONAL NOTES + * name no the name of the parameter should be in : format + * value no the value of the parameter. If this is an OUT or IN OUT parameter, + * this should be a reference to a variable + * type yes the type of the parameter + * length yes the max size of the parameter + */ + public function stored_procedure($package, $procedure, $params) + { + if ($package === '' OR $procedure === '' OR ! is_array($params)) + { + log_message('error', 'Invalid query: '.$package.'.'.$procedure); + return ($this->db_debug) ? $this->display_error('db_invalid_query') : FALSE; + } + + // build the query string + $sql = 'BEGIN '.$package.'.'.$procedure.'('; + + $have_cursor = FALSE; + foreach ($params as $param) + { + $sql .= $param['name'].','; + + if (isset($param['type']) && $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); + return $this->query($sql, FALSE, $have_cursor); + } + + // -------------------------------------------------------------------- + + /** + * Bind parameters + * + * @param array $params + * @return void + */ + protected function _bind_params($params) + { + if ( ! is_array($params) OR ! is_resource($this->stmt_id)) + { + return; + } + + foreach ($params as $param) + { + foreach (array('name', 'value', 'type', 'length') as $val) + { + if ( ! isset($param[$val])) + { + $param[$val] = ''; + } + } + + oci_bind_by_name($this->stmt_id, $param['name'], $param['value'], $param['length'], $param['type']); + } + } + + // -------------------------------------------------------------------- + + /** + * Begin Transaction + * + * @param bool $test_mode + * @return bool + */ + public 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); + + $this->commit_mode = is_php('5.3.2') ? OCI_NO_AUTO_COMMIT : OCI_DEFAULT; + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Commit Transaction + * + * @return bool + */ + public function trans_commit() + { + if ( ! $this->trans_enabled) + { + return TRUE; + } + + // When transactions are nested we only begin/commit/rollback the outermost ones + if ($this->_trans_depth > 0) + { + return TRUE; + } + + $this->commit_mode = OCI_COMMIT_ON_SUCCESS; + return oci_commit($this->conn_id); + } + + // -------------------------------------------------------------------- + + /** + * Rollback Transaction + * + * @return bool + */ + public function trans_rollback() + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $this->_trans_depth > 0) + { + return TRUE; + } + + $this->commit_mode = OCI_COMMIT_ON_SUCCESS; + return oci_rollback($this->conn_id); + } + + // -------------------------------------------------------------------- + + /** + * Affected Rows + * + * @return int + */ + public function affected_rows() + { + return oci_num_rows($this->stmt_id); + } + + // -------------------------------------------------------------------- + + /** + * Insert ID + * + * @return int + */ + public function insert_id() + { + // not supported in oracle + return $this->display_error('db_unsupported_function'); + } + + // -------------------------------------------------------------------- + + /** + * Show table query + * + * Generates a platform-specific query string so that the table names can be fetched + * + * @param bool $prefix_limit + * @return string + */ + protected function _list_tables($prefix_limit = FALSE) + { + $sql = 'SELECT "TABLE_NAME" FROM "ALL_TABLES"'; + + if ($prefix_limit !== FALSE && $this->dbprefix !== '') + { + return $sql.' WHERE "TABLE_NAME" LIKE \''.$this->escape_like_str($this->dbprefix)."%' " + .sprintf($this->_like_escape_str, $this->_like_escape_chr); + } + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Show column query + * + * Generates a platform-specific query string so that the column names can be fetched + * + * @param string $table + * @return string + */ + protected function _list_columns($table = '') + { + if (strpos($table, '.') !== FALSE) + { + sscanf($table, '%[^.].%s', $owner, $table); + } + else + { + $owner = $this->username; + } + + return 'SELECT COLUMN_NAME FROM ALL_TAB_COLUMNS + WHERE UPPER(OWNER) = '.$this->escape(strtoupper($owner)).' + AND UPPER(TABLE_NAME) = '.$this->escape(strtoupper($table)); + } + + // -------------------------------------------------------------------- + + /** + * Returns an object with field data + * + * @param string $table + * @return array + */ + public function field_data($table = '') + { + if ($table === '') + { + return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; + } + elseif (strpos($table, '.') !== FALSE) + { + sscanf($table, '%[^.].%s', $owner, $table); + } + else + { + $owner = $this->username; + } + + $sql = 'SELECT COLUMN_NAME, DATA_TYPE, CHAR_LENGTH, DATA_PRECISION, DATA_LENGTH, DATA_DEFAULT, NULLABLE + FROM ALL_TAB_COLUMNS + WHERE UPPER(OWNER) = '.$this->escape(strtoupper($owner)).' + AND UPPER(TABLE_NAME) = '.$this->escape(strtoupper($table)); + + if (($query = $this->query($sql)) === FALSE) + { + return FALSE; + } + $query = $query->result_object(); + + $retval = array(); + for ($i = 0, $c = count($query); $i < $c; $i++) + { + $retval[$i] = new stdClass(); + $retval[$i]->name = $query[$i]->COLUMN_NAME; + $retval[$i]->type = $query[$i]->DATA_TYPE; + + $length = ($query[$i]->CHAR_LENGTH > 0) + ? $query[$i]->CHAR_LENGTH : $query[$i]->DATA_PRECISION; + if ($length === NULL) + { + $length = $query[$i]->DATA_LENGTH; + } + $retval[$i]->max_length = $length; + + $default = $query[$i]->DATA_DEFAULT; + if ($default === NULL && $query[$i]->NULLABLE === 'N') + { + $default = ''; + } + $retval[$i]->default = $query[$i]->COLUMN_DEFAULT; + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Error + * + * Returns an array containing code and message of the last + * database error that has occured. + * + * @return array + */ + public function error() + { + /* oci_error() returns an array that already contains the + * 'code' and 'message' keys, so we can just return it. + */ + if (is_resource($this->curs_id)) + { + return oci_error($this->curs_id); + } + elseif (is_resource($this->stmt_id)) + { + return oci_error($this->stmt_id); + } + elseif (is_resource($this->conn_id)) + { + return oci_error($this->conn_id); + } + + return oci_error(); + } + + // -------------------------------------------------------------------- + + /** + * Insert batch statement + * + * Generates a platform-specific insert string from the supplied data + * + * @param string $table Table name + * @param array $keys INSERT keys + * @param array $values INSERT values + * @return string + */ + protected function _insert_batch($table, $keys, $values) + { + $keys = implode(', ', $keys); + $sql = "INSERT ALL\n"; + + for ($i = 0, $c = count($values); $i < $c; $i++) + { + $sql .= ' INTO '.$table.' ('.$keys.') VALUES '.$values[$i]."\n"; + } + + return $sql.'SELECT * FROM dual'; + } + + // -------------------------------------------------------------------- + + /** + * Truncate statement + * + * Generates a platform-specific truncate string from the supplied data + * + * If the database does not support the TRUNCATE statement, + * then this method maps to 'DELETE FROM table' + * + * @param string $table + * @return string + */ + protected function _truncate($table) + { + return 'TRUNCATE TABLE '.$table; + } + + // -------------------------------------------------------------------- + + /** + * Delete statement + * + * Generates a platform-specific delete string from the supplied data + * + * @param string $table + * @return string + */ + protected function _delete($table) + { + if ($this->qb_limit) + { + $this->where('rownum <= ',$this->qb_limit, FALSE); + $this->qb_limit = FALSE; + } + + return parent::_delete($table); + } + + // -------------------------------------------------------------------- + + /** + * LIMIT + * + * Generates a platform-specific LIMIT clause + * + * @param string $sql SQL Query + * @return string + */ + protected function _limit($sql) + { + $this->limit_used = TRUE; + return 'SELECT * FROM (SELECT inner_query.*, rownum rnum FROM ('.$sql.') inner_query WHERE rownum < '.($this->qb_offset + $this->qb_limit + 1).')' + .($this->qb_offset ? ' WHERE rnum >= '.($this->qb_offset + 1) : ''); + } + + // -------------------------------------------------------------------- + + /** + * Close DB Connection + * + * @return void + */ + protected function _close() + { + oci_close($this->conn_id); + } + +} + +/* End of file oci8_driver.php */ +/* Location: ./system/database/drivers/oci8/oci8_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php new file mode 100755 index 0000000..d63846f --- /dev/null +++ b/system/database/drivers/oci8/oci8_forge.php @@ -0,0 +1,133 @@ +db->escape_identifiers($table); + $sqls = array(); + for ($i = 0, $c = count($field); $i < $c; $i++) + { + if ($field[$i]['_literal'] !== FALSE) + { + $field[$i] = "\n\t".$field[$i]['_literal']; + } + else + { + $field[$i]['_literal'] = "\n\t".$this->_process_column($field[$i]); + if ($alter_type === 'MODIFY' && ! empty($field[$i]['new_name'])) + { + $sqls[] = $sql.' RENAME COLUMN '.$this->db->escape_identifiers($field[$i]['name']) + .' '.$this->db->escape_identifiers($field[$i]['new_name']); + } + } + } + + $sql .= ' '.$alter_type.' '; + $sql .= (count($field) === 1) + ? $field[0] + : '('.implode(',', $field).')'; + + // RENAME COLUMN must be executed after MODIFY + array_unshift($sqls, $sql); + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Field attribute AUTO_INCREMENT + * + * @param array &$attributes + * @param array &$field + * @return void + */ + protected function _attr_auto_increment(&$attributes, &$field) + { + // Not supported - sequences and triggers must be used instead + } + +} + +/* End of file oci8_forge.php */ +/* Location: ./system/database/drivers/oci8/oci8_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php new file mode 100755 index 0000000..50612ca --- /dev/null +++ b/system/database/drivers/oci8/oci8_result.php @@ -0,0 +1,222 @@ +stmt_id = $driver_object->stmt_id; + $this->curs_id = $driver_object->curs_id; + $this->limit_used = $driver_object->limit_used; + $this->commit_mode =& $driver_object->commit_mode; + $driver_object->stmt_id = FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Number of fields in the result set + * + * @return int + */ + public function num_fields() + { + $count = oci_num_fields($this->stmt_id); + + // if we used a limit we subtract it + return ($this->limit_used) ? $count - 1 : $count; + } + + // -------------------------------------------------------------------- + + /** + * Fetch Field Names + * + * Generates an array of column names + * + * @return array + */ + public function list_fields() + { + $field_names = array(); + for ($c = 1, $fieldCount = $this->num_fields(); $c <= $fieldCount; $c++) + { + $field_names[] = oci_field_name($this->stmt_id, $c); + } + return $field_names; + } + + // -------------------------------------------------------------------- + + /** + * Field data + * + * Generates an array of objects containing field meta-data + * + * @return array + */ + public function field_data() + { + $retval = array(); + for ($c = 1, $fieldCount = $this->num_fields(); $c <= $fieldCount; $c++) + { + $F = new stdClass(); + $F->name = oci_field_name($this->stmt_id, $c); + $F->type = oci_field_type($this->stmt_id, $c); + $F->max_length = oci_field_size($this->stmt_id, $c); + + $retval[] = $F; + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Free the result + * + * @return void + */ + public function free_result() + { + if (is_resource($this->result_id)) + { + oci_free_statement($this->result_id); + $this->result_id = FALSE; + } + + if (is_resource($this->stmt_id)) + { + oci_free_statement($this->stmt_id); + } + + if (is_resource($this->curs_id)) + { + oci_cancel($this->curs_id); + $this->curs_id = NULL; + } + } + + // -------------------------------------------------------------------- + + /** + * Result - associative array + * + * Returns the result set as an array + * + * @return array + */ + protected function _fetch_assoc() + { + $id = ($this->curs_id) ? $this->curs_id : $this->stmt_id; + return oci_fetch_assoc($id); + } + + // -------------------------------------------------------------------- + + /** + * Result - object + * + * Returns the result set as an object + * + * @param string $class_name + * @return object + */ + protected function _fetch_object($class_name = 'stdClass') + { + $row = ($this->curs_id) + ? oci_fetch_object($this->curs_id) + : oci_fetch_object($this->stmt_id); + + if ($class_name === 'stdClass' OR ! $row) + { + return $row; + } + + $class_name = new $class_name(); + foreach ($row as $key => $value) + { + $class_name->$key = $value; + } + + return $class_name; + } + +} + +/* End of file oci8_result.php */ +/* Location: ./system/database/drivers/oci8/oci8_result.php */ \ No newline at end of file diff --git a/system/database/drivers/oci8/oci8_utility.php b/system/database/drivers/oci8/oci8_utility.php new file mode 100755 index 0000000..856125b --- /dev/null +++ b/system/database/drivers/oci8/oci8_utility.php @@ -0,0 +1,60 @@ +db->display_error('db_unsupported_feature'); + } + +} + +/* End of file oci8_utility.php */ +/* Location: ./system/database/drivers/oci8/oci8_utility.php */ \ No newline at end of file diff --git a/system/database/drivers/odbc/index.html b/system/database/drivers/odbc/index.html new file mode 100755 index 0000000..c942a79 --- /dev/null +++ b/system/database/drivers/odbc/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

    Directory access is forbidden.

    + + + \ No newline at end of file diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php new file mode 100755 index 0000000..06c24d6 --- /dev/null +++ b/system/database/drivers/odbc/odbc_driver.php @@ -0,0 +1,366 @@ +dsn)) + { + $this->dsn = $this->hostname; + } + } + + // -------------------------------------------------------------------- + + /** + * Non-persistent database connection + * + * @param bool $persistent + * @return resource + */ + public function db_connect($persistent = FALSE) + { + return ($persistent === TRUE) + ? odbc_pconnect($this->dsn, $this->username, $this->password) + : odbc_connect($this->dsn, $this->username, $this->password); + } + + // -------------------------------------------------------------------- + + /** + * Execute the query + * + * @param string $sql an SQL query + * @return resource + */ + protected function _execute($sql) + { + return odbc_exec($this->conn_id, $sql); + } + + // -------------------------------------------------------------------- + + /** + * Begin Transaction + * + * @param bool $test_mode + * @return bool + */ + public function trans_begin($test_mode = FALSE) + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $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); + + return odbc_autocommit($this->conn_id, FALSE); + } + + // -------------------------------------------------------------------- + + /** + * Commit Transaction + * + * @return bool + */ + public function trans_commit() + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $this->_trans_depth > 0) + { + return TRUE; + } + + $ret = odbc_commit($this->conn_id); + odbc_autocommit($this->conn_id, TRUE); + return $ret; + } + + // -------------------------------------------------------------------- + + /** + * Rollback Transaction + * + * @return bool + */ + public function trans_rollback() + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $this->_trans_depth > 0) + { + return TRUE; + } + + $ret = odbc_rollback($this->conn_id); + odbc_autocommit($this->conn_id, TRUE); + return $ret; + } + + // -------------------------------------------------------------------- + + /** + * Platform-dependant string escape + * + * @param string + * @return string + */ + protected function _escape_str($str) + { + return remove_invisible_characters($str); + } + + // -------------------------------------------------------------------- + + /** + * Affected Rows + * + * @return int + */ + public function affected_rows() + { + return odbc_num_rows($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Insert ID + * + * @return bool + */ + public function insert_id() + { + return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Show table query + * + * Generates a platform-specific query string so that the table names can be fetched + * + * @param bool $prefix_limit + * @return string + */ + protected function _list_tables($prefix_limit = FALSE) + { + $sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = '".$this->schema."'"; + + if ($prefix_limit !== FALSE && $this->dbprefix !== '') + { + return $sql." AND table_name LIKE '".$this->escape_like_str($this->dbprefix)."%' " + .sprintf($this->_like_escape_str, $this->_like_escape_chr); + } + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Show column query + * + * Generates a platform-specific query string so that the column names can be fetched + * + * @param string $table + * @return string + */ + protected function _list_columns($table = '') + { + return 'SHOW COLUMNS FROM '.$table; + } + + // -------------------------------------------------------------------- + + /** + * Field data query + * + * Generates a platform-specific query so that the column data can be retrieved + * + * @param string $table + * @return string + */ + protected function _field_data($table) + { + return 'SELECT TOP 1 FROM '.$table; + } + + // -------------------------------------------------------------------- + + /** + * Error + * + * Returns an array containing code and message of the last + * database error that has occured. + * + * @return array + */ + public function error() + { + return array('code' => odbc_error($this->conn_id), 'message' => odbc_errormsg($this->conn_id)); + } + + // -------------------------------------------------------------------- + + /** + * Update statement + * + * Generates a platform-specific update string from the supplied data + * + * @param string $table + * @param array $values + * @return string + */ + protected function _update($table, $values) + { + $this->qb_limit = FALSE; + $this->qb_orderby = array(); + return parent::_update($table, $values); + } + + // -------------------------------------------------------------------- + + /** + * Truncate statement + * + * Generates a platform-specific truncate string from the supplied data + * + * If the database does not support the TRUNCATE statement, + * then this method maps to 'DELETE FROM table' + * + * @param string $table + * @return string + */ + protected function _truncate($table) + { + return 'DELETE FROM '.$table; + } + + // -------------------------------------------------------------------- + + /** + * Delete statement + * + * Generates a platform-specific delete string from the supplied data + * + * @param string $table + * @return string + */ + protected function _delete($table) + { + $this->qb_limit = FALSE; + return parent::_delete($table); + } + + // -------------------------------------------------------------------- + + /** + * Close DB Connection + * + * @return void + */ + protected function _close() + { + odbc_close($this->conn_id); + } + +} + +/* End of file odbc_driver.php */ +/* Location: ./system/database/drivers/odbc/odbc_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/odbc/odbc_forge.php b/system/database/drivers/odbc/odbc_forge.php new file mode 100755 index 0000000..dbf9949 --- /dev/null +++ b/system/database/drivers/odbc/odbc_forge.php @@ -0,0 +1,76 @@ +num_rows)) + { + return $this->num_rows; + } + elseif (($this->num_rows = odbc_num_rows($this->result_id)) !== -1) + { + return $this->num_rows; + } + + // Work-around for ODBC subdrivers that don't support num_rows() + if (count($this->result_array) > 0) + { + return $this->num_rows = count($this->result_array); + } + elseif (count($this->result_object) > 0) + { + return $this->num_rows = count($this->result_object); + } + + return $this->num_rows = count($this->result_array()); + } + + // -------------------------------------------------------------------- + + /** + * Number of fields in the result set + * + * @return int + */ + public function num_fields() + { + return odbc_num_fields($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Fetch Field Names + * + * Generates an array of column names + * + * @return array + */ + public function list_fields() + { + $field_names = array(); + $num_fields = $this->num_fields(); + + if ($num_fields > 0) + { + for ($i = 1; $i <= $num_fields; $i++) + { + $field_names[] = odbc_field_name($this->result_id, $i); + } + } + + return $field_names; + } + + // -------------------------------------------------------------------- + + /** + * Field data + * + * Generates an array of objects containing field meta-data + * + * @return array + */ + public function field_data() + { + $retval = array(); + for ($i = 0, $odbc_index = 1, $c = $this->num_fields(); $i < $c; $i++, $odbc_index++) + { + $retval[$i] = new stdClass(); + $retval[$i]->name = odbc_field_name($this->result_id, $odbc_index); + $retval[$i]->type = odbc_field_type($this->result_id, $odbc_index); + $retval[$i]->max_length = odbc_field_len($this->result_id, $odbc_index); + $retval[$i]->primary_key = 0; + $retval[$i]->default = ''; + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Free the result + * + * @return void + */ + public function free_result() + { + if (is_resource($this->result_id)) + { + odbc_free_result($this->result_id); + $this->result_id = FALSE; + } + } + + // -------------------------------------------------------------------- + + /** + * Result - associative array + * + * Returns the result set as an array + * + * @return array + */ + protected function _fetch_assoc() + { + return odbc_fetch_array($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Result - object + * + * Returns the result set as an object + * + * @param string $class_name + * @return object + */ + protected function _fetch_object($class_name = 'stdClass') + { + $row = odbc_fetch_object($this->result_id); + + if ($class_name === 'stdClass' OR ! $row) + { + return $row; + } + + $class_name = new $class_name(); + foreach ($row as $key => $value) + { + $class_name->$key = $value; + } + + return $class_name; + } + +} + +// -------------------------------------------------------------------- + +if ( ! function_exists('odbc_fetch_array')) +{ + /** + * ODBC Fetch array + * + * Emulates the native odbc_fetch_array() function when + * it is not available (odbc_fetch_array() requires unixODBC) + * + * @param resource &$result + * @param int $rownumber + * @return array + */ + function odbc_fetch_array(&$result, $rownumber = 1) + { + $rs = array(); + if ( ! odbc_fetch_into($result, $rs, $rownumber)) + { + return FALSE; + } + + $rs_assoc = array(); + foreach ($rs as $k => $v) + { + $field_name = odbc_field_name($result, $k+1); + $rs_assoc[$field_name] = $v; + } + + return $rs_assoc; + } +} + +// -------------------------------------------------------------------- + +if ( ! function_exists('odbc_fetch_object')) +{ + /** + * ODBC Fetch object + * + * Emulates the native odbc_fetch_object() function when + * it is not available. + * + * @param resource &$result + * @param int $rownumber + * @return object + */ + function odbc_fetch_object(&$result, $rownumber = 1) + { + $rs = array(); + if ( ! odbc_fetch_into($result, $rs, $rownumber)) + { + return FALSE; + } + + $rs_object = new stdClass(); + foreach ($rs as $k => $v) + { + $field_name = odbc_field_name($result, $k+1); + $rs_object->$field_name = $v; + } + + return $rs_object; + } +} + +/* End of file odbc_result.php */ +/* Location: ./system/database/drivers/odbc/odbc_result.php */ \ No newline at end of file diff --git a/system/database/drivers/odbc/odbc_utility.php b/system/database/drivers/odbc/odbc_utility.php new file mode 100755 index 0000000..00b6186 --- /dev/null +++ b/system/database/drivers/odbc/odbc_utility.php @@ -0,0 +1,53 @@ +db->display_error('db_unsupported_feature'); + } + +} + +/* End of file odbc_utility.php */ +/* Location: ./system/database/drivers/odbc/odbc_utility.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/index.html b/system/database/drivers/pdo/index.html new file mode 100755 index 0000000..c942a79 --- /dev/null +++ b/system/database/drivers/pdo/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

    Directory access is forbidden.

    + + + \ No newline at end of file diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php new file mode 100755 index 0000000..1d4e626 --- /dev/null +++ b/system/database/drivers/pdo/pdo_driver.php @@ -0,0 +1,392 @@ +dsn, $match) && count($match) === 2) + { + // If there is a minimum valid dsn string pattern found, we're done + // This is for general PDO users, who tend to have a full DSN string. + $this->subdriver = $match[1]; + return; + } + // Legacy support for DSN specified in the hostname field + elseif (preg_match('/([^:]+):/', $this->hostname, $match) && count($match) === 2) + { + $this->dsn = $this->hostname; + $this->hostname = NULL; + $this->subdriver = $match[1]; + return; + } + elseif (in_array($this->subdriver, array('mssql', 'sybase'), TRUE)) + { + $this->subdriver = 'dblib'; + } + elseif ($this->subdriver === '4D') + { + $this->subdriver = '4d'; + } + elseif ( ! in_array($this->subdriver, array('4d', 'cubrid', 'dblib', 'firebird', 'ibm', 'informix', 'mysql', 'oci', 'odbc', 'pgsql', 'sqlite', 'sqlsrv'), TRUE)) + { + log_message('error', 'PDO: Invalid or non-existent subdriver'); + + if ($this->db_debug) + { + show_error('Invalid or non-existent PDO subdriver'); + } + } + + $this->dsn = NULL; + } + + // -------------------------------------------------------------------- + + /** + * Database connection + * + * @param bool $persistent + * @return object + */ + public function db_connect($persistent = FALSE) + { + $this->options[PDO::ATTR_PERSISTENT] = $persistent; + + try + { + return new PDO($this->dsn, $this->username, $this->password, $this->options); + } + catch (PDOException $e) + { + if ($this->db_debug && empty($this->failover)) + { + $this->display_error($e->getMessage(), '', TRUE); + } + + return FALSE; + } + } + + // -------------------------------------------------------------------- + + /** + * Database version number + * + * @return string + */ + public function version() + { + if (isset($this->data_cache['version'])) + { + return $this->data_cache['version']; + } + elseif ( ! $this->conn_id) + { + $this->initialize(); + } + + // Not all subdrivers support the getAttribute() method + try + { + return $this->data_cache['version'] = $this->conn_id->getAttribute(PDO::ATTR_SERVER_VERSION); + } + catch (PDOException $e) + { + return parent::version(); + } + } + + // -------------------------------------------------------------------- + + /** + * Execute the query + * + * @param string $sql SQL query + * @return mixed + */ + protected function _execute($sql) + { + return $this->conn_id->query($sql); + } + + // -------------------------------------------------------------------- + + /** + * Begin Transaction + * + * @param bool $test_mode + * @return bool + */ + public function trans_begin($test_mode = FALSE) + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $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); + + return $this->conn_id->beginTransaction(); + } + + // -------------------------------------------------------------------- + + /** + * Commit Transaction + * + * @return bool + */ + public function trans_commit() + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $this->_trans_depth > 0) + { + return TRUE; + } + + return $this->conn_id->commit(); + } + + // -------------------------------------------------------------------- + + /** + * Rollback Transaction + * + * @return bool + */ + public function trans_rollback() + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $this->_trans_depth > 0) + { + return TRUE; + } + + return $this->conn_id->rollBack(); + } + + // -------------------------------------------------------------------- + + /** + * Platform-dependant string escape + * + * @param string + * @return string + */ + protected function _escape_str($str) + { + // Escape the string + $str = $this->conn_id->quote($str); + + // If there are duplicated quotes, trim them away + return ($str[0] === "'") + ? substr($str, 1, -1) + : $str; + } + + // -------------------------------------------------------------------- + + /** + * Affected Rows + * + * @return int + */ + public function affected_rows() + { + return is_object($this->result_id) ? $this->result_id->rowCount() : 0; + } + + // -------------------------------------------------------------------- + + /** + * Insert ID + * + * @param string $name + * @return int + */ + public function insert_id($name = NULL) + { + return $this->conn_id->lastInsertId($name); + } + + // -------------------------------------------------------------------- + + /** + * Field data query + * + * Generates a platform-specific query so that the column data can be retrieved + * + * @param string $table + * @return string + */ + protected function _field_data($table) + { + return 'SELECT TOP 1 * FROM '.$this->protect_identifiers($table); + } + + // -------------------------------------------------------------------- + + /** + * Error + * + * Returns an array containing code and message of the last + * database error that has occured. + * + * @return array + */ + public function error() + { + $error = array('code' => '00000', 'message' => ''); + $pdo_error = $this->conn_id->errorInfo(); + + if (empty($pdo_error[0])) + { + return $error; + } + + $error['code'] = isset($pdo_error[1]) ? $pdo_error[0].'/'.$pdo_error[1] : $pdo_error[0]; + if (isset($pdo_error[2])) + { + $error['message'] = $pdo_error[2]; + } + + return $error; + } + + // -------------------------------------------------------------------- + + /** + * Update_Batch statement + * + * Generates a platform-specific batch update string from the supplied data + * + * @param string $table Table name + * @param array $values Update data + * @param string $index WHERE key + * @return string + */ + protected function _update_batch($table, $values, $index) + { + $ids = array(); + 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]; + } + } + } + + $cases = ''; + foreach ($final as $k => $v) + { + $cases .= $k.' = CASE '."\n"; + + foreach ($v as $row) + { + $cases .= $row."\n"; + } + + $cases .= 'ELSE '.$k.' END, '; + } + + $this->where($index.' IN('.implode(',', $ids).')', NULL, FALSE); + + return 'UPDATE '.$table.' SET '.substr($cases, 0, -2).$this->_compile_wh('qb_where'); + } + + // -------------------------------------------------------------------- + + /** + * Truncate statement + * + * Generates a platform-specific truncate string from the supplied data + * + * If the database does not support the TRUNCATE statement, + * then this method maps to 'DELETE FROM table' + * + * @param string $table + * @return string + */ + protected function _truncate($table) + { + return 'TRUNCATE TABLE '.$table; + } + +} + +/* End of file pdo_driver.php */ +/* Location: ./system/database/drivers/pdo/pdo_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/pdo_forge.php b/system/database/drivers/pdo/pdo_forge.php new file mode 100755 index 0000000..4bc8546 --- /dev/null +++ b/system/database/drivers/pdo/pdo_forge.php @@ -0,0 +1,55 @@ +num_rows)) + { + return $this->num_rows; + } + elseif (count($this->result_array) > 0) + { + return $this->num_rows = count($this->result_array); + } + elseif (count($this->result_object) > 0) + { + return $this->num_rows = count($this->result_object); + } + elseif (($num_rows = $this->result_id->rowCount()) > 0) + { + return $this->num_rows = $num_rows; + } + + return $this->num_rows = count($this->result_array()); + } + + // -------------------------------------------------------------------- + + /** + * Number of fields in the result set + * + * @return int + */ + public function num_fields() + { + return $this->result_id->columnCount(); + } + + // -------------------------------------------------------------------- + + /** + * Fetch Field Names + * + * Generates an array of column names + * + * @return bool + */ + public function list_fields() + { + $field_names = array(); + for ($i = 0, $c = $this->num_fields(); $i < $c; $i++) + { + // Might trigger an E_WARNING due to not all subdrivers + // supporting getColumnMeta() + $field_names[$i] = @$this->result_id->getColumnMeta(); + $field_names[$i] = $field_names[$i]['name']; + } + + return $field_names; + } + + // -------------------------------------------------------------------- + + /** + * Field data + * + * Generates an array of objects containing field meta-data + * + * @return array + */ + public function field_data() + { + try + { + $retval = array(); + + for ($i = 0, $c = $this->num_fields(); $i < $c; $i++) + { + $field = $this->result_id->getColumnMeta($i); + + $retval[$i] = new stdClass(); + $retval[$i]->name = $field['name']; + $retval[$i]->type = $field['native_type']; + $retval[$i]->max_length = ($field['len'] > 0) ? $field['len'] : NULL; + $retval[$i]->primary_key = (int) ( ! empty($field['flags']) && in_array('primary_key', $field['flags'], TRUE)); + } + + return $retval; + } + catch (Exception $e) + { + if ($this->db->db_debug) + { + return $this->db->display_error('db_unsupported_feature'); + } + + return FALSE; + } + } + + // -------------------------------------------------------------------- + + /** + * Free the result + * + * @return void + */ + public function free_result() + { + if (is_object($this->result_id)) + { + $this->result_id = FALSE; + } + } + + // -------------------------------------------------------------------- + + /** + * Result - associative array + * + * Returns the result set as an array + * + * @return array + */ + protected function _fetch_assoc() + { + return $this->result_id->fetch(PDO::FETCH_ASSOC); + } + + // -------------------------------------------------------------------- + + /** + * Result - object + * + * Returns the result set as an object + * + * @param string $class_name + * @return object + */ + protected function _fetch_object($class_name = 'stdClass') + { + return $this->result_id->fetchObject($class_name); + } + +} + +/* End of file pdo_result.php */ +/* Location: ./system/database/drivers/pdo/pdo_result.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/pdo_utility.php b/system/database/drivers/pdo/pdo_utility.php new file mode 100755 index 0000000..f3c8e2d --- /dev/null +++ b/system/database/drivers/pdo/pdo_utility.php @@ -0,0 +1,53 @@ +db->display_error('db_unsupported_feature'); + } + +} + +/* End of file pdo_utility.php */ +/* Location: ./system/database/drivers/pdo/pdo_utility.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/subdrivers/index.html b/system/database/drivers/pdo/subdrivers/index.html new file mode 100755 index 0000000..c942a79 --- /dev/null +++ b/system/database/drivers/pdo/subdrivers/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

    Directory access is forbidden.

    + + + \ No newline at end of file diff --git a/system/database/drivers/pdo/subdrivers/pdo_4d_driver.php b/system/database/drivers/pdo/subdrivers/pdo_4d_driver.php new file mode 100755 index 0000000..590a332 --- /dev/null +++ b/system/database/drivers/pdo/subdrivers/pdo_4d_driver.php @@ -0,0 +1,192 @@ +dsn)) + { + $this->dsn = '4D:host='.(empty($this->hostname) ? '127.0.0.1' : $this->hostname); + + empty($this->port) OR $this->dsn .= ';port='.$this->port; + empty($this->database) OR $this->dsn .= ';dbname='.$this->database; + empty($this->char_set) OR $this->dsn .= ';charset='.$this->char_set; + } + elseif ( ! empty($this->char_set) && strpos($this->dsn, 'charset=', 3) === FALSE) + { + $this->dsn .= ';charset='.$this->char_set; + } + } + + // -------------------------------------------------------------------- + + /** + * Show table query + * + * Generates a platform-specific query string so that the table names can be fetched + * + * @param bool $prefix_limit + * @return string + */ + protected function _list_tables($prefix_limit = FALSE) + { + $sql = 'SELECT '.$this->escape_identifiers('TABLE_NAME').' FROM '.$this->escape_identifiers('_USER_TABLES'); + + if ($prefix_limit === TRUE && $this->dbprefix !== '') + { + $sql .= ' WHERE '.$this->escape_identifiers('TABLE_NAME')." LIKE '".$this->escape_like_str($this->dbprefix)."%' " + .sprintf($this->_like_escape_str, $this->_like_escape_chr); + } + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Show column query + * + * Generates a platform-specific query string so that the column names can be fetched + * + * @param string $table + * @return string + */ + protected function _list_columns($table = '') + { + return 'SELECT '.$this->escape_identifiers('COLUMN_NAME').' FROM '.$this->escape_identifiers('_USER_COLUMNS') + .' WHERE '.$this->escape_identifiers('TABLE_NAME').' = '.$this->escape($table); + } + + // -------------------------------------------------------------------- + + /** + * Field data query + * + * Generates a platform-specific query so that the column data can be retrieved + * + * @param string $table + * @return string + */ + protected function _field_data($table) + { + return 'SELECT * FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE).' LIMIT 1'; + } + + // -------------------------------------------------------------------- + + /** + * Update statement + * + * Generates a platform-specific update string from the supplied data + * + * @param string $table + * @param array $values + * @return string + */ + protected function _update($table, $values) + { + $this->qb_limit = FALSE; + $this->qb_orderby = array(); + return parent::_update($table, $values); + } + + // -------------------------------------------------------------------- + + /** + * Delete statement + * + * Generates a platform-specific delete string from the supplied data + * + * @param string $table + * @return string + */ + protected function _delete($table) + { + $this->qb_limit = FALSE; + return parent::_delete($table); + } + + // -------------------------------------------------------------------- + + /** + * LIMIT + * + * Generates a platform-specific LIMIT clause + * + * @param string $sql SQL Query + * @return string + */ + protected function _limit($sql) + { + return $sql.' LIMIT '.$this->qb_limit.($this->qb_offset ? ' OFFSET '.$this->qb_offset : ''); + } + +} + +/* End of file pdo_4d_driver.php */ +/* Location: ./system/database/drivers/pdo/subdrivers/pdo_4d_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/subdrivers/pdo_4d_forge.php b/system/database/drivers/pdo/subdrivers/pdo_4d_forge.php new file mode 100755 index 0000000..97255ed --- /dev/null +++ b/system/database/drivers/pdo/subdrivers/pdo_4d_forge.php @@ -0,0 +1,209 @@ + 'INT', + 'SMALLINT' => 'INT', + 'INT' => 'INT64', + 'INT32' => 'INT64' + ); + + /** + * DEFAULT value representation in CREATE/ALTER TABLE statements + * + * @var string + */ + protected $_default = FALSE; + + // -------------------------------------------------------------------- + + /** + * ALTER TABLE + * + * @param string $alter_type ALTER type + * @param string $table Table name + * @param mixed $field Column definition + * @return string|string[] + */ + protected function _alter_table($alter_type, $table, $field) + { + if (in_array($alter_type, array('ADD', 'DROP'), TRUE)) + { + return parent::_alter_table($alter_type, $table, $field); + } + + // No method of modifying columns is supported + return FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Process column + * + * @param array $field + * @return string + */ + protected function _process_column($field) + { + return $this->db->escape_identifiers($field['name']) + .' '.$field['type'].$field['length'] + .$field['null'] + .$field['unique'] + .$field['auto_increment']; + } + + // -------------------------------------------------------------------- + + /** + * Field attribute TYPE + * + * Performs a data type mapping between different databases. + * + * @param array &$attributes + * @return void + */ + protected function _attr_type(&$attributes) + { + switch (strtoupper($attributes['TYPE'])) + { + case 'TINYINT': + $attributes['TYPE'] = 'SMALLINT'; + $attributes['UNSIGNED'] = FALSE; + return; + case 'MEDIUMINT': + $attributes['TYPE'] = 'INTEGER'; + $attributes['UNSIGNED'] = FALSE; + return; + case 'INTEGER': + $attributes['TYPE'] = 'INT'; + return; + case 'BIGINT': + $attribites['TYPE'] = 'INT64'; + return; + default: return; + } + } + + // -------------------------------------------------------------------- + + /** + * Field attribute UNIQUE + * + * @param array &$attributes + * @param array &$field + * @return void + */ + protected function _attr_unique(&$attributes, &$field) + { + if ( ! empty($attributes['UNIQUE']) && $attributes['UNIQUE'] === TRUE) + { + $field['unique'] = ' UNIQUE'; + + // UNIQUE must be used with NOT NULL + $field['null'] = ' NOT NULL'; + } + } + + // -------------------------------------------------------------------- + + /** + * Field attribute AUTO_INCREMENT + * + * @param array &$attributes + * @param array &$field + * @return void + */ + protected function _attr_auto_increment(&$attributes, &$field) + { + if ( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE) + { + if (stripos($field['type'], 'int') !== FALSE) + { + $field['auto_increment'] = ' AUTO_INCREMENT'; + } + elseif (strcasecmp($field['type'], 'UUID') === 0) + { + $field['auto_increment'] = ' AUTO_GENERATE'; + } + } + } + +} + +/* End of file pdo_4d_forge.php */ +/* Location: ./system/database/drivers/pdo/subdrivers/pdo_4d_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/subdrivers/pdo_cubrid_driver.php b/system/database/drivers/pdo/subdrivers/pdo_cubrid_driver.php new file mode 100755 index 0000000..d2d1fd5 --- /dev/null +++ b/system/database/drivers/pdo/subdrivers/pdo_cubrid_driver.php @@ -0,0 +1,247 @@ +dsn)) + { + $this->dsn = 'cubrid:host='.(empty($this->hostname) ? '127.0.0.1' : $this->hostname); + + empty($this->port) OR $this->dsn .= ';port='.$this->port; + empty($this->database) OR $this->dsn .= ';dbname='.$this->database; + empty($this->char_set) OR $this->dsn .= ';charset='.$this->char_set; + } + } + + // -------------------------------------------------------------------- + + /** + * Show table query + * + * Generates a platform-specific query string so that the table names can be fetched + * + * @param bool $prefix_limit + * @return string + */ + protected function _list_tables($prefix_limit = FALSE) + { + $sql = 'SHOW TABLES'; + + if ($prefix_limit === TRUE && $this->dbprefix !== '') + { + return $sql." LIKE '".$this->escape_like_str($this->dbprefix)."%'"; + } + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Show column query + * + * Generates a platform-specific query string so that the column names can be fetched + * + * @param string $table + * @return string + */ + protected function _list_columns($table = '') + { + return 'SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE); + } + + // -------------------------------------------------------------------- + + /** + * Returns an object with field data + * + * @param string $table + * @return array + */ + public function field_data($table = '') + { + if ($table === '') + { + return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; + } + + if (($query = $this->query('SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE))) === FALSE) + { + return FALSE; + } + $query = $query->result_object(); + + $retval = array(); + for ($i = 0, $c = count($query); $i < $c; $i++) + { + $retval[$i] = new stdClass(); + $retval[$i]->name = $query[$i]->Field; + + sscanf($query[$i]->Type, '%[a-z](%d)', + $retval[$i]->type, + $retval[$i]->max_length + ); + + $retval[$i]->default = $query[$i]->Default; + $retval[$i]->primary_key = (int) ($query[$i]->Key === 'PRI'); + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Update_Batch statement + * + * Generates a platform-specific batch update string from the supplied data + * + * @param string $table Table name + * @param array $values Update data + * @param string $index WHERE key + * @return string + */ + protected function _update_batch($table, $values, $index) + { + $ids = array(); + 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]; + } + } + } + + $cases = ''; + foreach ($final as $k => $v) + { + $cases .= $k." = CASE \n" + .implode("\n", $v)."\n" + .'ELSE '.$k.' END), '; + } + + $this->where($index.' IN('.implode(',', $ids).')', NULL, FALSE); + + return 'UPDATE '.$table.' SET '.substr($cases, 0, -2).$this->_compile_wh('qb_where'); + } + + // -------------------------------------------------------------------- + + /** + * Truncate statement + * + * Generates a platform-specific truncate string from the supplied data + * + * If the database does not support the TRUNCATE statement, + * then this method maps to 'DELETE FROM table' + * + * @param string $table + * @return string + */ + protected function _truncate($table) + { + return 'TRUNCATE '.$table; + } + + // -------------------------------------------------------------------- + + /** + * FROM tables + * + * Groups tables in FROM clauses if needed, so there is no confusion + * about operator precedence. + * + * @return string + */ + protected function _from_tables() + { + if ( ! empty($this->qb_join) && count($this->qb_from) > 1) + { + return '('.implode(', ', $this->qb_from).')'; + } + + return implode(', ', $this->qb_from); + } + +} + +/* End of file pdo_cubrid_driver.php */ +/* Location: ./system/database/drivers/pdo/subdrivers/pdo_cubrid_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/subdrivers/pdo_cubrid_forge.php b/system/database/drivers/pdo/subdrivers/pdo_cubrid_forge.php new file mode 100755 index 0000000..ed93d24 --- /dev/null +++ b/system/database/drivers/pdo/subdrivers/pdo_cubrid_forge.php @@ -0,0 +1,219 @@ + 'INTEGER', + 'SMALLINT' => 'INTEGER', + 'INT' => 'BIGINT', + 'INTEGER' => 'BIGINT', + 'BIGINT' => 'NUMERIC', + 'FLOAT' => 'DOUBLE', + 'REAL' => 'DOUBLE' + ); + + // -------------------------------------------------------------------- + + /** + * ALTER TABLE + * + * @param string $alter_type ALTER type + * @param string $table Table name + * @param mixed $field Column definition + * @return string|string[] + */ + protected function _alter_table($alter_type, $table, $field) + { + if (in_array($alter_type, array('DROP', 'ADD'), TRUE)) + { + return parent::_alter_table($alter_type, $table, $field); + } + + $sql = 'ALTER TABLE '.$this->db->escape_identifiers($table); + $sqls = array(); + for ($i = 0, $c = count($field); $i < $c; $i++) + { + if ($field[$i]['_literal'] !== FALSE) + { + $sqls[] = $sql.' CHANGE '.$field[$i]['_literal']; + } + else + { + $alter_type = empty($field[$i]['new_name']) ? ' MODIFY ' : ' CHANGE '; + $sqls[] = $sql.$alter_type.$this->_process_column($field[$i]); + } + } + + return $sqls; + } + + // -------------------------------------------------------------------- + + /** + * Process column + * + * @param array $field + * @return string + */ + protected function _process_column($field) + { + $extra_clause = isset($field['after']) + ? ' AFTER '.$this->db->escape_identifiers($field['after']) : ''; + + if (empty($extra_clause) && isset($field['first']) && $field['first'] === TRUE) + { + $extra_clause = ' FIRST'; + } + + return $this->db->escape_identifiers($field['name']) + .(empty($field['new_name']) ? '' : ' '.$this->db->escape_identifiers($field['new_name'])) + .' '.$field['type'].$field['length'] + .$field['unsigned'] + .$field['null'] + .$field['default'] + .$field['auto_increment'] + .$field['unique'] + .$extra_clause; + } + + // -------------------------------------------------------------------- + + /** + * Field attribute TYPE + * + * Performs a data type mapping between different databases. + * + * @param array &$attributes + * @return void + */ + protected function _attr_type(&$attributes) + { + switch (strtoupper($attributes['TYPE'])) + { + case 'TINYINT': + $attributes['TYPE'] = 'SMALLINT'; + $attributes['UNSIGNED'] = FALSE; + return; + case 'MEDIUMINT': + $attributes['TYPE'] = 'INTEGER'; + $attributes['UNSIGNED'] = FALSE; + return; + default: return; + } + } + + // -------------------------------------------------------------------- + + /** + * Process indexes + * + * @param string $table (ignored) + * @return string + */ + protected function _process_indexes($table) + { + $sql = ''; + + for ($i = 0, $c = count($this->keys); $i < $c; $i++) + { + if (is_array($this->keys[$i])) + { + for ($i2 = 0, $c2 = count($this->keys[$i]); $i2 < $c2; $i2++) + { + if ( ! isset($this->fields[$this->keys[$i][$i2]])) + { + unset($this->keys[$i][$i2]); + continue; + } + } + } + elseif ( ! isset($this->fields[$this->keys[$i]])) + { + unset($this->keys[$i]); + continue; + } + + is_array($this->keys[$i]) OR $this->keys[$i] = array($this->keys[$i]); + + $sql .= ",\n\tKEY ".$this->db->escape_identifiers(implode('_', $this->keys[$i])) + .' ('.implode(', ', $this->db->escape_identifiers($this->keys[$i])).')'; + } + + $this->keys = array(); + + return $sql; + } + +} + +/* End of file pdo_cubrid_forge.php */ +/* Location: ./system/database/drivers/pdo/subdrivers/pdo_cubrid_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/subdrivers/pdo_dblib_driver.php b/system/database/drivers/pdo/subdrivers/pdo_dblib_driver.php new file mode 100755 index 0000000..379fc07 --- /dev/null +++ b/system/database/drivers/pdo/subdrivers/pdo_dblib_driver.php @@ -0,0 +1,329 @@ +dsn)) + { + $this->dsn = $params['subdriver'].':host='.(empty($this->hostname) ? '127.0.0.1' : $this->hostname); + + if ( ! empty($this->port)) + { + $this->dsn .= (DIRECTORY_SEPARATOR === '\\' ? ',' : ':').$this->port; + } + + empty($this->database) OR $this->dsn .= ';dbname='.$this->database; + empty($this->char_set) OR $this->dsn .= ';charset='.$this->char_set; + empty($this->appname) OR $this->dsn .= ';appname='.$this->appname; + } + else + { + if ( ! empty($this->char_set) && strpos($this->dsn, 'charset=', 6) === FALSE) + { + $this->dsn .= ';charset='.$this->char_set; + } + + $this->subdriver = 'dblib'; + } + } + + // -------------------------------------------------------------------- + + /** + * Database connection + * + * @param bool $persistent + * @return object + */ + public function db_connect($persistent = FALSE) + { + $this->conn_id = parent::db_connect($persistent); + + if ( ! is_object($this->conn_id)) + { + return $this->conn_id; + } + + // Determine how identifiers are escaped + $query = $this->query('SELECT CASE WHEN (@@OPTIONS | 256) = @@OPTIONS THEN 1 ELSE 0 END AS qi'); + $query = $query->row_array(); + $this->_quoted_identifier = empty($query) ? FALSE : (bool) $query['qi']; + $this->_escape_char = ($this->_quoted_identifier) ? '"' : array('[', ']'); + + return $this->conn_id; + } + + // -------------------------------------------------------------------- + + /** + * Show table query + * + * Generates a platform-specific query string so that the table names can be fetched + * + * @param bool $prefix_limit + * @return string + */ + protected function _list_tables($prefix_limit = FALSE) + { + return 'SELECT '.$this->escape_identifiers('name') + .' FROM '.$this->escape_identifiers('sysobjects') + .' WHERE '.$this->escape_identifiers('type')." = 'U'"; + + if ($prefix_limit === TRUE && $this->dbprefix !== '') + { + $sql .= ' AND '.$this->escape_identifiers('name')." LIKE '".$this->escape_like_str($this->dbprefix)."%' " + .sprintf($this->_like_escape_str, $this->_like_escape_chr); + } + + return $sql.' ORDER BY '.$this->escape_identifiers('name'); + } + + // -------------------------------------------------------------------- + + /** + * Show column query + * + * Generates a platform-specific query string so that the column names can be fetched + * + * @param string $table + * @return string + */ + protected function _list_columns($table = '') + { + return 'SELECT COLUMN_NAME + FROM INFORMATION_SCHEMA.Columns + WHERE UPPER(TABLE_NAME) = '.$this->escape(strtoupper($table)); + } + + // -------------------------------------------------------------------- + + /** + * Returns an object with field data + * + * @param string $table + * @return array + */ + public function field_data($table = '') + { + if ($table === '') + { + return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; + } + + $sql = 'SELECT COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, NUMERIC_PRECISION, COLUMN_DEFAULT + FROM INFORMATION_SCHEMA.Columns + WHERE UPPER(TABLE_NAME) = '.$this->escape(strtoupper($table)); + + if (($query = $this->query($sql)) === FALSE) + { + return FALSE; + } + $query = $query->result_object(); + + $retval = array(); + for ($i = 0, $c = count($query); $i < $c; $i++) + { + $retval[$i] = new stdClass(); + $retval[$i]->name = $query[$i]->COLUMN_NAME; + $retval[$i]->type = $query[$i]->DATA_TYPE; + $retval[$i]->max_length = ($query[$i]->CHARACTER_MAXIMUM_LENGTH > 0) ? $query[$i]->CHARACTER_MAXIMUM_LENGTH : $query[$i]->NUMERIC_PRECISION; + $retval[$i]->default = $query[$i]->COLUMN_DEFAULT; + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Update statement + * + * Generates a platform-specific update string from the supplied data + * + * @param string $table + * @param array $values + * @return string + */ + protected function _update($table, $values) + { + $this->qb_limit = FALSE; + $this->qb_orderby = array(); + return parent::_update($table, $values); + } + + // -------------------------------------------------------------------- + + /** + * Delete statement + * + * Generates a platform-specific delete string from the supplied data + * + * @param string $table + * @return string + */ + protected function _delete($table) + { + if ($this->qb_limit) + { + return 'WITH ci_delete AS (SELECT TOP '.$this->qb_limit.' * FROM '.$table.$this->_compile_wh('qb_where').') DELETE FROM ci_delete'; + } + + return parent::_delete($table); + } + + // -------------------------------------------------------------------- + + /** + * LIMIT + * + * Generates a platform-specific LIMIT clause + * + * @param string $sql SQL Query + * @return string + */ + protected function _limit($sql) + { + $limit = $this->qb_offset + $this->qb_limit; + + // As of SQL Server 2005 (9.0.*) ROW_NUMBER() is supported, + // however an ORDER BY clause is required for it to work + if (version_compare($this->version(), '9', '>=') && $this->qb_offset && ! empty($this->qb_orderby)) + { + $orderby = $this->_compile_order_by(); + + // We have to strip the ORDER BY clause + $sql = trim(substr($sql, 0, strrpos($sql, $orderby))); + + // Get the fields to select from our subquery, so that we can avoid CI_rownum appearing in the actual results + if (count($this->qb_select) === 0) + { + $select = '*'; // Inevitable + } + else + { + // Use only field names and their aliases, everything else is out of our scope. + $select = array(); + $field_regexp = ($this->_quoted_identifier) + ? '("[^\"]+")' : '(\[[^\]]+\])'; + for ($i = 0, $c = count($this->qb_select); $i < $c; $i++) + { + $select[] = preg_match('/(?:\s|\.)'.$field_regexp.'$/i', $this->qb_select[$i], $m) + ? $m[1] : $this->qb_select[$i]; + } + $select = implode(', ', $select); + } + + return 'SELECT '.$select." FROM (\n\n" + .preg_replace('/^(SELECT( DISTINCT)?)/i', '\\1 ROW_NUMBER() OVER('.trim($orderby).') AS '.$this->escape_identifiers('CI_rownum').', ', $sql) + ."\n\n) ".$this->escape_identifiers('CI_subquery') + ."\nWHERE ".$this->escape_identifiers('CI_rownum').' BETWEEN '.($this->qb_offset + 1).' AND '.$limit; + } + + return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$limit.' ', $sql); + } + + // -------------------------------------------------------------------- + + /** + * Insert batch statement + * + * Generates a platform-specific insert string from the supplied data. + * + * @param string $table Table name + * @param array $keys INSERT keys + * @param array $values INSERT values + * @return string|bool + */ + protected function _insert_batch($table, $keys, $values) + { + // Multiple-value inserts are only supported as of SQL Server 2008 + if (version_compare($this->version(), '10', '>=')) + { + return parent::_insert_batch($table, $keys, $values); + } + + return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE; + } + +} + +/* End of file pdo_dblib_driver.php */ +/* Location: ./system/database/drivers/pdo/subdrivers/pdo_dblib_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/subdrivers/pdo_dblib_forge.php b/system/database/drivers/pdo/subdrivers/pdo_dblib_forge.php new file mode 100755 index 0000000..271c00d --- /dev/null +++ b/system/database/drivers/pdo/subdrivers/pdo_dblib_forge.php @@ -0,0 +1,136 @@ + 'SMALLINT', + 'SMALLINT' => 'INT', + 'INT' => 'BIGINT', + 'REAL' => 'FLOAT' + ); + + // -------------------------------------------------------------------- + + /** + * ALTER TABLE + * + * @param string $alter_type ALTER type + * @param string $table Table name + * @param mixed $field Column definition + * @return string|string[] + */ + protected function _alter_table($alter_type, $table, $field) + { + if (in_array($alter_type, array('ADD', 'DROP'), TRUE)) + { + return parent::_alter_table($alter_type, $table, $field); + } + + $sql = 'ALTER TABLE '.$this->db->escape_identifiers($table).' ALTER COLUMN '; + $sqls = array(); + for ($i = 0, $c = count($field); $i < $c; $i++) + { + $sqls[] = $sql.$this->_process_column($field[$i]); + } + + return $sqls; + } + + // -------------------------------------------------------------------- + + /** + * Field attribute TYPE + * + * Performs a data type mapping between different databases. + * + * @param array &$attributes + * @return void + */ + protected function _attr_type(&$attributes) + { + switch (strtoupper($attributes['TYPE'])) + { + case 'MEDIUMINT': + $attributes['TYPE'] = 'INTEGER'; + $attributes['UNSIGNED'] = FALSE; + return; + case 'INTEGER': + $attributes['TYPE'] = 'INT'; + return; + default: return; + } + } + + // -------------------------------------------------------------------- + + /** + * Field attribute AUTO_INCREMENT + * + * @param array &$attributes + * @param array &$field + * @return void + */ + protected function _attr_auto_increment(&$attributes, &$field) + { + if ( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE && stripos($field['type'], 'int') !== FALSE) + { + $field['auto_increment'] = ' IDENTITY(1,1)'; + } + } + +} + +/* End of file pdo_dblib_forge.php */ +/* Location: ./system/database/drivers/pdo/subdrivers/pdo_dblib_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/subdrivers/pdo_firebird_driver.php b/system/database/drivers/pdo/subdrivers/pdo_firebird_driver.php new file mode 100755 index 0000000..cbee19e --- /dev/null +++ b/system/database/drivers/pdo/subdrivers/pdo_firebird_driver.php @@ -0,0 +1,260 @@ +dsn)) + { + $this->dsn = 'firebird:'; + + if ( ! empty($this->database)) + { + $this->dsn .= 'dbname='.$this->database; + } + elseif ( ! empty($this->hostname)) + { + $this->dsn .= 'dbname='.$this->hostname; + } + + empty($this->char_set) OR $this->dsn .= ';charset='.$this->char_set; + empty($this->role) OR $this->dsn .= ';role='.$this->role; + } + elseif ( ! empty($this->char_set) && strpos($this->dsn, 'charset=', 9) === FALSE) + { + $this->dsn .= ';charset='.$this->char_set; + } + } + + // -------------------------------------------------------------------- + + /** + * Show table query + * + * Generates a platform-specific query string so that the table names can be fetched + * + * @param bool $prefix_limit + * @return string + */ + protected function _list_tables($prefix_limit = FALSE) + { + $sql = 'SELECT "RDB$RELATION_NAME" FROM "RDB$RELATIONS" WHERE "RDB$RELATION_NAME" NOT LIKE \'RDB$%\' AND "RDB$RELATION_NAME" NOT LIKE \'MON$%\''; + + if ($prefix_limit === TRUE && $this->dbprefix !== '') + { + return $sql.' AND "RDB$RELATION_NAME" LIKE \''.$this->escape_like_str($this->dbprefix)."%' " + .sprintf($this->_like_escape_str, $this->_like_escape_chr); + } + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Show column query + * + * Generates a platform-specific query string so that the column names can be fetched + * + * @param string $table + * @return string + */ + protected function _list_columns($table = '') + { + return 'SELECT "RDB$FIELD_NAME" FROM "RDB$RELATION_FIELDS" WHERE "RDB$RELATION_NAME" = '.$this->escape($table); + } + + // -------------------------------------------------------------------- + + /** + * Returns an object with field data + * + * @param string $table + * @return array + */ + public function field_data($table = '') + { + if ($table === '') + { + return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; + } + + $sql = 'SELECT "rfields"."RDB$FIELD_NAME" AS "name", + CASE "fields"."RDB$FIELD_TYPE" + WHEN 7 THEN \'SMALLINT\' + WHEN 8 THEN \'INTEGER\' + WHEN 9 THEN \'QUAD\' + WHEN 10 THEN \'FLOAT\' + WHEN 11 THEN \'DFLOAT\' + WHEN 12 THEN \'DATE\' + WHEN 13 THEN \'TIME\' + WHEN 14 THEN \'CHAR\' + WHEN 16 THEN \'INT64\' + WHEN 27 THEN \'DOUBLE\' + WHEN 35 THEN \'TIMESTAMP\' + WHEN 37 THEN \'VARCHAR\' + WHEN 40 THEN \'CSTRING\' + WHEN 261 THEN \'BLOB\' + ELSE NULL + END AS "type", + "fields"."RDB$FIELD_LENGTH" AS "max_length", + "rfields"."RDB$DEFAULT_VALUE" AS "default" + FROM "RDB$RELATION_FIELDS" "rfields" + JOIN "RDB$FIELDS" "fields" ON "rfields"."RDB$FIELD_SOURCE" = "fields"."RDB$FIELD_NAME" + WHERE "rfields"."RDB$RELATION_NAME" = '.$this->escape($table).' + ORDER BY "rfields"."RDB$FIELD_POSITION"'; + + return (($query = $this->query($sql)) !== FALSE) + ? $query->result_object() + : FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Update statement + * + * Generates a platform-specific update string from the supplied data + * + * @param string $table + * @param array $values + * @return string + */ + protected function _update($table, $values) + { + $this->qb_limit = FALSE; + return parent::_update($table, $values); + } + + // -------------------------------------------------------------------- + + /** + * Truncate statement + * + * Generates a platform-specific truncate string from the supplied data + * + * If the database does not support the TRUNCATE statement, + * then this method maps to 'DELETE FROM table' + * + * @param string $table + * @return string + */ + protected function _truncate($table) + { + return 'DELETE FROM '.$table; + } + + // -------------------------------------------------------------------- + + /** + * Delete statement + * + * Generates a platform-specific delete string from the supplied data + * + * @param string $table + * @return string + */ + protected function _delete($table) + { + $this->qb_limit = FALSE; + return parent::_delete($table); + } + + // -------------------------------------------------------------------- + + /** + * LIMIT + * + * Generates a platform-specific LIMIT clause + * + * @param string $sql SQL Query + * @return string + */ + protected function _limit($sql) + { + // Limit clause depends on if Interbase or Firebird + if (stripos($this->version(), 'firebird') !== FALSE) + { + $select = 'FIRST '.$this->qb_limit + .($this->qb_offset > 0 ? ' SKIP '.$this->qb_offset : ''); + } + else + { + $select = 'ROWS ' + .($this->qb_offset > 0 ? $this->qb_offset.' TO '.($this->qb_limit + $this->qb_offset) : $this->qb_limit); + } + + return preg_replace('`SELECT`i', 'SELECT '.$select, $sql); + } + +} + +/* End of file pdo_firebird_driver.php */ +/* Location: ./system/database/drivers/pdo/subdrivers/pdo_firebird_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/subdrivers/pdo_firebird_forge.php b/system/database/drivers/pdo/subdrivers/pdo_firebird_forge.php new file mode 100755 index 0000000..d754c27 --- /dev/null +++ b/system/database/drivers/pdo/subdrivers/pdo_firebird_forge.php @@ -0,0 +1,229 @@ + 'INTEGER', + 'INTEGER' => 'INT64', + 'FLOAT' => 'DOUBLE PRECISION' + ); + + /** + * NULL value representation in CREATE/ALTER TABLE statements + * + * @var string + */ + protected $_null = 'NULL'; + + // -------------------------------------------------------------------- + + /** + * Create database + * + * @param string $db_name + * @return string + */ + public function create_database($db_name) + { + // Firebird databases are flat files, so a path is required + + // Hostname is needed for remote access + empty($this->db->hostname) OR $db_name = $this->hostname.':'.$db_name; + + return parent::create_database('"'.$db_name.'"'); + } + + // -------------------------------------------------------------------- + + /** + * Drop database + * + * @param string $db_name (ignored) + * @return bool + */ + public function drop_database($db_name = '') + { + if ( ! ibase_drop_db($this->conn_id)) + { + return ($this->db->db_debug) ? $this->db->display_error('db_unable_to_drop') : FALSE; + } + elseif ( ! empty($this->db->data_cache['db_names'])) + { + $key = array_search(strtolower($this->db->database), array_map('strtolower', $this->db->data_cache['db_names']), TRUE); + if ($key !== FALSE) + { + unset($this->db->data_cache['db_names'][$key]); + } + } + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * ALTER TABLE + * + * @param string $alter_type ALTER type + * @param string $table Table name + * @param mixed $field Column definition + * @return string|string[] + */ + protected function _alter_table($alter_type, $table, $field) + { + if (in_array($alter_type, array('DROP', 'ADD'), TRUE)) + { + return parent::_alter_table($alter_type, $table, $field); + } + + $sql = 'ALTER TABLE '.$this->db->escape_identifiers($table); + $sqls = array(); + for ($i = 0, $c = count($field); $i < $c; $i++) + { + if ($field[$i]['_literal'] !== FALSE) + { + return FALSE; + } + + if (isset($field[$i]['type'])) + { + $sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identifiers($field[$i]['name']) + .' TYPE '.$field[$i]['type'].$field[$i]['length']; + } + + if ( ! empty($field[$i]['default'])) + { + $sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identifiers($field[$i]['name']) + .' SET DEFAULT '.$field[$i]['default']; + } + + if (isset($field[$i]['null'])) + { + $sqls[] = 'UPDATE "RDB$RELATION_FIELDS" SET "RDB$NULL_FLAG" = ' + .($field[$i]['null'] === TRUE ? 'NULL' : '1') + .' WHERE "RDB$FIELD_NAME" = '.$this->db->escape($field[$i]['name']) + .' AND "RDB$RELATION_NAME" = '.$this->db->escape($table); + } + + if ( ! empty($field[$i]['new_name'])) + { + $sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identifiers($field[$i]['name']) + .' TO '.$this->db->escape_identifiers($field[$i]['new_name']); + } + } + + return $sqls; + } + + // -------------------------------------------------------------------- + + /** + * Process column + * + * @param array $field + * @return string + */ + protected function _process_column($field) + { + return $this->db->escape_identifiers($field['name']) + .' '.$field['type'].$field['length'] + .$field['null'] + .$field['unique'] + .$field['default']; + } + + // -------------------------------------------------------------------- + + /** + * Field attribute TYPE + * + * Performs a data type mapping between different databases. + * + * @param array &$attributes + * @return void + */ + protected function _attr_type(&$attributes) + { + switch (strtoupper($attributes['TYPE'])) + { + case 'TINYINT': + $attributes['TYPE'] = 'SMALLINT'; + $attributes['UNSIGNED'] = FALSE; + return; + case 'MEDIUMINT': + $attributes['TYPE'] = 'INTEGER'; + $attributes['UNSIGNED'] = FALSE; + return; + case 'INT': + $attributes['TYPE'] = 'INTEGER'; + return; + case 'BIGINT': + $attributes['TYPE'] = 'INT64'; + return; + default: return; + } + } + + // -------------------------------------------------------------------- + + /** + * Field attribute AUTO_INCREMENT + * + * @param array &$attributes + * @param array &$field + * @return void + */ + protected function _attr_auto_increment(&$attributes, &$field) + { + // Not supported + } + +} + +/* End of file pdo_firebird_forge.php */ +/* Location: ./system/database/drivers/pdo/subdrivers/pdo_firebird_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/subdrivers/pdo_ibm_driver.php b/system/database/drivers/pdo/subdrivers/pdo_ibm_driver.php new file mode 100755 index 0000000..030fae0 --- /dev/null +++ b/system/database/drivers/pdo/subdrivers/pdo_ibm_driver.php @@ -0,0 +1,236 @@ +dsn)) + { + $this->dsn = 'ibm:'; + + // Pre-defined DSN + if (empty($this->hostname) && empty($this->HOSTNAME) && empty($this->port) && empty($this->PORT)) + { + if (isset($this->DSN)) + { + $this->dsn .= 'DSN='.$this->DSN; + } + elseif ( ! empty($this->database)) + { + $this->dsn .= 'DSN='.$this->database; + } + + return; + } + + $this->dsn .= 'DRIVER='.(isset($this->DRIVER) ? '{'.$this->DRIVER.'}' : '{IBM DB2 ODBC DRIVER}').';'; + + if (isset($this->DATABASE)) + { + $this->dsn .= 'DATABASE='.$this->DATABASE.';'; + } + elseif ( ! empty($this->database)) + { + $this->dsn .= 'DATABASE='.$this->database.';'; + } + + if (isset($this->HOSTNAME)) + { + $this->dsn .= 'HOSTNAME='.$this->HOSTNAME.';'; + } + else + { + $this->dsn .= 'HOSTNAME='.(empty($this->hostname) ? '127.0.0.1;' : $this->hostname.';'); + } + + if (isset($this->PORT)) + { + $this->dsn .= 'PORT='.$this->port.';'; + } + elseif ( ! empty($this->port)) + { + $this->dsn .= ';PORT='.$this->port.';'; + } + + $this->dsn .= 'PROTOCOL='.(isset($this->PROTOCOL) ? $this->PROTOCOL.';' : 'TCPIP;'); + } + } + + // -------------------------------------------------------------------- + + /** + * Show table query + * + * Generates a platform-specific query string so that the table names can be fetched + * + * @param bool $prefix_limit + * @return string + */ + protected function _list_tables($prefix_limit = FALSE) + { + $sql = 'SELECT "tabname" FROM "syscat"."tables" + WHERE "type" = \'T\' AND LOWER("tabschema") = '.$this->escape(strtolower($this->database)); + + if ($prefix_limit === TRUE && $this->dbprefix !== '') + { + $sql .= ' AND "tabname" LIKE \''.$this->escape_like_str($this->dbprefix)."%' " + .sprintf($this->_like_escape_str, $this->_like_escape_chr); + } + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Show column query + * + * Generates a platform-specific query string so that the column names can be fetched + * + * @param string $table + * @return array + */ + protected function _list_columns($table = '') + { + return 'SELECT "colname" FROM "syscat"."columns" + WHERE LOWER("tabschema") = '.$this->escape(strtolower($this->database)).' + AND LOWER("tabname") = '.$this->escape(strtolower($table)); + } + + // -------------------------------------------------------------------- + + /** + * Returns an object with field data + * + * @param string $table + * @return array + */ + public function field_data($table = '') + { + $sql = 'SELECT "colname" AS "name", "typename" AS "type", "default" AS "default", "length" AS "max_length", + CASE "keyseq" WHEN NULL THEN 0 ELSE 1 END AS "primary_key" + FROM "syscat"."columns" + WHERE LOWER("tabschema") = '.$this->escape(strtolower($this->database)).' + AND LOWER("tabname") = '.$this->escape(strtolower($table)).' + ORDER BY "colno"'; + + return (($query = $this->query($sql)) !== FALSE) + ? $query->result_object() + : FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Update statement + * + * Generates a platform-specific update string from the supplied data + * + * @param string $table + * @param array $values + * @return string + */ + protected function _update($table, $values) + { + $this->qb_limit = FALSE; + $this->qb_orderby = array(); + return parent::_update($table, $values); + } + + // -------------------------------------------------------------------- + + /** + * Delete statement + * + * Generates a platform-specific delete string from the supplied data + * + * @param string $table + * @return string + */ + protected function _delete($table) + { + $this->qb_limit = FALSE; + return parent::_delete($table); + } + + // -------------------------------------------------------------------- + + /** + * LIMIT + * + * Generates a platform-specific LIMIT clause + * + * @param string $sql SQL Query + * @return string + */ + protected function _limit($sql) + { + $sql .= ' FETCH FIRST '.($this->qb_limit + $this->qb_offset).' ROWS ONLY'; + + return ($this->qb_offset) + ? 'SELECT * FROM ('.$sql.') WHERE rownum > '.$this->qb_offset + : $sql; + } + +} + +/* End of file pdo_ibm_driver.php */ +/* Location: ./system/database/drivers/pdo/subdrivers/pdo_ibm_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/subdrivers/pdo_ibm_forge.php b/system/database/drivers/pdo/subdrivers/pdo_ibm_forge.php new file mode 100755 index 0000000..fc3579f --- /dev/null +++ b/system/database/drivers/pdo/subdrivers/pdo_ibm_forge.php @@ -0,0 +1,146 @@ + 'INTEGER', + 'INT' => 'BIGINT', + 'INTEGER' => 'BIGINT' + ); + + /** + * DEFAULT value representation in CREATE/ALTER TABLE statements + * + * @var string + */ + protected $_default = FALSE; + + // -------------------------------------------------------------------- + + /** + * ALTER TABLE + * + * @param string $alter_type ALTER type + * @param string $table Table name + * @param mixed $field Column definition + * @return string|string[] + */ + protected function _alter_table($alter_type, $table, $field) + { + if ($alter_type === 'CHANGE') + { + $alter_type = 'MODIFY'; + } + + return parent::_alter_table($alter_type, $table, $field); + } + + // -------------------------------------------------------------------- + + /** + * Field attribute TYPE + * + * Performs a data type mapping between different databases. + * + * @param array &$attributes + * @return void + */ + protected function _attr_type(&$attributes) + { + switch (strtoupper($attributes['TYPE'])) + { + case 'TINYINT': + $attributes['TYPE'] = 'SMALLINT'; + $attributes['UNSIGNED'] = FALSE; + return; + case 'MEDIUMINT': + $attributes['TYPE'] = 'INTEGER'; + $attributes['UNSIGNED'] = FALSE; + return; + default: return; + } + } + + // -------------------------------------------------------------------- + + /** + * Field attribute UNIQUE + * + * @param array &$attributes + * @param array &$field + * @return void + */ + protected function _attr_unique(&$attributes, &$field) + { + if ( ! empty($attributes['UNIQUE']) && $attributes['UNIQUE'] === TRUE) + { + $field['unique'] = ' UNIQUE'; + + // UNIQUE must be used with NOT NULL + $field['null'] = ' NOT NULL'; + } + } + + // -------------------------------------------------------------------- + + /** + * Field attribute AUTO_INCREMENT + * + * @param array &$attributes + * @param array &$field + * @return void + */ + protected function _attr_auto_increment(&$attributes, &$field) + { + // Not supported + } + +} + +/* End of file pdo_ibm_forge.php */ +/* Location: ./system/database/drivers/pdo/subdrivers/pdo_ibm_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/subdrivers/pdo_informix_driver.php b/system/database/drivers/pdo/subdrivers/pdo_informix_driver.php new file mode 100755 index 0000000..f28cce1 --- /dev/null +++ b/system/database/drivers/pdo/subdrivers/pdo_informix_driver.php @@ -0,0 +1,301 @@ +dsn)) + { + $this->dsn = 'informix:'; + + // Pre-defined DSN + if (empty($this->hostname) && empty($this->host) && empty($this->port) && empty($this->service)) + { + if (isset($this->DSN)) + { + $this->dsn .= 'DSN='.$this->DSN; + } + elseif ( ! empty($this->database)) + { + $this->dsn .= 'DSN='.$this->database; + } + + return; + } + + if (isset($this->host)) + { + $this->dsn .= 'host='.$this->host; + } + else + { + $this->dsn .= 'host='.(empty($this->hostname) ? '127.0.0.1' : $this->hostname); + } + + if (isset($this->service)) + { + $this->dsn .= '; service='.$this->service; + } + elseif ( ! empty($this->port)) + { + $this->dsn .= '; service='.$this->port; + } + + empty($this->database) OR $this->dsn .= '; database='.$this->database; + empty($this->server) OR $this->dsn .= '; server='.$this->server; + + $this->dsn .= '; protocol='.(isset($this->protocol) ? $this->protocol : 'onsoctcp') + .'; EnableScrollableCursors=1'; + } + } + + // -------------------------------------------------------------------- + + /** + * Show table query + * + * Generates a platform-specific query string so that the table names can be fetched + * + * @param bool $prefix_limit + * @return string + */ + protected function _list_tables($prefix_limit = FALSE) + { + $sql = 'SELECT "tabname" FROM "systables" + WHERE "tabid" > 99 AND "tabtype" = \'T\' AND LOWER("owner") = '.$this->escape(strtolower($this->username)); + + if ($prefix_limit === TRUE && $this->dbprefix !== '') + { + $sql .= ' AND "tabname" LIKE \''.$this->escape_like_str($this->dbprefix)."%' " + .sprintf($this->_like_escape_str, $this->_like_escape_chr); + } + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Show column query + * + * Generates a platform-specific query string so that the column names can be fetched + * + * @param string $table + * @return string + */ + protected function _list_columns($table = '') + { + if (strpos($table, '.') !== FALSE) + { + sscanf($table, '%[^.].%s', $owner, $table); + } + else + { + $owner = $this->username; + } + + return 'SELECT "colname" FROM "systables", "syscolumns" + WHERE "systables"."tabid" = "syscolumns"."tabid" + AND "systables"."tabtype" = \'T\' + AND LOWER("systables"."owner") = '.$this->escape(strtolower($owner)).' + AND LOWER("systables"."tabname") = '.$this->escape(strtolower($table)); + } + + // -------------------------------------------------------------------- + + /** + * Returns an object with field data + * + * @param string $table + * @return array + */ + public function field_data($table = '') + { + $sql = 'SELECT "syscolumns"."colname" AS "name", + CASE "syscolumns"."coltype" + WHEN 0 THEN \'CHAR\' + WHEN 1 THEN \'SMALLINT\' + WHEN 2 THEN \'INTEGER\' + WHEN 3 THEN \'FLOAT\' + WHEN 4 THEN \'SMALLFLOAT\' + WHEN 5 THEN \'DECIMAL\' + WHEN 6 THEN \'SERIAL\' + WHEN 7 THEN \'DATE\' + WHEN 8 THEN \'MONEY\' + WHEN 9 THEN \'NULL\' + WHEN 10 THEN \'DATETIME\' + WHEN 11 THEN \'BYTE\' + WHEN 12 THEN \'TEXT\' + WHEN 13 THEN \'VARCHAR\' + WHEN 14 THEN \'INTERVAL\' + WHEN 15 THEN \'NCHAR\' + WHEN 16 THEN \'NVARCHAR\' + WHEN 17 THEN \'INT8\' + WHEN 18 THEN \'SERIAL8\' + WHEN 19 THEN \'SET\' + WHEN 20 THEN \'MULTISET\' + WHEN 21 THEN \'LIST\' + WHEN 22 THEN \'Unnamed ROW\' + WHEN 40 THEN \'LVARCHAR\' + WHEN 41 THEN \'BLOB/CLOB/BOOLEAN\' + WHEN 4118 THEN \'Named ROW\' + ELSE "syscolumns"."coltype" + END AS "type", + "syscolumns"."collength" as "max_length", + CASE "sysdefaults"."type" + WHEN \'L\' THEN "sysdefaults"."default" + ELSE NULL + END AS "default" + FROM "syscolumns", "systables", "sysdefaults" + WHERE "syscolumns"."tabid" = "systables"."tabid" + AND "systables"."tabid" = "sysdefaults"."tabid" + AND "syscolumns"."colno" = "sysdefaults"."colno" + AND "systables"."tabtype" = \'T\' + AND LOWER("systables"."owner") = '.$this->escape(strtolower($this->username)).' + AND LOWER("systables"."tabname") = '.$this->escape(strtolower($table)).' + ORDER BY "syscolumns"."colno"'; + + return (($query = $this->query($sql)) !== FALSE) + ? $query->result_object() + : FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Update statement + * + * Generates a platform-specific update string from the supplied data + * + * @param string $table + * @param array $values + * @return string + */ + protected function _update($table, $values) + { + $this->qb_limit = FALSE; + $this->qb_orderby = array(); + return parent::_update($table, $values); + } + + // -------------------------------------------------------------------- + + /** + * Truncate statement + * + * Generates a platform-specific truncate string from the supplied data + * + * If the database does not support the TRUNCATE statement, + * then this method maps to 'DELETE FROM table' + * + * @param string $table + * @return string + */ + protected function _truncate($table) + { + return 'TRUNCATE TABLE ONLY '.$table; + } + + // -------------------------------------------------------------------- + + /** + * Delete statement + * + * Generates a platform-specific delete string from the supplied data + * + * @param string $table + * @return string + */ + protected function _delete($table) + { + $this->qb_limit = FALSE; + return parent::_delete($table); + } + + // -------------------------------------------------------------------- + + /** + * LIMIT + * + * Generates a platform-specific LIMIT clause + * + * @param string $sql $SQL Query + * @return string + */ + protected function _limit($sql) + { + $select = 'SELECT '.($this->qb_offset ? 'SKIP '.$this->qb_offset : '').'FIRST '.$this->qb_limit.' '; + return preg_replace('/^(SELECT\s)/i', $select, $sql, 1); + } + +} + +/* End of file pdo_informix_driver.php */ +/* Location: ./system/database/drivers/pdo/subdrivers/pdo_informix_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/subdrivers/pdo_informix_forge.php b/system/database/drivers/pdo/subdrivers/pdo_informix_forge.php new file mode 100755 index 0000000..a2d0bdd --- /dev/null +++ b/system/database/drivers/pdo/subdrivers/pdo_informix_forge.php @@ -0,0 +1,155 @@ + 'INTEGER', + 'INT' => 'BIGINT', + 'INTEGER' => 'BIGINT', + 'REAL' => 'DOUBLE PRECISION', + 'SMALLFLOAT' => 'DOUBLE PRECISION' + ); + + /** + * DEFAULT value representation in CREATE/ALTER TABLE statements + * + * @var string + */ + protected $_default = ', '; + + // -------------------------------------------------------------------- + + /** + * ALTER TABLE + * + * @param string $alter_type ALTER type + * @param string $table Table name + * @param mixed $field Column definition + * @return string|string[] + */ + protected function _alter_table($alter_type, $table, $field) + { + if ($alter_type === 'CHANGE') + { + $alter_type = 'MODIFY'; + } + + return parent::_alter_table($alter_type, $table, $field); + } + + // -------------------------------------------------------------------- + + /** + * Field attribute TYPE + * + * Performs a data type mapping between different databases. + * + * @param array &$attributes + * @return void + */ + protected function _attr_type(&$attributes) + { + switch (strtoupper($attributes['TYPE'])) + { + case 'TINYINT': + $attributes['TYPE'] = 'SMALLINT'; + $attributes['UNSIGNED'] = FALSE; + return; + case 'MEDIUMINT': + $attributes['TYPE'] = 'INTEGER'; + $attributes['UNSIGNED'] = FALSE; + return; + case 'BYTE': + case 'TEXT': + case 'BLOB': + case 'CLOB': + $attributes['UNIQUE'] = FALSE; + if (isset($attributes['DEFAULT'])) + { + unset($attributes['DEFAULT']); + } + return; + default: return; + } + } + + // -------------------------------------------------------------------- + + /** + * Field attribute UNIQUE + * + * @param array &$attributes + * @param array &$field + * @return void + */ + protected function _attr_unique(&$attributes, &$field) + { + if ( ! empty($attributes['UNIQUE']) && $attributes['UNIQUE'] === TRUE) + { + $field['unique'] = ' UNIQUE CONSTRAINT '.$this->db->escape_identifiers($field['name']); + } + } + + // -------------------------------------------------------------------- + + /** + * Field attribute AUTO_INCREMENT + * + * @param array &$attributes + * @param array &$field + * @return void + */ + protected function _attr_auto_increment(&$attributes, &$field) + { + // Not supported + } + +} + +/* End of file pdo_informix_forge.php */ +/* Location: ./system/database/drivers/pdo/subdrivers/pdo_informix_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php b/system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php new file mode 100755 index 0000000..70c405c --- /dev/null +++ b/system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php @@ -0,0 +1,263 @@ +dsn)) + { + $this->dsn = 'mysql:host='.(empty($this->hostname) ? '127.0.0.1' : $this->hostname); + + empty($this->port) OR $this->dsn .= ';port='.$this->port; + empty($this->database) OR $this->dsn .= ';dbname='.$this->database; + empty($this->char_set) OR $this->dsn .= ';charset='.$this->char_set; + } + elseif ( ! empty($this->char_set) && strpos($this->dsn, 'charset=', 6) === FALSE && is_php('5.3.6')) + { + $this->dsn .= ';charset='.$this->char_set; + } + } + + // -------------------------------------------------------------------- + + /** + * Database connection + * + * @param bool $persistent + * @return object + * @todo SSL support + */ + public function db_connect($persistent = FALSE) + { + /* Prior to PHP 5.3.6, even if the charset was supplied in the DSN + * on connect - it was ignored. This is a work-around for the issue. + * + * Reference: http://www.php.net/manual/en/ref.pdo-mysql.connection.php + */ + if ( ! is_php('5.3.6') && ! empty($this->char_set)) + { + $this->options[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET NAMES '.$this->char_set + .(empty($this->dbcollat) ? '' : ' COLLATE '.$this->dbcollat); + } + + if ($this->stricton) + { + if (empty($this->options[PDO::MYSQL_ATTR_INIT_COMMAND])) + { + $this->options[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET SESSION sql_mode="STRICT_ALL_TABLES"'; + } + else + { + $this->options[PDO::MYSQL_ATTR_INIT_COMMAND] .= ', @@session.sql_mode = "STRICT_ALL_TABLES"'; + } + } + + if ($this->compress === TRUE) + { + $this->options[PDO::MYSQL_ATTR_COMPRESS] = TRUE; + } + + return parent::db_connect($persistent); + } + + // -------------------------------------------------------------------- + + /** + * Show table query + * + * Generates a platform-specific query string so that the table names can be fetched + * + * @param bool $prefix_limit + * @return string + */ + protected function _list_tables($prefix_limit = FALSE) + { + $sql = 'SHOW TABLES'; + + if ($prefix_limit === TRUE && $this->dbprefix !== '') + { + return $sql." LIKE '".$this->escape_like_str($this->dbprefix)."%'"; + } + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Show column query + * + * Generates a platform-specific query string so that the column names can be fetched + * + * @param string $table + * @return string + */ + protected function _list_columns($table = '') + { + return 'SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE); + } + + // -------------------------------------------------------------------- + + /** + * Returns an object with field data + * + * @param string $table + * @return array + */ + public function field_data($table = '') + { + if ($table === '') + { + return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; + } + + if (($query = $this->query('SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE))) === FALSE) + { + return FALSE; + } + $query = $query->result_object(); + + $retval = array(); + for ($i = 0, $c = count($query); $i < $c; $i++) + { + $retval[$i] = new stdClass(); + $retval[$i]->name = $query[$i]->Field; + + sscanf($query[$i]->Type, '%[a-z](%d)', + $retval[$i]->type, + $retval[$i]->max_length + ); + + $retval[$i]->default = $query[$i]->Default; + $retval[$i]->primary_key = (int) ($query[$i]->Key === 'PRI'); + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Truncate statement + * + * Generates a platform-specific truncate string from the supplied data + * + * If the database does not support the TRUNCATE statement, + * then this method maps to 'DELETE FROM table' + * + * @param string $table + * @return string + */ + protected function _truncate($table) + { + return 'TRUNCATE '.$table; + } + + // -------------------------------------------------------------------- + + /** + * FROM tables + * + * Groups tables in FROM clauses if needed, so there is no confusion + * about operator precedence. + * + * @return string + */ + protected function _from_tables() + { + if ( ! empty($this->qb_join) && count($this->qb_from) > 1) + { + return '('.implode(', ', $this->qb_from).')'; + } + + return implode(', ', $this->qb_from); + } + +} + +/* End of file pdo_mysql_driver.php */ +/* Location: ./system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php b/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php new file mode 100755 index 0000000..d2e1e28 --- /dev/null +++ b/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php @@ -0,0 +1,247 @@ +db->char_set) && ! strpos($sql, 'CHARACTER SET') && ! strpos($sql, 'CHARSET')) + { + $sql .= ' DEFAULT CHARACTER SET = '.$this->db->char_set; + } + + if ( ! empty($this->db->dbcollat) && ! strpos($sql, 'COLLATE')) + { + $sql .= ' COLLATE = '.$this->db->dbcollat; + } + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * ALTER TABLE + * + * @param string $alter_type ALTER type + * @param string $table Table name + * @param mixed $field Column definition + * @return string|string[] + */ + protected function _alter_table($alter_type, $table, $field) + { + if ($alter_type === 'DROP') + { + return parent::_alter_table($alter_type, $table, $field); + } + + $sql = 'ALTER TABLE '.$this->db->escape_identifiers($table); + for ($i = 0, $c = count($field); $i < $c; $i++) + { + if ($field[$i]['_literal'] !== FALSE) + { + $field[$i] = ($alter_type === 'ADD') + ? "\n\tADD ".$field[$i]['_literal'] + : "\n\tMODIFY ".$field[$i]['_literal']; + } + else + { + if ($alter_type === 'ADD') + { + $field[$i]['_literal'] = "\n\tADD "; + } + else + { + $field[$i]['_literal'] = empty($field[$i]['new_name']) ? "\n\tMODIFY " : "\n\tCHANGE "; + } + + $field[$i] = $field[$i]['_literal'].$this->_process_column($field[$i]); + } + } + + return array($sql.implode(',', $field)); + } + + // -------------------------------------------------------------------- + + /** + * Process column + * + * @param array $field + * @return string + */ + protected function _process_column($field) + { + $extra_clause = isset($field['after']) + ? ' AFTER '.$this->db->escape_identifiers($field['after']) : ''; + + if (empty($extra_clause) && isset($field['first']) && $field['first'] === TRUE) + { + $extra_clause = ' FIRST'; + } + + return $this->db->escape_identifiers($field['name']) + .(empty($field['new_name']) ? '' : ' '.$this->db->escape_identifiers($field['new_name'])) + .' '.$field['type'].$field['length'] + .$field['unsigned'] + .$field['null'] + .$field['default'] + .$field['auto_increment'] + .$field['unique'] + .$extra_clause; + } + + // -------------------------------------------------------------------- + + /** + * Process indexes + * + * @param string $table (ignored) + * @return string + */ + protected function _process_indexes($table) + { + $sql = ''; + + for ($i = 0, $c = count($this->keys); $i < $c; $i++) + { + if (is_array($this->keys[$i])) + { + for ($i2 = 0, $c2 = count($this->keys[$i]); $i2 < $c2; $i2++) + { + if ( ! isset($this->fields[$this->keys[$i][$i2]])) + { + unset($this->keys[$i][$i2]); + continue; + } + } + } + elseif ( ! isset($this->fields[$this->keys[$i]])) + { + unset($this->keys[$i]); + continue; + } + + is_array($this->keys[$i]) OR $this->keys[$i] = array($this->keys[$i]); + + $sql .= ",\n\tKEY ".$this->db->escape_identifiers(implode('_', $this->keys[$i])) + .' ('.implode(', ', $this->db->escape_identifiers($this->keys[$i])).')'; + } + + $this->keys = array(); + + return $sql; + } + +} + +/* End of file pdo_mysql_forge.php */ +/* Location: ./system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/subdrivers/pdo_oci_driver.php b/system/database/drivers/pdo/subdrivers/pdo_oci_driver.php new file mode 100755 index 0000000..6fef078 --- /dev/null +++ b/system/database/drivers/pdo/subdrivers/pdo_oci_driver.php @@ -0,0 +1,291 @@ +dsn)) + { + $this->dsn = 'oci:dbname='; + + // Oracle has a slightly different PDO DSN format (Easy Connect), + // which also supports pre-defined DSNs. + if (empty($this->hostname) && empty($this->port)) + { + $this->dsn .= $this->database; + } + else + { + $this->dsn .= '//'.(empty($this->hostname) ? '127.0.0.1' : $this->hostname) + .(empty($this->port) ? '' : ':'.$this->port).'/'; + + empty($this->database) OR $this->dsn .= $this->database; + } + + empty($this->char_set) OR $this->dsn .= ';charset='.$this->char_set; + } + elseif ( ! empty($this->char_set) && strpos($this->dsn, 'charset=', 4) === FALSE) + { + $this->dsn .= ';charset='.$this->char_set; + } + } + + // -------------------------------------------------------------------- + + /** + * Show table query + * + * Generates a platform-specific query string so that the table names can be fetched + * + * @param bool $prefix_limit + * @return string + */ + protected function _list_tables($prefix_limit = FALSE) + { + $sql = 'SELECT "TABLE_NAME" FROM "ALL_TABLES"'; + + if ($prefix_limit === TRUE && $this->dbprefix !== '') + { + return $sql.' WHERE "TABLE_NAME" LIKE \''.$this->escape_like_str($this->dbprefix)."%' " + .sprintf($this->_like_escape_str, $this->_like_escape_chr); + } + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Show column query + * + * Generates a platform-specific query string so that the column names can be fetched + * + * @param string $table + * @return string + */ + protected function _list_columns($table = '') + { + if (strpos($table, '.') !== FALSE) + { + sscanf($table, '%[^.].%s', $owner, $table); + } + else + { + $owner = $this->username; + } + + return 'SELECT COLUMN_NAME FROM ALL_TAB_COLUMNS + WHERE UPPER(OWNER) = '.$this->escape(strtoupper($owner)).' + AND UPPER(TABLE_NAME) = '.$this->escape(strtoupper($table)); + } + + // -------------------------------------------------------------------- + + /** + * Returns an object with field data + * + * @param string $table + * @return array + */ + public function field_data($table = '') + { + if ($table === '') + { + return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; + } + elseif (strpos($table, '.') !== FALSE) + { + sscanf($table, '%[^.].%s', $owner, $table); + } + else + { + $owner = $this->username; + } + + $sql = 'SELECT COLUMN_NAME, DATA_TYPE, CHAR_LENGTH, DATA_PRECISION, DATA_LENGTH, DATA_DEFAULT, NULLABLE + FROM ALL_TAB_COLUMNS + WHERE UPPER(OWNER) = '.$this->escape(strtoupper($owner)).' + AND UPPER(TABLE_NAME) = '.$this->escape(strtoupper($table)); + + if (($query = $this->query($sql)) === FALSE) + { + return FALSE; + } + $query = $query->result_object(); + + $retval = array(); + for ($i = 0, $c = count($query); $i < $c; $i++) + { + $retval[$i] = new stdClass(); + $retval[$i]->name = $query[$i]->COLUMN_NAME; + $retval[$i]->type = $query[$i]->DATA_TYPE; + + $length = ($query[$i]->CHAR_LENGTH > 0) + ? $query[$i]->CHAR_LENGTH : $query[$i]->DATA_PRECISION; + if ($length === NULL) + { + $length = $query[$i]->DATA_LENGTH; + } + $retval[$i]->max_length = $length; + + $default = $query[$i]->DATA_DEFAULT; + if ($default === NULL && $query[$i]->NULLABLE === 'N') + { + $default = ''; + } + $retval[$i]->default = $query[$i]->COLUMN_DEFAULT; + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Insert batch statement + * + * @param string $table Table name + * @param array $keys INSERT keys + * @param array $values INSERT values + * @return string + */ + protected function _insert_batch($table, $keys, $values) + { + $keys = implode(', ', $keys); + $sql = "INSERT ALL\n"; + + for ($i = 0, $c = count($values); $i < $c; $i++) + { + $sql .= ' INTO '.$table.' ('.$keys.') VALUES '.$values[$i]."\n"; + } + + return $sql.'SELECT * FROM dual'; + } + + // -------------------------------------------------------------------- + + /** + * Delete statement + * + * Generates a platform-specific delete string from the supplied data + * + * @param string $table + * @return string + */ + protected function _delete($table) + { + if ($this->qb_limit) + { + $this->where('rownum <= ',$this->qb_limit, FALSE); + $this->qb_limit = FALSE; + } + + return parent::_delete($table); + } + + // -------------------------------------------------------------------- + + /** + * LIMIT + * + * Generates a platform-specific LIMIT clause + * + * @param string $sql SQL Query + * @return string + */ + protected function _limit($sql) + { + return 'SELECT * FROM (SELECT inner_query.*, rownum rnum FROM ('.$sql.') inner_query WHERE rownum < '.($this->qb_offset + $this->qb_limit + 1).')' + .($this->qb_offset ? ' WHERE rnum >= '.($this->qb_offset + 1): ''); + } + +} + +/* End of file pdo_oci_driver.php */ +/* Location: ./system/database/drivers/pdo/subdrivers/pdo_oci_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/subdrivers/pdo_oci_forge.php b/system/database/drivers/pdo/subdrivers/pdo_oci_forge.php new file mode 100755 index 0000000..dbbff5b --- /dev/null +++ b/system/database/drivers/pdo/subdrivers/pdo_oci_forge.php @@ -0,0 +1,133 @@ +db->escape_identifiers($table); + $sqls = array(); + for ($i = 0, $c = count($field); $i < $c; $i++) + { + if ($field[$i]['_literal'] !== FALSE) + { + $field[$i] = "\n\t".$field[$i]['_literal']; + } + else + { + $field[$i]['_literal'] = "\n\t".$this->_process_column($field[$i]); + if ($alter_type === 'MODIFY' && ! empty($field[$i]['new_name'])) + { + $sqls[] = $sql.' RENAME COLUMN '.$this->db->escape_identifiers($field[$i]['name']) + .' '.$this->db->escape_identifiers($field[$i]['new_name']); + } + } + } + + $sql .= ' '.$alter_type.' '; + $sql .= (count($field) === 1) + ? $field[0] + : '('.implode(',', $field).')'; + + // RENAME COLUMN must be executed after MODIFY + array_unshift($sqls, $sql); + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Field attribute AUTO_INCREMENT + * + * @param array &$attributes + * @param array &$field + * @return void + */ + protected function _attr_auto_increment(&$attributes, &$field) + { + // Not supported - sequences and triggers must be used instead + } + +} + +/* End of file pdo_oci_forge.php */ +/* Location: ./system/database/drivers/pdo/subdrivers/pdo_oci_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/subdrivers/pdo_odbc_driver.php b/system/database/drivers/pdo/subdrivers/pdo_odbc_driver.php new file mode 100755 index 0000000..c95fe18 --- /dev/null +++ b/system/database/drivers/pdo/subdrivers/pdo_odbc_driver.php @@ -0,0 +1,258 @@ +dsn)) + { + $this->dsn = 'odbc:'; + + // Pre-defined DSN + if (empty($this->hostname) && empty($this->HOSTNAME) && empty($this->port) && empty($this->PORT)) + { + if (isset($this->DSN)) + { + $this->dsn .= 'DSN='.$this->DSN; + } + elseif ( ! empty($this->database)) + { + $this->dsn .= 'DSN='.$this->database; + } + + return; + } + + // If the DSN is not pre-configured - try to build an IBM DB2 connection string + $this->dsn .= 'DRIVER='.(isset($this->DRIVER) ? '{'.$this->DRIVER.'}' : '{IBM DB2 ODBC DRIVER}').';'; + + if (isset($this->DATABASE)) + { + $this->dsn .= 'DATABASE='.$this->DATABASE.';'; + } + elseif ( ! empty($this->database)) + { + $this->dsn .= 'DATABASE='.$this->database.';'; + } + + if (isset($this->HOSTNAME)) + { + $this->dsn .= 'HOSTNAME='.$this->HOSTNAME.';'; + } + else + { + $this->dsn .= 'HOSTNAME='.(empty($this->hostname) ? '127.0.0.1;' : $this->hostname.';'); + } + + if (isset($this->PORT)) + { + $this->dsn .= 'PORT='.$this->port.';'; + } + elseif ( ! empty($this->port)) + { + $this->dsn .= ';PORT='.$this->port.';'; + } + + $this->dsn .= 'PROTOCOL='.(isset($this->PROTOCOL) ? $this->PROTOCOL.';' : 'TCPIP;'); + } + } + + // -------------------------------------------------------------------- + + /** + * Show table query + * + * Generates a platform-specific query string so that the table names can be fetched + * + * @param bool $prefix_limit + * @return string + */ + protected function _list_tables($prefix_limit = FALSE) + { + $sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = '".$this->schema."'"; + + if ($prefix_limit !== FALSE && $this->dbprefix !== '') + { + return $sql." AND table_name LIKE '".$this->escape_like_str($this->dbprefix)."%' " + .sprintf($this->_like_escape_str, $this->_like_escape_chr); + } + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Show column query + * + * Generates a platform-specific query string so that the column names can be fetched + * + * @param string $table + * @return string + */ + protected function _list_columns($table = '') + { + return 'SELECT column_name FROM information_schema.columns WHERE table_name = '.$this->escape($table); + } + + // -------------------------------------------------------------------- + + /** + * Update statement + * + * Generates a platform-specific update string from the supplied data + * + * @param string $table + * @param array $values + * @return string + */ + protected function _update($table, $values) + { + $this->qb_limit = FALSE; + $this->qb_orderby = array(); + return parent::_update($table, $values); + } + + // -------------------------------------------------------------------- + + /** + * Truncate statement + * + * Generates a platform-specific truncate string from the supplied data + * + * If the database does not support the TRUNCATE statement, + * then this method maps to 'DELETE FROM table' + * + * @param string $table + * @return string + */ + protected function _truncate($table) + { + return 'DELETE FROM '.$table; + } + + // -------------------------------------------------------------------- + + /** + * Delete statement + * + * Generates a platform-specific delete string from the supplied data + * + * @param string the table name + * @return string + */ + protected function _delete($table) + { + $this->qb_limit = FALSE; + return parent::_delete($table); + } + + // -------------------------------------------------------------------- + + /** + * LIMIT + * + * Generates a platform-specific LIMIT clause + * + * @param string $sql SQL Query + * @return string + */ + protected function _limit($sql) + { + return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$this->qb_limit.' ', $sql); + } + +} + +/* End of file pdo_odbc_driver.php */ +/* Location: ./system/database/drivers/pdo/subdrivers/pdo_odbc_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/subdrivers/pdo_odbc_forge.php b/system/database/drivers/pdo/subdrivers/pdo_odbc_forge.php new file mode 100755 index 0000000..e7feacd --- /dev/null +++ b/system/database/drivers/pdo/subdrivers/pdo_odbc_forge.php @@ -0,0 +1,62 @@ +dsn)) + { + $this->dsn = 'pgsql:host='.(empty($this->hostname) ? '127.0.0.1' : $this->hostname); + + empty($this->port) OR $this->dsn .= ';port='.$this->port; + empty($this->database) OR $this->dsn .= ';dbname='.$this->database; + + if ( ! empty($this->username)) + { + $this->dsn .= ';username='.$this->username; + empty($this->password) OR $this->dsn .= ';password='.$this->password; + } + } + } + + // -------------------------------------------------------------------- + + /** + * Database connection + * + * @param bool $persistent + * @return object + */ + public function db_connect($persistent = FALSE) + { + $this->conn_id = parent::db_connect($persistent); + + if (is_object($this->conn_id) && ! empty($this->schema)) + { + $this->simple_query('SET search_path TO '.$this->schema.',public'); + } + + return $this->conn_id; + } + + // -------------------------------------------------------------------- + + /** + * Insert ID + * + * @param string $name + * @return int + */ + public function insert_id($name = NULL) + { + if ($name === NULL && version_compare($this->version(), '8.1', '>=')) + { + $query = $this->query('SELECT LASTVAL() AS ins_id'); + $query = $query->row(); + return $query->ins_id; + } + + return $this->conn_id->lastInsertId($name); + } + + // -------------------------------------------------------------------- + + /** + * Determines if a query is a "write" type. + * + * @param string An SQL query string + * @return bool + */ + public function is_write_type($sql) + { + return (bool) preg_match('/^\s*"?(SET|INSERT(?![^\)]+\)\s+RETURNING)|UPDATE(?!.*\sRETURNING)|DELETE|CREATE|DROP|TRUNCATE|LOAD|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK|REINDEX)\s/i', str_replace(array("\r\n", "\r", "\n"), ' ', $sql)); + } + + // -------------------------------------------------------------------- + + /** + * "Smart" Escape String + * + * Escapes data based on type + * + * @param string $str + * @return mixed + */ + public function escape($str) + { + if (is_bool($str)) + { + return ($str) ? 'TRUE' : 'FALSE'; + } + + return parent::escape($str); + } + + // -------------------------------------------------------------------- + + /** + * ORDER BY + * + * @param string $orderby + * @param string $direction ASC, DESC or RANDOM + * @param bool $escape + * @return object + */ + public function order_by($orderby, $direction = '', $escape = NULL) + { + $direction = strtoupper(trim($direction)); + if ($direction === 'RANDOM') + { + if ( ! is_float($orderby) && ctype_digit((string) $orderby)) + { + $orderby = ($orderby > 1) + ? (float) '0.'.$orderby + : (float) $orderby; + } + + if (is_float($orderby)) + { + $this->simple_query('SET SEED '.$orderby); + } + + $orderby = $this->_random_keyword[0]; + $direction = ''; + $escape = FALSE; + } + + return parent::order_by($orderby, $direction, $escape); + } + + // -------------------------------------------------------------------- + + /** + * Show table query + * + * Generates a platform-specific query string so that the table names can be fetched + * + * @param bool $prefix_limit + * @return string + */ + protected function _list_tables($prefix_limit = FALSE) + { + $sql = 'SELECT "table_name" FROM "information_schema"."tables" WHERE "table_schema" = \''.$this->schema."'"; + + if ($prefix_limit === TRUE && $this->dbprefix !== '') + { + return $sql.' AND "table_name" LIKE \'' + .$this->escape_like_str($this->dbprefix)."%' " + .sprintf($this->_like_escape_str, $this->_like_escape_chr); + } + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * List column query + * + * Generates a platform-specific query string so that the column names can be fetched + * + * @param string $table + * @return string + */ + protected function _list_columns($table = '') + { + return 'SELECT "column_name" + FROM "information_schema"."columns" + WHERE LOWER("table_name") = '.$this->escape(strtolower($table)); + } + + // -------------------------------------------------------------------- + + /** + * Returns an object with field data + * + * @param string $table + * @return array + */ + public function field_data($table = '') + { + if ($table === '') + { + return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; + } + + $sql = 'SELECT "column_name", "data_type", "character_maximum_length", "numeric_precision", "column_default" + FROM "information_schema"."columns" + WHERE LOWER("table_name") = '.$this->escape(strtolower($table)); + + if (($query = $this->query($sql)) === FALSE) + { + return FALSE; + } + $query = $query->result_object(); + + $retval = array(); + for ($i = 0, $c = count($query); $i < $c; $i++) + { + $retval[$i] = new stdClass(); + $retval[$i]->name = $query[$i]->column_name; + $retval[$i]->type = $query[$i]->data_type; + $retval[$i]->max_length = ($query[$i]->character_maximum_length > 0) ? $query[$i]->character_maximum_length : $query[$i]->numeric_precision; + $retval[$i]->default = $query[$i]->column_default; + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Update statement + * + * Generates a platform-specific update string from the supplied data + * + * @param string $table + * @param array $values + * @return string + */ + protected function _update($table, $values) + { + $this->qb_limit = FALSE; + $this->qb_orderby = array(); + return parent::_update($table, $values); + } + + // -------------------------------------------------------------------- + + /** + * Update_Batch statement + * + * Generates a platform-specific batch update string from the supplied data + * + * @param string $table Table name + * @param array $values Update data + * @param string $index WHERE key + * @return string + */ + protected function _update_batch($table, $values, $index) + { + $ids = array(); + foreach ($values as $key => $val) + { + $ids[] = $val[$index]; + + foreach (array_keys($val) as $field) + { + if ($field !== $index) + { + $final[$field][] = 'WHEN '.$val[$index].' THEN '.$val[$field]; + } + } + } + + $cases = ''; + foreach ($final as $k => $v) + { + $cases .= $k.' = (CASE '.$index."\n" + .implode("\n", $v)."\n" + .'ELSE '.$k.' END), '; + } + + $this->where($index.' IN('.implode(',', $ids).')', NULL, FALSE); + + return 'UPDATE '.$table.' SET '.substr($cases, 0, -2).$this->_compile_wh('qb_where'); + } + + // -------------------------------------------------------------------- + + /** + * Delete statement + * + * Generates a platform-specific delete string from the supplied data + * + * @param string $table + * @return string + */ + protected function _delete($table) + { + $this->qb_limit = FALSE; + return parent::_delete($table); + } + + // -------------------------------------------------------------------- + + /** + * LIMIT + * + * Generates a platform-specific LIMIT clause + * + * @param string $sql SQL Query + * @return string + */ + protected function _limit($sql) + { + return $sql.' LIMIT '.$this->qb_limit.($this->qb_offset ? ' OFFSET '.$this->qb_offset : ''); + } + +} + +/* End of file pdo_pgsql_driver.php */ +/* Location: ./system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/subdrivers/pdo_pgsql_forge.php b/system/database/drivers/pdo/subdrivers/pdo_pgsql_forge.php new file mode 100755 index 0000000..cdaa202 --- /dev/null +++ b/system/database/drivers/pdo/subdrivers/pdo_pgsql_forge.php @@ -0,0 +1,195 @@ + 'INTEGER', + 'SMALLINT' => 'INTEGER', + 'INT' => 'BIGINT', + 'INT4' => 'BIGINT', + 'INTEGER' => 'BIGINT', + 'INT8' => 'NUMERIC', + 'BIGINT' => 'NUMERIC', + 'REAL' => 'DOUBLE PRECISION', + 'FLOAT' => 'DOUBLE PRECISION' + ); + + /** + * NULL value representation in CREATE/ALTER TABLE statements + * + * @var string + */ + protected $_null = 'NULL'; + + // -------------------------------------------------------------------- + + /** + * Class constructor + * + * @param object &$db Database object + * @return void + */ + public function __construct(&$db) + { + parent::__construct($db); + + if (version_compare($this->db->version(), '9.0', '>')) + { + $this->create_table_if = 'CREATE TABLE IF NOT EXISTS'; + } + } + + // -------------------------------------------------------------------- + + /** + * ALTER TABLE + * + * @param string $alter_type ALTER type + * @param string $table Table name + * @param mixed $field Column definition + * @return string|string[] + */ + protected function _alter_table($alter_type, $table, $field) + { + if (in_array($alter_type, array('DROP', 'ADD'), TRUE)) + { + return parent::_alter_table($alter_type, $table, $field); + } + + $sql = 'ALTER TABLE '.$this->db->escape_identifiers($table); + $sqls = array(); + for ($i = 0, $c = count($field); $i < $c; $i++) + { + if ($field[$i]['_literal'] !== FALSE) + { + return FALSE; + } + + if (version_compare($this->db->version(), '8', '>=') && isset($field[$i]['type'])) + { + $sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identifiers($field[$i]['name']) + .' TYPE '.$field[$i]['type'].$field[$i]['length']; + } + + if ( ! empty($field[$i]['default'])) + { + $sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identifiers($field[$i]['name']) + .' SET DEFAULT '.$field[$i]['default']; + } + + if (isset($field[$i]['null'])) + { + $sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identifiers($field[$i]['name']) + .($field[$i]['null'] === TRUE ? ' DROP NOT NULL' : ' SET NOT NULL'); + } + + if ( ! empty($field[$i]['new_name'])) + { + $sqls[] = $sql.' RENAME COLUMN '.$this->db->escape_identifiers($field[$i]['name']) + .' TO '.$this->db->escape_identifiers($field[$i]['new_name']); + } + } + + return $sqls; + } + + // -------------------------------------------------------------------- + + /** + * Field attribute TYPE + * + * Performs a data type mapping between different databases. + * + * @param array &$attributes + * @return void + */ + protected function _attr_type(&$attributes) + { + // Reset field lenghts for data types that don't support it + if (isset($attributes['CONSTRAINT']) && stripos($attributes['TYPE'], 'int') !== FALSE) + { + $attributes['CONSTRAINT'] = NULL; + } + + switch (strtoupper($attributes['TYPE'])) + { + case 'TINYINT': + $attributes['TYPE'] = 'SMALLINT'; + $attributes['UNSIGNED'] = FALSE; + return; + case 'MEDIUMINT': + $attributes['TYPE'] = 'INTEGER'; + $attributes['UNSIGNED'] = FALSE; + return; + default: return; + } + } + + // -------------------------------------------------------------------- + + /** + * Field attribute AUTO_INCREMENT + * + * @param array &$attributes + * @param array &$field + * @return void + */ + protected function _attr_auto_increment(&$attributes, &$field) + { + if ( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE) + { + $field['type'] = ($field['type'] === 'NUMERIC') + ? 'BIGSERIAL' + : 'SERIAL'; + } + } + +} + +/* End of file pdo_pgsql_forge.php */ +/* Location: ./system/database/drivers/pdo/subdrivers/pdo_pgsql_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/subdrivers/pdo_sqlite_driver.php b/system/database/drivers/pdo/subdrivers/pdo_sqlite_driver.php new file mode 100755 index 0000000..a91f00b --- /dev/null +++ b/system/database/drivers/pdo/subdrivers/pdo_sqlite_driver.php @@ -0,0 +1,202 @@ +dsn)) + { + $this->dsn = 'sqlite:'; + + if (empty($this->database) && empty($this->hostname)) + { + $this->database = ':memory:'; + } + + $this->database = empty($this->database) ? $this->hostname : $this->database; + } + } + + // -------------------------------------------------------------------- + + /** + * Show table query + * + * Generates a platform-specific query string so that the table names can be fetched + * + * @param bool $prefix_limit + * @return string + */ + protected function _list_tables($prefix_limit = FALSE) + { + $sql = 'SELECT "NAME" FROM "SQLITE_MASTER" WHERE "TYPE" = \'table\''; + + if ($prefix_limit === TRUE && $this->dbprefix !== '') + { + return $sql.' AND "NAME" LIKE \''.$this->escape_like_str($this->dbprefix)."%' " + .sprintf($this->_like_escape_str, $this->_like_escape_chr); + } + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Show column query + * + * Generates a platform-specific query string so that the column names can be fetched + * + * @param string $table + * @return string + */ + protected function _list_columns($table = '') + { + // Not supported + return FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Returns an object with field data + * + * @param string $table + * @return array + */ + public function field_data($table = '') + { + if ($table === '') + { + return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; + } + + if (($query = $this->query('PRAGMA TABLE_INFO('.$this->protect_identifiers($table, TRUE, NULL, FALSE).')')) === FALSE) + { + return FALSE; + } + + $query = $query->result_array(); + if (empty($query)) + { + return FALSE; + } + + $retval = array(); + for ($i = 0, $c = count($query); $i < $c; $i++) + { + $retval[$i] = new stdClass(); + $retval[$i]->name = $query[$i]['name']; + $retval[$i]->type = $query[$i]['type']; + $retval[$i]->max_length = NULL; + $retval[$i]->default = $query[$i]['dflt_value']; + $retval[$i]->primary_key = isset($query[$i]['pk']) ? (int) $query[$i]['pk'] : 0; + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Replace statement + * + * @param string $table Table name + * @param array $keys INSERT keys + * @param array $values INSERT values + * @return string + */ + protected function _replace($table, $keys, $values) + { + return 'INSERT OR '.parent::_replace($table, $keys, $values); + } + + // -------------------------------------------------------------------- + + /** + * Truncate statement + * + * Generates a platform-specific truncate string from the supplied data + * + * If the database does not support the TRUNCATE statement, + * then this method maps to 'DELETE FROM table' + * + * @param string $table + * @return string + */ + protected function _truncate($table) + { + return 'DELETE FROM '.$table; + } + +} + +/* End of file pdo_sqlite_driver.php */ +/* Location: ./system/database/drivers/pdo/subdrivers/pdo_sqlite_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/subdrivers/pdo_sqlite_forge.php b/system/database/drivers/pdo/subdrivers/pdo_sqlite_forge.php new file mode 100755 index 0000000..9b0725e --- /dev/null +++ b/system/database/drivers/pdo/subdrivers/pdo_sqlite_forge.php @@ -0,0 +1,229 @@ +db->version(), '3.3', '<')) + { + $this->_create_table_if = FALSE; + } + } + + // -------------------------------------------------------------------- + + /** + * Create database + * + * @param string $db_name (ignored) + * @return bool + */ + public function create_database($db_name = '') + { + // 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 + * + * @param string $db_name (ignored) + * @return bool + */ + public function drop_database($db_name = '') + { + // In SQLite, a database is dropped when we delete a file + if (file_exists($this->db->database)) + { + // We need to close the pseudo-connection first + $this->db->close(); + if ( ! @unlink($this->db->database)) + { + return $this->db->db_debug ? $this->db->display_error('db_unable_to_drop') : FALSE; + } + elseif ( ! empty($this->db->data_cache['db_names'])) + { + $key = array_search(strtolower($this->db->database), array_map('strtolower', $this->db->data_cache['db_names']), TRUE); + if ($key !== FALSE) + { + unset($this->db->data_cache['db_names'][$key]); + } + } + + return TRUE; + } + + return $this->db->db_debug ? $this->db->display_error('db_unable_to_drop') : FALSE; + } + + // -------------------------------------------------------------------- + + /** + * ALTER TABLE + * + * @param string $alter_type ALTER type + * @param string $table Table name + * @param mixed $field Column definition + * @return string|string[] + */ + protected function _alter_table($alter_type, $table, $field) + { + if ($alter_type === 'DROP' OR $alter_type === 'CHANGE') + { + // drop_column(): + // BEGIN TRANSACTION; + // CREATE TEMPORARY TABLE t1_backup(a,b); + // INSERT INTO t1_backup SELECT a,b FROM t1; + // DROP TABLE t1; + // CREATE TABLE t1(a,b); + // INSERT INTO t1 SELECT a,b FROM t1_backup; + // DROP TABLE t1_backup; + // COMMIT; + + return FALSE; + } + + return parent::_alter_table($alter_type, $table, $field); + } + + // -------------------------------------------------------------------- + + /** + * Process column + * + * @param array $field + * @return string + */ + protected function _process_column($field) + { + return $this->db->escape_identifiers($field['name']) + .' '.$field['type'] + .$field['auto_increment'] + .$field['null'] + .$field['unique'] + .$field['default']; + } + + // -------------------------------------------------------------------- + + /** + * Field attribute TYPE + * + * Performs a data type mapping between different databases. + * + * @param array &$attributes + * @return void + */ + protected function _attr_type(&$attributes) + { + switch (strtoupper($attributes['TYPE'])) + { + case 'ENUM': + case 'SET': + $attributes['TYPE'] = 'TEXT'; + return; + default: return; + } + } + + // -------------------------------------------------------------------- + + /** + * Field attribute AUTO_INCREMENT + * + * @param array &$attributes + * @param array &$field + * @return void + */ + protected function _attr_auto_increment(&$attributes, &$field) + { + if ( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE && stripos($field['type'], 'int') !== FALSE) + { + $field['type'] = 'INTEGER PRIMARY KEY'; + $field['default'] = ''; + $field['null'] = ''; + $field['unique'] = ''; + $field['auto_increment'] = ' AUTOINCREMENT'; + + $this->primary_keys = array(); + } + } + +} + +/* End of file pdo_sqlite_forge.php */ +/* Location: ./system/database/drivers/pdo/subdrivers/pdo_sqlite_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php b/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php new file mode 100755 index 0000000..ba004d5 --- /dev/null +++ b/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php @@ -0,0 +1,363 @@ +dsn)) + { + $this->dsn = 'sqlsrv:Server='.(empty($this->hostname) ? '127.0.0.1' : $this->hostname); + + empty($this->port) OR $this->dsn .= ','.$this->port; + empty($this->database) OR $this->dsn .= ';Database='.$this->database; + + // Some custom options + + if (isset($this->QuotedId)) + { + $this->dsn .= ';QuotedId='.$this->QuotedId; + $this->_quoted_identifier = (bool) $this->QuotedId; + } + + if (isset($this->ConnectionPooling)) + { + $this->dsn .= ';ConnectionPooling='.$this->ConnectionPooling; + } + + if ($this->encrypt === TRUE) + { + $this->dsn .= ';Encrypt=1'; + } + + if (isset($this->TraceOn)) + { + $this->dsn .= ';TraceOn='.$this->TraceOn; + } + + if (isset($this->TrustServerCertificate)) + { + $this->dsn .= ';TrustServerCertificate='.$this->TrustServerCertificate; + } + + empty($this->APP) OR $this->dsn .= ';APP='.$this->APP; + empty($this->Failover_Partner) OR $this->dsn .= ';Failover_Partner='.$this->Failover_Partner; + empty($this->LoginTimeout) OR $this->dsn .= ';LoginTimeout='.$this->LoginTimeout; + empty($this->MultipleActiveResultSets) OR $this->dsn .= ';MultipleActiveResultSets='.$this->MultipleActiveResultSets; + empty($this->TraceFile) OR $this->dsn .= ';TraceFile='.$this->TraceFile; + empty($this->WSID) OR $this->dsn .= ';WSID='.$this->WSID; + } + elseif (preg_match('/QuotedId=(0|1)/', $this->dsn, $match)) + { + $this->_quoted_identifier = (bool) $match[1]; + } + } + + // -------------------------------------------------------------------- + + /** + * Database connection + * + * @param bool $persistent + * @return object + */ + public function db_connect($persistent = FALSE) + { + if ( ! empty($this->char_set) && preg_match('/utf[^8]*8/i', $this->char_set)) + { + $this->options[PDO::SQLSRV_ENCODING_UTF8] = 1; + } + + $this->conn_id = parent::db_connect($persistent); + + if ( ! is_object($this->conn_id) OR is_bool($this->_quoted_identifier)) + { + return $this->conn_id; + } + + // Determine how identifiers are escaped + $query = $this->query('SELECT CASE WHEN (@@OPTIONS | 256) = @@OPTIONS THEN 1 ELSE 0 END AS qi'); + $query = $query->row_array(); + $this->_quoted_identifier = empty($query) ? FALSE : (bool) $query['qi']; + $this->_escape_char = ($this->_quoted_identifier) ? '"' : array('[', ']'); + + return $this->conn_id; + } + + // -------------------------------------------------------------------- + + /** + * Show table query + * + * Generates a platform-specific query string so that the table names can be fetched + * + * @param bool $prefix_limit + * @return string + */ + protected function _list_tables($prefix_limit = FALSE) + { + return 'SELECT '.$this->escape_identifiers('name') + .' FROM '.$this->escape_identifiers('sysobjects') + .' WHERE '.$this->escape_identifiers('type')." = 'U'"; + + if ($prefix_limit === TRUE && $this->dbprefix !== '') + { + $sql .= ' AND '.$this->escape_identifiers('name')." LIKE '".$this->escape_like_str($this->dbprefix)."%' " + .sprintf($this->_like_escape_str, $this->_like_escape_chr); + } + + return $sql.' ORDER BY '.$this->escape_identifiers('name'); + } + + // -------------------------------------------------------------------- + + /** + * Show column query + * + * Generates a platform-specific query string so that the column names can be fetched + * + * @param string $table + * @return string + */ + protected function _list_columns($table = '') + { + return 'SELECT COLUMN_NAME + FROM INFORMATION_SCHEMA.Columns + WHERE UPPER(TABLE_NAME) = '.$this->escape(strtoupper($table)); + } + + // -------------------------------------------------------------------- + + /** + * Returns an object with field data + * + * @param string $table + * @return array + */ + public function field_data($table = '') + { + if ($table === '') + { + return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; + } + + $sql = 'SELECT COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, NUMERIC_PRECISION, COLUMN_DEFAULT + FROM INFORMATION_SCHEMA.Columns + WHERE UPPER(TABLE_NAME) = '.$this->escape(strtoupper($table)); + + if (($query = $this->query($sql)) === FALSE) + { + return FALSE; + } + $query = $query->result_object(); + + $retval = array(); + for ($i = 0, $c = count($query); $i < $c; $i++) + { + $retval[$i] = new stdClass(); + $retval[$i]->name = $query[$i]->COLUMN_NAME; + $retval[$i]->type = $query[$i]->DATA_TYPE; + $retval[$i]->max_length = ($query[$i]->CHARACTER_MAXIMUM_LENGTH > 0) ? $query[$i]->CHARACTER_MAXIMUM_LENGTH : $query[$i]->NUMERIC_PRECISION; + $retval[$i]->default = $query[$i]->COLUMN_DEFAULT; + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Update statement + * + * Generates a platform-specific update string from the supplied data + * + * @param string $table + * @param array $values + * @return string + */ + protected function _update($table, $values) + { + $this->qb_limit = FALSE; + $this->qb_orderby = array(); + return parent::_update($table, $values); + } + + // -------------------------------------------------------------------- + + /** + * Delete statement + * + * Generates a platform-specific delete string from the supplied data + * + * @param string $table + * @return string + */ + protected function _delete($table) + { + if ($this->qb_limit) + { + return 'WITH ci_delete AS (SELECT TOP '.$this->qb_limit.' * FROM '.$table.$this->_compile_wh('qb_where').') DELETE FROM ci_delete'; + } + + return parent::_delete($table); + } + + // -------------------------------------------------------------------- + + /** + * LIMIT + * + * Generates a platform-specific LIMIT clause + * + * @param string $sql SQL Query + * @return string + */ + protected function _limit($sql) + { + // As of SQL Server 2012 (11.0.*) OFFSET is supported + if (version_compare($this->version(), '11', '>=')) + { + return $sql.' OFFSET '.(int) $this->qb_offset.' ROWS FETCH NEXT '.$this->qb_limit.' ROWS ONLY'; + } + + $limit = $this->qb_offset + $this->qb_limit; + + // An ORDER BY clause is required for ROW_NUMBER() to work + if ($this->qb_offset && ! empty($this->qb_orderby)) + { + $orderby = $this->_compile_order_by(); + + // We have to strip the ORDER BY clause + $sql = trim(substr($sql, 0, strrpos($sql, $orderby))); + + // Get the fields to select from our subquery, so that we can avoid CI_rownum appearing in the actual results + if (count($this->qb_select) === 0) + { + $select = '*'; // Inevitable + } + else + { + // Use only field names and their aliases, everything else is out of our scope. + $select = array(); + $field_regexp = ($this->_quoted_identifier) + ? '("[^\"]+")' : '(\[[^\]]+\])'; + for ($i = 0, $c = count($this->qb_select); $i < $c; $i++) + { + $select[] = preg_match('/(?:\s|\.)'.$field_regexp.'$/i', $this->qb_select[$i], $m) + ? $m[1] : $this->qb_select[$i]; + } + $select = implode(', ', $select); + } + + return 'SELECT '.$select." FROM (\n\n" + .preg_replace('/^(SELECT( DISTINCT)?)/i', '\\1 ROW_NUMBER() OVER('.trim($orderby).') AS '.$this->escape_identifiers('CI_rownum').', ', $sql) + ."\n\n) ".$this->escape_identifiers('CI_subquery') + ."\nWHERE ".$this->escape_identifiers('CI_rownum').' BETWEEN '.($this->qb_offset + 1).' AND '.$limit; + } + + return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$limit.' ', $sql); + } + + // -------------------------------------------------------------------- + + /** + * Insert batch statement + * + * Generates a platform-specific insert string from the supplied data. + * + * @param string $table Table name + * @param array $keys INSERT keys + * @param array $values INSERT values + * @return string|bool + */ + protected function _insert_batch($table, $keys, $values) + { + // Multiple-value inserts are only supported as of SQL Server 2008 + if (version_compare($this->version(), '10', '>=')) + { + return parent::_insert_batch($table, $keys, $values); + } + + return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE; + } + +} + +/* End of file pdo_sqlsrv_driver.php */ +/* Location: ./system/database/drivers/pdo/subdrivers/pdo_sqlsrv_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_forge.php b/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_forge.php new file mode 100755 index 0000000..3a903c7 --- /dev/null +++ b/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_forge.php @@ -0,0 +1,136 @@ + 'SMALLINT', + 'SMALLINT' => 'INT', + 'INT' => 'BIGINT', + 'REAL' => 'FLOAT' + ); + + // -------------------------------------------------------------------- + + /** + * ALTER TABLE + * + * @param string $alter_type ALTER type + * @param string $table Table name + * @param mixed $field Column definition + * @return string|string[] + */ + protected function _alter_table($alter_type, $table, $field) + { + if (in_array($alter_type, array('ADD', 'DROP'), TRUE)) + { + return parent::_alter_table($alter_type, $table, $field); + } + + $sql = 'ALTER TABLE '.$this->db->escape_identifiers($table).' ALTER COLUMN '; + $sqls = array(); + for ($i = 0, $c = count($field); $i < $c; $i++) + { + $sqls[] = $sql.$this->_process_column($field[$i]); + } + + return $sqls; + } + + // -------------------------------------------------------------------- + + /** + * Field attribute TYPE + * + * Performs a data type mapping between different databases. + * + * @param array &$attributes + * @return void + */ + protected function _attr_type(&$attributes) + { + switch (strtoupper($attributes['TYPE'])) + { + case 'MEDIUMINT': + $attributes['TYPE'] = 'INTEGER'; + $attributes['UNSIGNED'] = FALSE; + return; + case 'INTEGER': + $attributes['TYPE'] = 'INT'; + return; + default: return; + } + } + + // -------------------------------------------------------------------- + + /** + * Field attribute AUTO_INCREMENT + * + * @param array &$attributes + * @param array &$field + * @return void + */ + protected function _attr_auto_increment(&$attributes, &$field) + { + if ( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE && stripos($field['type'], 'int') !== FALSE) + { + $field['auto_increment'] = ' IDENTITY(1,1)'; + } + } + +} + +/* End of file pdo_sqlsrv_forge.php */ +/* Location: ./system/database/drivers/pdo/subdrivers/pdo_sqlsrv_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/postgre/index.html b/system/database/drivers/postgre/index.html new file mode 100755 index 0000000..c942a79 --- /dev/null +++ b/system/database/drivers/postgre/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

    Directory access is forbidden.

    + + + \ No newline at end of file diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php new file mode 100755 index 0000000..c380a7c --- /dev/null +++ b/system/database/drivers/postgre/postgre_driver.php @@ -0,0 +1,641 @@ +dsn)) + { + return; + } + + $this->dsn === '' OR $this->dsn = ''; + + if (strpos($this->hostname, '/') !== FALSE) + { + // If UNIX sockets are used, we shouldn't set a port + $this->port = ''; + } + + $this->hostname === '' OR $this->dsn = 'host='.$this->hostname.' '; + + if ( ! empty($this->port) && ctype_digit($this->port)) + { + $this->dsn .= 'port='.$this->port.' '; + } + + if ($this->username !== '') + { + $this->dsn .= 'user='.$this->username.' '; + + /* An empty password is valid! + * + * $db['password'] = NULL must be done in order to ignore it. + */ + $this->password === NULL OR $this->dsn .= "password='".$this->password."' "; + } + + $this->database === '' OR $this->dsn .= 'dbname='.$this->database.' '; + + /* We don't have these options as elements in our standard configuration + * array, but they might be set by parse_url() if the configuration was + * provided via string. Example: + * + * postgre://username:password@localhost:5432/database?connect_timeout=5&sslmode=1 + */ + foreach (array('connect_timeout', 'options', 'sslmode', 'service') as $key) + { + if (isset($this->$key) && is_string($this->key) && $this->key !== '') + { + $this->dsn .= $key."='".$this->key."' "; + } + } + + $this->dsn = rtrim($this->dsn); + } + + // -------------------------------------------------------------------- + + /** + * Database connection + * + * @param bool $persistent + * @return resource + */ + public function db_connect($persistent = FALSE) + { + if ($persistent === TRUE + && ($this->conn_id = pg_pconnect($this->dsn)) + && pg_connection_status($this->conn_id) === PGSQL_CONNECTION_BAD + && pg_ping($this->conn_id) === FALSE + ) + { + return FALSE; + } + else + { + $this->conn_id = pg_connect($this->dsn); + } + + if ($this->conn_id && ! empty($this->schema)) + { + $this->simple_query('SET search_path TO '.$this->schema.',public'); + } + + return $this->conn_id; + } + + // -------------------------------------------------------------------- + + /** + * Reconnect + * + * Keep / reestablish the db connection if no queries have been + * sent for a length of time exceeding the server's idle timeout + * + * @return void + */ + public function reconnect() + { + if (pg_ping($this->conn_id) === FALSE) + { + $this->conn_id = FALSE; + } + } + + // -------------------------------------------------------------------- + + /** + * Set client character set + * + * @param string $charset + * @return bool + */ + protected function _db_set_charset($charset) + { + return (pg_set_client_encoding($this->conn_id, $charset) === 0); + } + + // -------------------------------------------------------------------- + + /** + * Database version number + * + * @return string + */ + public function version() + { + if (isset($this->data_cache['version'])) + { + return $this->data_cache['version']; + } + elseif ( ! $this->conn_id) + { + $this->initialize(); + } + + if ( ! $this->conn_id OR ($pg_version = pg_version($this->conn_id)) === FALSE) + { + return FALSE; + } + + /* If PHP was compiled with PostgreSQL lib versions earlier + * than 7.4, pg_version() won't return the server version + * and so we'll have to fall back to running a query in + * order to get it. + */ + return isset($pg_version['server']) + ? $this->data_cache['version'] = $pg_version['server'] + : parent::version(); + } + + // -------------------------------------------------------------------- + + /** + * Execute the query + * + * @param string $sql an SQL query + * @return resource + */ + protected function _execute($sql) + { + return pg_query($this->conn_id, $sql); + } + + // -------------------------------------------------------------------- + + /** + * Begin Transaction + * + * @param bool $test_mode + * @return bool + */ + public function trans_begin($test_mode = FALSE) + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $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); + + return (bool) pg_query($this->conn_id, 'BEGIN'); + } + + // -------------------------------------------------------------------- + + /** + * Commit Transaction + * + * @return bool + */ + public function trans_commit() + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $this->_trans_depth > 0) + { + return TRUE; + } + + return (bool) pg_query($this->conn_id, 'COMMIT'); + } + + // -------------------------------------------------------------------- + + /** + * Rollback Transaction + * + * @return bool + */ + public function trans_rollback() + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $this->_trans_depth > 0) + { + return TRUE; + } + + return (bool) pg_query($this->conn_id, 'ROLLBACK'); + } + + // -------------------------------------------------------------------- + + /** + * Determines if a query is a "write" type. + * + * @param string An SQL query string + * @return bool + */ + public function is_write_type($sql) + { + return (bool) preg_match('/^\s*"?(SET|INSERT(?![^\)]+\)\s+RETURNING)|UPDATE(?!.*\sRETURNING)|DELETE|CREATE|DROP|TRUNCATE|LOAD|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK|REINDEX)\s/i', str_replace(array("\r\n", "\r", "\n"), ' ', $sql)); + } + + // -------------------------------------------------------------------- + + /** + * Platform-dependant string escape + * + * @param string + * @return string + */ + protected function _escape_str($str) + { + return pg_escape_string($this->conn_id, $str); + } + + // -------------------------------------------------------------------- + + /** + * "Smart" Escape String + * + * Escapes data based on type + * + * @param string $str + * @return mixed + */ + public function escape($str) + { + if (is_php('5.4.4') && (is_string($str) OR (is_object($str) && method_exists($str, '__toString')))) + { + return pg_escape_literal($this->conn_id, $str); + } + elseif (is_bool($str)) + { + return ($str) ? 'TRUE' : 'FALSE'; + } + + return parent::escape($str); + } + + // -------------------------------------------------------------------- + + /** + * Affected Rows + * + * @return int + */ + public function affected_rows() + { + return pg_affected_rows($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Insert ID + * + * @return string + */ + public function insert_id() + { + $v = pg_version($this->conn_id); + $v = isset($v['server']) ? $v['server'] : 0; // 'server' key is only available since PosgreSQL 7.4 + + $table = (func_num_args() > 0) ? func_get_arg(0) : NULL; + $column = (func_num_args() > 1) ? func_get_arg(1) : NULL; + + if ($table === NULL && $v >= '8.1') + { + $sql = 'SELECT LASTVAL() AS ins_id'; + } + elseif ($table !== NULL) + { + if ($column !== NULL && $v >= '8.0') + { + $sql = 'SELECT pg_get_serial_sequence(\''.$table."', '".$column."') AS seq"; + $query = $this->query($sql); + $query = $query->row(); + $seq = $query->seq; + } + else + { + // seq_name passed in table parameter + $seq = $table; + } + + $sql = 'SELECT CURRVAL(\''.$seq."') AS ins_id"; + } + else + { + return pg_last_oid($this->result_id); + } + + $query = $this->query($sql); + $query = $query->row(); + return (int) $query->ins_id; + } + + // -------------------------------------------------------------------- + + /** + * Show table query + * + * Generates a platform-specific query string so that the table names can be fetched + * + * @param bool $prefix_limit + * @return string + */ + protected function _list_tables($prefix_limit = FALSE) + { + $sql = 'SELECT "table_name" FROM "information_schema"."tables" WHERE "table_schema" = \''.$this->schema."'"; + + if ($prefix_limit !== FALSE && $this->dbprefix !== '') + { + return $sql.' AND "table_name" LIKE \'' + .$this->escape_like_str($this->dbprefix)."%' " + .sprintf($this->_like_escape_str, $this->_like_escape_chr); + } + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * List column query + * + * Generates a platform-specific query string so that the column names can be fetched + * + * @param string $table + * @return string + */ + protected function _list_columns($table = '') + { + return 'SELECT "column_name" + FROM "information_schema"."columns" + WHERE LOWER("table_name") = '.$this->escape(strtolower($table)); + } + + // -------------------------------------------------------------------- + + /** + * Returns an object with field data + * + * @param string $table + * @return array + */ + public function field_data($table = '') + { + if ($table === '') + { + return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; + } + + $sql = 'SELECT "column_name", "data_type", "character_maximum_length", "numeric_precision", "column_default" + FROM "information_schema"."columns" + WHERE LOWER("table_name") = '.$this->escape(strtolower($table)); + + if (($query = $this->query($sql)) === FALSE) + { + return FALSE; + } + $query = $query->result_object(); + + $retval = array(); + for ($i = 0, $c = count($query); $i < $c; $i++) + { + $retval[$i] = new stdClass(); + $retval[$i]->name = $query[$i]->column_name; + $retval[$i]->type = $query[$i]->data_type; + $retval[$i]->max_length = ($query[$i]->character_maximum_length > 0) ? $query[$i]->character_maximum_length : $query[$i]->numeric_precision; + $retval[$i]->default = $query[$i]->column_default; + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Error + * + * Returns an array containing code and message of the last + * database error that has occured. + * + * @return array + */ + public function error() + { + return array('code' => '', 'message' => pg_last_error($this->conn_id)); + } + + // -------------------------------------------------------------------- + + /** + * ORDER BY + * + * @param string $orderby + * @param string $direction ASC, DESC or RANDOM + * @param bool $escape + * @return object + */ + public function order_by($orderby, $direction = '', $escape = NULL) + { + $direction = strtoupper(trim($direction)); + if ($direction === 'RANDOM') + { + if ( ! is_float($orderby) && ctype_digit((string) $orderby)) + { + $orderby = ($orderby > 1) + ? (float) '0.'.$orderby + : (float) $orderby; + } + + if (is_float($orderby)) + { + $this->simple_query('SET SEED '.$orderby); + } + + $orderby = $this->_random_keyword[0]; + $direction = ''; + $escape = FALSE; + } + + return parent::order_by($orderby, $direction, $escape); + } + + // -------------------------------------------------------------------- + + /** + * Update statement + * + * Generates a platform-specific update string from the supplied data + * + * @param string $table + * @param array $values + * @return string + */ + protected function _update($table, $values) + { + $this->qb_limit = FALSE; + $this->qb_orderby = array(); + return parent::_update($table, $values); + } + + // -------------------------------------------------------------------- + + /** + * Update_Batch statement + * + * Generates a platform-specific batch update string from the supplied data + * + * @param string $table Table name + * @param array $values Update data + * @param string $index WHERE key + * @return string + */ + protected function _update_batch($table, $values, $index) + { + $ids = array(); + foreach ($values as $key => $val) + { + $ids[] = $val[$index]; + + foreach (array_keys($val) as $field) + { + if ($field !== $index) + { + $final[$field][] = 'WHEN '.$val[$index].' THEN '.$val[$field]; + } + } + } + + $cases = ''; + foreach ($final as $k => $v) + { + $cases .= $k.' = (CASE '.$index."\n" + .implode("\n", $v)."\n" + .'ELSE '.$k.' END), '; + } + + $this->where($index.' IN('.implode(',', $ids).')', NULL, FALSE); + + return 'UPDATE '.$table.' SET '.substr($cases, 0, -2).$this->_compile_wh('qb_where'); + } + + // -------------------------------------------------------------------- + + /** + * Delete statement + * + * Generates a platform-specific delete string from the supplied data + * + * @param string $table + * @return string + */ + protected function _delete($table) + { + $this->qb_limit = FALSE; + return parent::_delete($table); + } + + // -------------------------------------------------------------------- + + /** + * LIMIT + * + * Generates a platform-specific LIMIT clause + * + * @param string $sql SQL Query + * @return string + */ + protected function _limit($sql) + { + return $sql.' LIMIT '.$this->qb_limit.($this->qb_offset ? ' OFFSET '.$this->qb_offset : ''); + } + + // -------------------------------------------------------------------- + + /** + * Close DB Connection + * + * @return void + */ + protected function _close() + { + pg_close($this->conn_id); + } + +} + +/* End of file postgre_driver.php */ +/* Location: ./system/database/drivers/postgre/postgre_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php new file mode 100755 index 0000000..8bfb66c --- /dev/null +++ b/system/database/drivers/postgre/postgre_forge.php @@ -0,0 +1,188 @@ + 'INTEGER', + 'SMALLINT' => 'INTEGER', + 'INT' => 'BIGINT', + 'INT4' => 'BIGINT', + 'INTEGER' => 'BIGINT', + 'INT8' => 'NUMERIC', + 'BIGINT' => 'NUMERIC', + 'REAL' => 'DOUBLE PRECISION', + 'FLOAT' => 'DOUBLE PRECISION' + ); + + /** + * NULL value representation in CREATE/ALTER TABLE statements + * + * @var string + */ + protected $_null = 'NULL'; + + // -------------------------------------------------------------------- + + /** + * Class constructor + * + * @param object &$db Database object + * @return void + */ + public function __construct(&$db) + { + parent::__construct($db); + + if (version_compare($this->db->version(), '9.0', '>')) + { + $this->create_table_if = 'CREATE TABLE IF NOT EXISTS'; + } + } + + // -------------------------------------------------------------------- + + /** + * ALTER TABLE + * + * @param string $alter_type ALTER type + * @param string $table Table name + * @param mixed $field Column definition + * @return string|string[] + */ + protected function _alter_table($alter_type, $table, $field) + { + if (in_array($alter_type, array('DROP', 'ADD'), TRUE)) + { + return parent::_alter_table($alter_type, $table, $field); + } + + $sql = 'ALTER TABLE '.$this->db->escape_identifiers($table); + $sqls = array(); + for ($i = 0, $c = count($field); $i < $c; $i++) + { + if ($field[$i]['_literal'] !== FALSE) + { + return FALSE; + } + + if (version_compare($this->db->version(), '8', '>=') && isset($field[$i]['type'])) + { + $sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identifiers($field[$i]['name']) + .' TYPE '.$field[$i]['type'].$field[$i]['length']; + } + + if ( ! empty($field[$i]['default'])) + { + $sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identifiers($field[$i]['name']) + .' SET DEFAULT '.$field[$i]['default']; + } + + if (isset($field[$i]['null'])) + { + $sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identifiers($field[$i]['name']) + .($field[$i]['null'] === TRUE ? ' DROP NOT NULL' : ' SET NOT NULL'); + } + + if ( ! empty($field[$i]['new_name'])) + { + $sqls[] = $sql.' RENAME COLUMN '.$this->db->escape_identifiers($field[$i]['name']) + .' TO '.$this->db->escape_identifiers($field[$i]['new_name']); + } + } + + return $sqls; + } + + // -------------------------------------------------------------------- + + /** + * Field attribute TYPE + * + * Performs a data type mapping between different databases. + * + * @param array &$attributes + * @return void + */ + protected function _attr_type(&$attributes) + { + // Reset field lenghts for data types that don't support it + if (isset($attributes['CONSTRAINT']) && stripos($attributes['TYPE'], 'int') !== FALSE) + { + $attributes['CONSTRAINT'] = NULL; + } + + switch (strtoupper($attributes['TYPE'])) + { + case 'TINYINT': + $attributes['TYPE'] = 'SMALLINT'; + $attributes['UNSIGNED'] = FALSE; + return; + case 'MEDIUMINT': + $attributes['TYPE'] = 'INTEGER'; + $attributes['UNSIGNED'] = FALSE; + return; + default: return; + } + } + + // -------------------------------------------------------------------- + + /** + * Field attribute AUTO_INCREMENT + * + * @param array &$attributes + * @param array &$field + * @return void + */ + protected function _attr_auto_increment(&$attributes, &$field) + { + if ( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE) + { + $field['type'] = ($field['type'] === 'NUMERIC') + ? 'BIGSERIAL' + : 'SERIAL'; + } + } + +} + +/* End of file postgre_forge.php */ +/* Location: ./system/database/drivers/postgre/postgre_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/postgre/postgre_result.php b/system/database/drivers/postgre/postgre_result.php new file mode 100755 index 0000000..ab04af1 --- /dev/null +++ b/system/database/drivers/postgre/postgre_result.php @@ -0,0 +1,173 @@ +num_rows) + ? $this->num_rows + : $this->num_rows = pg_num_rows($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Number of fields in the result set + * + * @return int + */ + public function num_fields() + { + return pg_num_fields($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Fetch Field Names + * + * Generates an array of column names + * + * @return array + */ + public function list_fields() + { + $field_names = array(); + for ($i = 0, $c = $this->num_fields(); $i < $c; $i++) + { + $field_names[] = pg_field_name($this->result_id, $i); + } + + return $field_names; + } + + // -------------------------------------------------------------------- + + /** + * Field data + * + * Generates an array of objects containing field meta-data + * + * @return array + */ + public function field_data() + { + $retval = array(); + for ($i = 0, $c = $this->num_fields(); $i < $c; $i++) + { + $retval[$i] = new stdClass(); + $retval[$i]->name = pg_field_name($this->result_id, $i); + $retval[$i]->type = pg_field_type($this->result_id, $i); + $retval[$i]->max_length = pg_field_size($this->result_id, $i); + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Free the result + * + * @return void + */ + public function free_result() + { + if (is_resource($this->result_id)) + { + pg_free_result($this->result_id); + $this->result_id = FALSE; + } + } + + // -------------------------------------------------------------------- + + /** + * Data Seek + * + * Moves the internal pointer to the desired offset. We call + * this internally before fetching results to make sure the + * result set starts at zero. + * + * @param int $n + * @return bool + */ + public function data_seek($n = 0) + { + return pg_result_seek($this->result_id, $n); + } + + // -------------------------------------------------------------------- + + /** + * Result - associative array + * + * Returns the result set as an array + * + * @return array + */ + protected function _fetch_assoc() + { + return pg_fetch_assoc($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Result - object + * + * Returns the result set as an object + * + * @param string $class_name + * @return object + */ + protected function _fetch_object($class_name = 'stdClass') + { + return pg_fetch_object($this->result_id, NULL, $class_name); + } + +} + +/* End of file postgre_result.php */ +/* Location: ./system/database/drivers/postgre/postgre_result.php */ \ No newline at end of file diff --git a/system/database/drivers/postgre/postgre_utility.php b/system/database/drivers/postgre/postgre_utility.php new file mode 100755 index 0000000..fe7e3b6 --- /dev/null +++ b/system/database/drivers/postgre/postgre_utility.php @@ -0,0 +1,68 @@ +db->display_error('db_unsupported_feature'); + } +} + +/* End of file postgre_utility.php */ +/* Location: ./system/database/drivers/postgre/postgre_utility.php */ \ No newline at end of file diff --git a/system/database/drivers/sqlite/index.html b/system/database/drivers/sqlite/index.html new file mode 100755 index 0000000..c942a79 --- /dev/null +++ b/system/database/drivers/sqlite/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

    Directory access is forbidden.

    + + + \ No newline at end of file diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php new file mode 100755 index 0000000..a5dd6e0 --- /dev/null +++ b/system/database/drivers/sqlite/sqlite_driver.php @@ -0,0 +1,354 @@ +database, 0666, $error) + : sqlite_open($this->database, 0666, $error); + + isset($error) && log_message('error', $error); + + return $conn_id; + } + + // -------------------------------------------------------------------- + + /** + * Database version number + * + * @return string + */ + public function version() + { + return isset($this->data_cache['version']) + ? $this->data_cache['version'] + : $this->data_cache['version'] = sqlite_libversion(); + } + + // -------------------------------------------------------------------- + + /** + * Execute the query + * + * @param string $sql an SQL query + * @return resource + */ + protected function _execute($sql) + { + return $this->is_write_type($sql) + ? sqlite_exec($this->conn_id, $sql) + : sqlite_query($this->conn_id, $sql); + } + + // -------------------------------------------------------------------- + + /** + * Begin Transaction + * + * @param bool $test_mode + * @return bool + */ + public function trans_begin($test_mode = FALSE) + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $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); + + $this->simple_query('BEGIN TRANSACTION'); + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Commit Transaction + * + * @return bool + */ + public function trans_commit() + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $this->_trans_depth > 0) + { + return TRUE; + } + + $this->simple_query('COMMIT'); + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Rollback Transaction + * + * @return bool + */ + public function trans_rollback() + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $this->_trans_depth > 0) + { + return TRUE; + } + + $this->simple_query('ROLLBACK'); + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Platform-dependant string escape + * + * @param string + * @return string + */ + protected function _escape_str($str) + { + return sqlite_escape_string($str); + } + + // -------------------------------------------------------------------- + + /** + * Affected Rows + * + * @return int + */ + public function affected_rows() + { + return sqlite_changes($this->conn_id); + } + + // -------------------------------------------------------------------- + + /** + * Insert ID + * + * @return int + */ + public function insert_id() + { + return sqlite_last_insert_rowid($this->conn_id); + } + + // -------------------------------------------------------------------- + + /** + * List table query + * + * Generates a platform-specific query string so that the table names can be fetched + * + * @param bool $prefix_limit + * @return string + */ + protected function _list_tables($prefix_limit = FALSE) + { + $sql = "SELECT name FROM sqlite_master WHERE type='table'"; + + if ($prefix_limit !== FALSE && $this->dbprefix != '') + { + return $sql." AND 'name' LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); + } + + return $sql; + } + + // -------------------------------------------------------------------- + + /** + * Show column query + * + * Generates a platform-specific query string so that the column names can be fetched + * + * @param string $table + * @return bool + */ + protected function _list_columns($table = '') + { + // Not supported + return FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Returns an object with field data + * + * @param string $table + * @return array + */ + public function field_data($table = '') + { + if ($table === '') + { + return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; + } + + if (($query = $this->query('PRAGMA TABLE_INFO('.$this->protect_identifiers($table, TRUE, NULL, FALSE).')')) === FALSE) + { + return FALSE; + } + + $query = $query->result_array(); + if (empty($query)) + { + return FALSE; + } + + $retval = array(); + for ($i = 0, $c = count($query); $i < $c; $i++) + { + $retval[$i] = new stdClass(); + $retval[$i]->name = $query[$i]['name']; + $retval[$i]->type = $query[$i]['type']; + $retval[$i]->max_length = NULL; + $retval[$i]->default = $query[$i]['dflt_value']; + $retval[$i]->primary_key = isset($query[$i]['pk']) ? (int) $query[$i]['pk'] : 0; + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Error + * + * Returns an array containing code and message of the last + * database error that has occured. + * + * @return array + */ + public function error() + { + $error = array('code' => sqlite_last_error($this->conn_id)); + $error['message'] = sqlite_error_string($error['code']); + return $error; + } + + // -------------------------------------------------------------------- + + /** + * Replace statement + * + * Generates a platform-specific replace string from the supplied data + * + * @param string $table Table name + * @param array $keys INSERT keys + * @param array $values INSERT values + * @return string + */ + protected function _replace($table, $keys, $values) + { + return 'INSERT OR '.parent::_replace($table, $keys, $values); + } + + // -------------------------------------------------------------------- + + /** + * Truncate statement + * + * Generates a platform-specific truncate string from the supplied data + * + * If the database does not support the TRUNCATE statement, + * then this function maps to 'DELETE FROM table' + * + * @param string $table + * @return string + */ + protected function _truncate($table) + { + return 'DELETE FROM '.$table; + } + + // -------------------------------------------------------------------- + + /** + * Close DB Connection + * + * @return void + */ + protected function _close() + { + sqlite_close($this->conn_id); + } + +} + +/* End of file sqlite_driver.php */ +/* Location: ./system/database/drivers/sqlite/sqlite_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/sqlite/sqlite_forge.php b/system/database/drivers/sqlite/sqlite_forge.php new file mode 100755 index 0000000..5a28c2b --- /dev/null +++ b/system/database/drivers/sqlite/sqlite_forge.php @@ -0,0 +1,197 @@ +db->database) OR ! @unlink($this->db->database)) + { + return ($this->db->db_debug) ? $this->db->display_error('db_unable_to_drop') : FALSE; + } + elseif ( ! empty($this->db->data_cache['db_names'])) + { + $key = array_search(strtolower($this->db->database), array_map('strtolower', $this->db->data_cache['db_names']), TRUE); + if ($key !== FALSE) + { + unset($this->db->data_cache['db_names'][$key]); + } + } + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * ALTER TABLE + * + * @todo implement drop_column(), modify_column() + * @param string $alter_type ALTER type + * @param string $table Table name + * @param mixed $field Column definition + * @return string|string[] + */ + protected function _alter_table($alter_type, $table, $field) + { + if ($alter_type === 'DROP' OR $alter_type === 'CHANGE') + { + // drop_column(): + // BEGIN TRANSACTION; + // CREATE TEMPORARY TABLE t1_backup(a,b); + // INSERT INTO t1_backup SELECT a,b FROM t1; + // DROP TABLE t1; + // CREATE TABLE t1(a,b); + // INSERT INTO t1 SELECT a,b FROM t1_backup; + // DROP TABLE t1_backup; + // COMMIT; + + return FALSE; + } + + return parent::_alter_table($alter_type, $table, $field); + } + + // -------------------------------------------------------------------- + + /** + * Process column + * + * @param array $field + * @return string + */ + protected function _process_column($field) + { + return $this->db->escape_identifiers($field['name']) + .' '.$field['type'] + .$field['auto_increment'] + .$field['null'] + .$field['unique'] + .$field['default']; + } + + // -------------------------------------------------------------------- + + /** + * Field attribute TYPE + * + * Performs a data type mapping between different databases. + * + * @param array &$attributes + * @return void + */ + protected function _attr_type(&$attributes) + { + switch (strtoupper($attributes['TYPE'])) + { + case 'ENUM': + case 'SET': + $attributes['TYPE'] = 'TEXT'; + return; + default: return; + } + } + + // -------------------------------------------------------------------- + + /** + * Field attribute AUTO_INCREMENT + * + * @param array &$attributes + * @param array &$field + * @return void + */ + protected function _attr_auto_increment(&$attributes, &$field) + { + if ( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE && stripos($field['type'], 'int') !== FALSE) + { + $field['type'] = 'INTEGER PRIMARY KEY'; + $field['default'] = ''; + $field['null'] = ''; + $field['unique'] = ''; + $field['auto_increment'] = ' AUTOINCREMENT'; + + $this->primary_keys = array(); + } + } + +} + +/* End of file sqlite_forge.php */ +/* Location: ./system/database/drivers/sqlite/sqlite_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/sqlite/sqlite_result.php b/system/database/drivers/sqlite/sqlite_result.php new file mode 100755 index 0000000..8279c31 --- /dev/null +++ b/system/database/drivers/sqlite/sqlite_result.php @@ -0,0 +1,157 @@ +num_rows) + ? $this->num_rows + : $this->num_rows = @sqlite_num_rows($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Number of fields in the result set + * + * @return int + */ + public function num_fields() + { + return @sqlite_num_fields($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Fetch Field Names + * + * Generates an array of column names + * + * @return array + */ + public function list_fields() + { + $field_names = array(); + for ($i = 0, $c = $this->num_fields(); $i < $c; $i++) + { + $field_names[$i] = sqlite_field_name($this->result_id, $i); + } + + return $field_names; + } + + // -------------------------------------------------------------------- + + /** + * Field data + * + * Generates an array of objects containing field meta-data + * + * @return array + */ + public function field_data() + { + $retval = array(); + for ($i = 0, $c = $this->num_fields(); $i < $c; $i++) + { + $retval[$i] = new stdClass(); + $retval[$i]->name = sqlite_field_name($this->result_id, $i); + $retval[$i]->type = NULL; + $retval[$i]->max_length = NULL; + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Data Seek + * + * Moves the internal pointer to the desired offset. We call + * this internally before fetching results to make sure the + * result set starts at zero. + * + * @param int $n + * @return bool + */ + public function data_seek($n = 0) + { + return sqlite_seek($this->result_id, $n); + } + + // -------------------------------------------------------------------- + + /** + * Result - associative array + * + * Returns the result set as an array + * + * @return array + */ + protected function _fetch_assoc() + { + return sqlite_fetch_array($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Result - object + * + * Returns the result set as an object + * + * @param string $class_name + * @return object + */ + protected function _fetch_object($class_name = 'stdClass') + { + return sqlite_fetch_object($this->result_id, $class_name); + } + +} + +/* End of file sqlite_result.php */ +/* Location: ./system/database/drivers/sqlite/sqlite_result.php */ \ No newline at end of file diff --git a/system/database/drivers/sqlite/sqlite_utility.php b/system/database/drivers/sqlite/sqlite_utility.php new file mode 100755 index 0000000..7ad040e --- /dev/null +++ b/system/database/drivers/sqlite/sqlite_utility.php @@ -0,0 +1,53 @@ +db->display_error('db_unsupported_feature'); + } + +} + +/* End of file sqlite_utility.php */ +/* Location: ./system/database/drivers/sqlite/sqlite_utility.php */ \ No newline at end of file diff --git a/system/database/drivers/sqlite3/index.html b/system/database/drivers/sqlite3/index.html new file mode 100755 index 0000000..c942a79 --- /dev/null +++ b/system/database/drivers/sqlite3/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

    Directory access is forbidden.

    + + + \ No newline at end of file diff --git a/system/database/drivers/sqlite3/sqlite3_driver.php b/system/database/drivers/sqlite3/sqlite3_driver.php new file mode 100755 index 0000000..a7d0d08 --- /dev/null +++ b/system/database/drivers/sqlite3/sqlite3_driver.php @@ -0,0 +1,358 @@ +password) + ? new SQLite3($this->database) + : new SQLite3($this->database, SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE, $this->password); + } + catch (Exception $e) + { + return FALSE; + } + } + + // -------------------------------------------------------------------- + + /** + * Database version number + * + * @return string + */ + public function version() + { + if (isset($this->data_cache['version'])) + { + return $this->data_cache['version']; + } + + $version = SQLite3::version(); + return $this->data_cache['version'] = $version['versionString']; + } + + // -------------------------------------------------------------------- + + /** + * Execute the query + * + * @todo Implement use of SQLite3::querySingle(), if needed + * @param string $sql + * @return mixed SQLite3Result object or bool + */ + protected function _execute($sql) + { + return $this->is_write_type($sql) + ? $this->conn_id->exec($sql) + : $this->conn_id->query($sql); + } + + // -------------------------------------------------------------------- + + /** + * Begin Transaction + * + * @param bool $test_mode + * @return bool + */ + public function trans_begin($test_mode = FALSE) + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $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); + + return $this->conn_id->exec('BEGIN TRANSACTION'); + } + + // -------------------------------------------------------------------- + + /** + * Commit Transaction + * + * @return bool + */ + public function trans_commit() + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $this->_trans_depth > 0) + { + return TRUE; + } + + return $this->conn_id->exec('END TRANSACTION'); + } + + // -------------------------------------------------------------------- + + /** + * Rollback Transaction + * + * @return bool + */ + public function trans_rollback() + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $this->_trans_depth > 0) + { + return TRUE; + } + + return $this->conn_id->exec('ROLLBACK'); + } + + // -------------------------------------------------------------------- + + /** + * Platform-dependant string escape + * + * @param string + * @return string + */ + protected function _escape_str($str) + { + return $this->conn_id->escapeString(remove_invisible_characters($str)); + } + + // -------------------------------------------------------------------- + + /** + * Affected Rows + * + * @return int + */ + public function affected_rows() + { + return $this->conn_id->changes(); + } + + // -------------------------------------------------------------------- + + /** + * Insert ID + * + * @return int + */ + public function insert_id() + { + return $this->conn_id->lastInsertRowID(); + } + + // -------------------------------------------------------------------- + + /** + * Show table query + * + * Generates a platform-specific query string so that the table names can be fetched + * + * @param bool $prefix_limit + * @return string + */ + protected function _list_tables($prefix_limit = FALSE) + { + return 'SELECT "NAME" FROM "SQLITE_MASTER" WHERE "TYPE" = \'table\'' + .(($prefix_limit !== FALSE && $this->dbprefix != '') + ? ' AND "NAME" LIKE \''.$this->escape_like_str($this->dbprefix).'%\' '.sprintf($this->_like_escape_str, $this->_like_escape_chr) + : ''); + } + + // -------------------------------------------------------------------- + + /** + * Show column query + * + * Generates a platform-specific query string so that the column names can be fetched + * + * @param string $table + * @return string + */ + protected function _list_columns($table = '') + { + // Not supported + return FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Returns an object with field data + * + * @param string $table + * @return array + */ + public function field_data($table = '') + { + if ($table === '') + { + return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; + } + + if (($query = $this->query('PRAGMA TABLE_INFO('.$this->protect_identifiers($table, TRUE, NULL, FALSE).')')) === FALSE) + { + return FALSE; + } + + $query = $query->result_array(); + if (empty($query)) + { + return FALSE; + } + + $retval = array(); + for ($i = 0, $c = count($query); $i < $c; $i++) + { + $retval[$i] = new stdClass(); + $retval[$i]->name = $query[$i]['name']; + $retval[$i]->type = $query[$i]['type']; + $retval[$i]->max_length = NULL; + $retval[$i]->default = $query[$i]['dflt_value']; + $retval[$i]->primary_key = isset($query[$i]['pk']) ? (int) $query[$i]['pk'] : 0; + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Error + * + * Returns an array containing code and message of the last + * database error that has occured. + * + * @return array + */ + public function error() + { + return array('code' => $this->conn_id->lastErrorCode(), 'message' => $this->conn_id->lastErrorMsg()); + } + + // -------------------------------------------------------------------- + + /** + * Replace statement + * + * Generates a platform-specific replace string from the supplied data + * + * @param string $table Table name + * @param array $keys INSERT keys + * @param array $values INSERT values + * @return string + */ + protected function _replace($table, $keys, $values) + { + return 'INSERT OR '.parent::_replace($table, $keys, $values); + } + + // -------------------------------------------------------------------- + + /** + * Truncate statement + * + * Generates a platform-specific truncate string from the supplied data + * + * If the database does not support the TRUNCATE statement, + * then this method maps to 'DELETE FROM table' + * + * @param string $table + * @return string + */ + protected function _truncate($table) + { + return 'DELETE FROM '.$table; + } + + // -------------------------------------------------------------------- + + /** + * Close DB Connection + * + * @return void + */ + protected function _close() + { + $this->conn_id->close(); + } + +} + +/* End of file sqlite3_driver.php */ +/* Location: ./system/database/drivers/sqlite3/sqlite3_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/sqlite3/sqlite3_forge.php b/system/database/drivers/sqlite3/sqlite3_forge.php new file mode 100755 index 0000000..d79d15a --- /dev/null +++ b/system/database/drivers/sqlite3/sqlite3_forge.php @@ -0,0 +1,216 @@ +db->version(), '3.3', '<')) + { + $this->create_table_if = FALSE; + } + } + + // -------------------------------------------------------------------- + + /** + * Create database + * + * @param string $db_name + * @return bool + */ + public function create_database($db_name = '') + { + // 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 + * + * @param string $db_name (ignored) + * @return bool + */ + public function drop_database($db_name = '') + { + // In SQLite, a database is dropped when we delete a file + if (file_exists($this->db->database)) + { + // We need to close the pseudo-connection first + $this->db->close(); + if ( ! @unlink($this->db->database)) + { + return $this->db->db_debug ? $this->db->display_error('db_unable_to_drop') : FALSE; + } + elseif ( ! empty($this->db->data_cache['db_names'])) + { + $key = array_search(strtolower($this->db->database), array_map('strtolower', $this->db->data_cache['db_names']), TRUE); + if ($key !== FALSE) + { + unset($this->db->data_cache['db_names'][$key]); + } + } + + return TRUE; + } + + return $this->db->db_debug ? $this->db->display_error('db_unable_to_drop') : FALSE; + } + + // -------------------------------------------------------------------- + + /** + * ALTER TABLE + * + * @todo implement drop_column(), modify_column() + * @param string $alter_type ALTER type + * @param string $table Table name + * @param mixed $field Column definition + * @return string|string[] + */ + protected function _alter_table($alter_type, $table, $field) + { + if ($alter_type === 'DROP' OR $alter_type === 'CHANGE') + { + // drop_column(): + // BEGIN TRANSACTION; + // CREATE TEMPORARY TABLE t1_backup(a,b); + // INSERT INTO t1_backup SELECT a,b FROM t1; + // DROP TABLE t1; + // CREATE TABLE t1(a,b); + // INSERT INTO t1 SELECT a,b FROM t1_backup; + // DROP TABLE t1_backup; + // COMMIT; + + return FALSE; + } + + return parent::_alter_table($alter_type, $table, $field); + } + + // -------------------------------------------------------------------- + + /** + * Process column + * + * @param array $field + * @return string + */ + protected function _process_column($field) + { + return $this->db->escape_identifiers($field['name']) + .' '.$field['type'] + .$field['auto_increment'] + .$field['null'] + .$field['unique'] + .$field['default']; + } + + // -------------------------------------------------------------------- + + /** + * Field attribute TYPE + * + * Performs a data type mapping between different databases. + * + * @param array &$attributes + * @return void + */ + protected function _attr_type(&$attributes) + { + switch (strtoupper($attributes['TYPE'])) + { + case 'ENUM': + case 'SET': + $attributes['TYPE'] = 'TEXT'; + return; + default: return; + } + } + + // -------------------------------------------------------------------- + + /** + * Field attribute AUTO_INCREMENT + * + * @param array &$attributes + * @param array &$field + * @return void + */ + protected function _attr_auto_increment(&$attributes, &$field) + { + if ( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE && stripos($field['type'], 'int') !== FALSE) + { + $field['type'] = 'INTEGER PRIMARY KEY'; + $field['default'] = ''; + $field['null'] = ''; + $field['unique'] = ''; + $field['auto_increment'] = ' AUTOINCREMENT'; + + $this->primary_keys = array(); + } + } + +} + +/* End of file sqlite3_forge.php */ +/* Location: ./system/database/drivers/sqlite3/sqlite3_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/sqlite3/sqlite3_result.php b/system/database/drivers/sqlite3/sqlite3_result.php new file mode 100755 index 0000000..fb2fc4e --- /dev/null +++ b/system/database/drivers/sqlite3/sqlite3_result.php @@ -0,0 +1,187 @@ +result_id->numColumns(); + } + + // -------------------------------------------------------------------- + + /** + * Fetch Field Names + * + * Generates an array of column names + * + * @return array + */ + public function list_fields() + { + $field_names = array(); + for ($i = 0, $c = $this->num_fields(); $i < $c; $i++) + { + $field_names[] = $this->result_id->columnName($i); + } + + return $field_names; + } + + // -------------------------------------------------------------------- + + /** + * Field data + * + * Generates an array of objects containing field meta-data + * + * @return array + */ + public function field_data() + { + static $data_types = array( + SQLITE3_INTEGER => 'integer', + SQLITE3_FLOAT => 'float', + SQLITE3_TEXT => 'text', + SQLITE3_BLOB => 'blob', + SQLITE3_NULL => 'null' + ); + + $retval = array(); + for ($i = 0, $c = $this->num_fields(); $i < $this->num_fields(); $i++) + { + $retval[$i] = new stdClass(); + $retval[$i]->name = $this->result_id->columnName($i); + + $type = $this->result_id->columnType($i); + $retval[$i]->type = isset($data_types[$type]) ? $data_types[$type] : $type; + + $retval[$i]->max_length = NULL; + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Free the result + * + * @return void + */ + public function free_result() + { + if (is_object($this->result_id)) + { + $this->result_id->finalize(); + $this->result_id = NULL; + } + } + + // -------------------------------------------------------------------- + + /** + * Result - associative array + * + * Returns the result set as an array + * + * @return array + */ + protected function _fetch_assoc() + { + return $this->result_id->fetchArray(SQLITE3_ASSOC); + } + + // -------------------------------------------------------------------- + + /** + * Result - object + * + * Returns the result set as an object + * + * @param string $class_name + * @return object + */ + protected function _fetch_object($class_name = 'stdClass') + { + // No native support for fetching rows as objects + if (($row = $this->result_id->fetchArray(SQLITE3_ASSOC)) === FALSE) + { + return FALSE; + } + elseif ($class_name === 'stdClass') + { + return (object) $row; + } + + $class_name = new $class_name(); + foreach (array_keys($row) as $key) + { + $class_name->$key = $row[$key]; + } + + return $class_name; + } + + // -------------------------------------------------------------------- + + /** + * Data Seek + * + * Moves the internal pointer to the desired offset. We call + * this internally before fetching results to make sure the + * result set starts at zero. + * + * @param int $n (ignored) + * @return array + */ + public function data_seek($n = 0) + { + // Only resetting to the start of the result set is supported + return ($n > 0) ? FALSE : $this->result_id->reset(); + } + +} + +/* End of file sqlite3_result.php */ +/* Location: ./system/database/drivers/sqlite3/sqlite3_result.php */ \ No newline at end of file diff --git a/system/database/drivers/sqlite3/sqlite3_utility.php b/system/database/drivers/sqlite3/sqlite3_utility.php new file mode 100755 index 0000000..49dcf3d --- /dev/null +++ b/system/database/drivers/sqlite3/sqlite3_utility.php @@ -0,0 +1,53 @@ +db->display_error('db_unsupported_feature'); + } + +} + +/* End of file sqlite3_utility.php */ +/* Location: ./system/database/drivers/sqlite3/sqlite3_utility.php */ \ No newline at end of file diff --git a/system/database/drivers/sqlsrv/index.html b/system/database/drivers/sqlsrv/index.html new file mode 100755 index 0000000..c942a79 --- /dev/null +++ b/system/database/drivers/sqlsrv/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

    Directory access is forbidden.

    + + + \ No newline at end of file diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php new file mode 100755 index 0000000..ec983d5 --- /dev/null +++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php @@ -0,0 +1,565 @@ +scrollable === NULL) + { + $this->scrollable = defined('SQLSRV_CURSOR_CLIENT_BUFFERED') + ? SQLSRV_CURSOR_CLIENT_BUFFERED + : FALSE; + } + } + + // -------------------------------------------------------------------- + + /** + * Database connection + * + * @param bool $pooling + * @return resource + */ + public function db_connect($pooling = FALSE) + { + $charset = in_array(strtolower($this->char_set), array('utf-8', 'utf8'), TRUE) + ? 'UTF-8' : SQLSRV_ENC_CHAR; + + $connection = array( + 'UID' => empty($this->username) ? '' : $this->username, + 'PWD' => empty($this->password) ? '' : $this->password, + 'Database' => $this->database, + 'ConnectionPooling' => ($pooling === TRUE) ? 1 : 0, + 'CharacterSet' => $charset, + 'Encrypt' => ($this->encrypt === TRUE) ? 1 : 0, + 'ReturnDatesAsStrings' => 1 + ); + + // If the username and password are both empty, assume this is a + // 'Windows Authentication Mode' connection. + if (empty($connection['UID']) && empty($connection['PWD'])) + { + unset($connection['UID'], $connection['PWD']); + } + + $this->conn_id = sqlsrv_connect($this->hostname, $connection); + + // Determine how identifiers are escaped + $query = $this->query('SELECT CASE WHEN (@@OPTIONS | 256) = @@OPTIONS THEN 1 ELSE 0 END AS qi'); + $query = $query->row_array(); + $this->_quoted_identifier = empty($query) ? FALSE : (bool) $query['qi']; + $this->_escape_char = ($this->_quoted_identifier) ? '"' : array('[', ']'); + + return $this->conn_id; + } + + // -------------------------------------------------------------------- + + /** + * Select the database + * + * @param string $database + * @return bool + */ + public function db_select($database = '') + { + if ($database === '') + { + $database = $this->database; + } + + if ($this->_execute('USE '.$this->escape_identifiers($database))) + { + $this->database = $database; + return TRUE; + } + + return FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Execute the query + * + * @param string $sql an SQL query + * @return resource + */ + protected function _execute($sql) + { + return ($this->scrollable === FALSE OR $this->is_write_type($sql)) + ? sqlsrv_query($this->conn_id, $sql) + : sqlsrv_query($this->conn_id, $sql, NULL, array('Scrollable' => $this->scrollable)); + } + + // -------------------------------------------------------------------- + + /** + * Begin Transaction + * + * @param bool $test_mode + * @return bool + */ + public function trans_begin($test_mode = FALSE) + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $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); + + return sqlsrv_begin_transaction($this->conn_id); + } + + // -------------------------------------------------------------------- + + /** + * Commit Transaction + * + * @return bool + */ + public function trans_commit() + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $this->_trans_depth > 0) + { + return TRUE; + } + + return sqlsrv_commit($this->conn_id); + } + + // -------------------------------------------------------------------- + + /** + * Rollback Transaction + * + * @return bool + */ + public function trans_rollback() + { + // When transactions are nested we only begin/commit/rollback the outermost ones + if ( ! $this->trans_enabled OR $this->_trans_depth > 0) + { + return TRUE; + } + + return sqlsrv_rollback($this->conn_id); + } + + // -------------------------------------------------------------------- + + /** + * Affected Rows + * + * @return int + */ + public function affected_rows() + { + return sqlsrv_rows_affected($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Insert ID + * + * Returns the last id created in the Identity column. + * + * @return string + */ + public function insert_id() + { + $query = $this->query('SELECT @@IDENTITY AS insert_id'); + $query = $query->row(); + return $query->insert_id; + } + + // -------------------------------------------------------------------- + + /** + * Database version number + * + * @return string + */ + public function version() + { + if (isset($this->data_cache['version'])) + { + return $this->data_cache['version']; + } + elseif ( ! $this->conn_id) + { + $this->initialize(); + } + + if ( ! $this->conn_id OR ($info = sqlsrv_server_info($this->conn_id)) === FALSE) + { + return FALSE; + } + + return $this->data_cache['version'] = $info['SQLServerVersion']; + } + + // -------------------------------------------------------------------- + + /** + * List table query + * + * Generates a platform-specific query string so that the table names can be fetched + * + * @param bool + * @return string $prefix_limit + */ + protected function _list_tables($prefix_limit = FALSE) + { + $sql = 'SELECT '.$this->escape_identifiers('name') + .' FROM '.$this->escape_identifiers('sysobjects') + .' WHERE '.$this->escape_identifiers('type')." = 'U'"; + + if ($prefix_limit === TRUE && $this->dbprefix !== '') + { + $sql .= ' AND '.$this->escape_identifiers('name')." LIKE '".$this->escape_like_str($this->dbprefix)."%' " + .sprintf($this->_escape_like_str, $this->_escape_like_chr); + } + + return $sql.' ORDER BY '.$this->escape_identifiers('name'); + } + + // -------------------------------------------------------------------- + + /** + * List column query + * + * Generates a platform-specific query string so that the column names can be fetched + * + * @param string $table + * @return string + */ + protected function _list_columns($table = '') + { + return 'SELECT COLUMN_NAME + FROM INFORMATION_SCHEMA.Columns + WHERE UPPER(TABLE_NAME) = '.$this->escape(strtoupper($table)); + } + + // -------------------------------------------------------------------- + + /** + * Returns an object with field data + * + * @param string $table + * @return array + */ + public function field_data($table = '') + { + if ($table === '') + { + return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; + } + + $sql = 'SELECT COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, NUMERIC_PRECISION, COLUMN_DEFAULT + FROM INFORMATION_SCHEMA.Columns + WHERE UPPER(TABLE_NAME) = '.$this->escape(strtoupper($table)); + + if (($query = $this->query($sql)) === FALSE) + { + return FALSE; + } + $query = $query->result_object(); + + $retval = array(); + for ($i = 0, $c = count($query); $i < $c; $i++) + { + $retval[$i] = new stdClass(); + $retval[$i]->name = $query[$i]->COLUMN_NAME; + $retval[$i]->type = $query[$i]->DATA_TYPE; + $retval[$i]->max_length = ($query[$i]->CHARACTER_MAXIMUM_LENGTH > 0) ? $query[$i]->CHARACTER_MAXIMUM_LENGTH : $query[$i]->NUMERIC_PRECISION; + $retval[$i]->default = $query[$i]->COLUMN_DEFAULT; + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Error + * + * Returns an array containing code and message of the last + * database error that has occured. + * + * @return array + */ + public function error() + { + $error = array('code' => '00000', 'message' => ''); + $sqlsrv_errors = sqlsrv_errors(SQLSRV_ERR_ERRORS); + + if ( ! is_array($sqlsrv_errors)) + { + return $error; + } + + $sqlsrv_error = array_shift($sqlsrv_errors); + if (isset($sqlsrv_error['SQLSTATE'])) + { + $error['code'] = isset($sqlsrv_error['code']) ? $sqlsrv_error['SQLSTATE'].'/'.$sqlsrv_error['code'] : $sqlsrv_error['SQLSTATE']; + } + elseif (isset($sqlsrv_error['code'])) + { + $error['code'] = $sqlsrv_error['code']; + } + + if (isset($sqlsrv_error['message'])) + { + $error['message'] = $sqlsrv_error['message']; + } + + return $error; + } + + // -------------------------------------------------------------------- + + /** + * Update statement + * + * Generates a platform-specific update string from the supplied data + * + * @param string $table + * @param array $values + * @return string + */ + protected function _update($table, $values) + { + $this->qb_limit = FALSE; + $this->qb_orderby = array(); + return parent::_update($table, $values); + } + + // -------------------------------------------------------------------- + + /** + * Truncate statement + * + * Generates a platform-specific truncate string from the supplied data + * + * If the database does not support the TRUNCATE statement, + * then this method maps to 'DELETE FROM table' + * + * @param string $table + * @return string + */ + protected function _truncate($table) + { + return 'TRUNCATE TABLE '.$table; + } + + // -------------------------------------------------------------------- + + /** + * Delete statement + * + * Generates a platform-specific delete string from the supplied data + * + * @param string $table + * @return string + */ + protected function _delete($table) + { + if ($this->qb_limit) + { + return 'WITH ci_delete AS (SELECT TOP '.$this->qb_limit.' * FROM '.$table.$this->_compile_wh('qb_where').') DELETE FROM ci_delete'; + } + + return parent::_delete($table); + } + + // -------------------------------------------------------------------- + + /** + * LIMIT + * + * Generates a platform-specific LIMIT clause + * + * @param string $sql SQL Query + * @return string + */ + protected function _limit($sql) + { + // As of SQL Server 2012 (11.0.*) OFFSET is supported + if (version_compare($this->version(), '11', '>=')) + { + return $sql.' OFFSET '.(int) $this->qb_offset.' ROWS FETCH NEXT '.$this->qb_limit.' ROWS ONLY'; + } + + $limit = $this->qb_offset + $this->qb_limit; + + // An ORDER BY clause is required for ROW_NUMBER() to work + if ($this->qb_offset && ! empty($this->qb_orderby)) + { + $orderby = $this->_compile_order_by(); + + // We have to strip the ORDER BY clause + $sql = trim(substr($sql, 0, strrpos($sql, $orderby))); + + // Get the fields to select from our subquery, so that we can avoid CI_rownum appearing in the actual results + if (count($this->qb_select) === 0) + { + $select = '*'; // Inevitable + } + else + { + // Use only field names and their aliases, everything else is out of our scope. + $select = array(); + $field_regexp = ($this->_quoted_identifier) + ? '("[^\"]+")' : '(\[[^\]]+\])'; + for ($i = 0, $c = count($this->qb_select); $i < $c; $i++) + { + $select[] = preg_match('/(?:\s|\.)'.$field_regexp.'$/i', $this->qb_select[$i], $m) + ? $m[1] : $this->qb_select[$i]; + } + $select = implode(', ', $select); + } + + return 'SELECT '.$select." FROM (\n\n" + .preg_replace('/^(SELECT( DISTINCT)?)/i', '\\1 ROW_NUMBER() OVER('.trim($orderby).') AS '.$this->escape_identifiers('CI_rownum').', ', $sql) + ."\n\n) ".$this->escape_identifiers('CI_subquery') + ."\nWHERE ".$this->escape_identifiers('CI_rownum').' BETWEEN '.($this->qb_offset + 1).' AND '.$limit; + } + + return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$limit.' ', $sql); + } + + // -------------------------------------------------------------------- + + /** + * Insert batch statement + * + * Generates a platform-specific insert string from the supplied data. + * + * @param string $table Table name + * @param array $keys INSERT keys + * @param array $values INSERT values + * @return string|bool + */ + protected function _insert_batch($table, $keys, $values) + { + // Multiple-value inserts are only supported as of SQL Server 2008 + if (version_compare($this->version(), '10', '>=')) + { + return parent::_insert_batch($table, $keys, $values); + } + + return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Close DB Connection + * + * @return void + */ + protected function _close() + { + sqlsrv_close($this->conn_id); + } + +} + +/* End of file sqlsrv_driver.php */ +/* Location: ./system/database/drivers/sqlsrv/sqlsrv_driver.php */ \ No newline at end of file diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php new file mode 100755 index 0000000..7938684 --- /dev/null +++ b/system/database/drivers/sqlsrv/sqlsrv_forge.php @@ -0,0 +1,136 @@ + 'SMALLINT', + 'SMALLINT' => 'INT', + 'INT' => 'BIGINT', + 'REAL' => 'FLOAT' + ); + + // -------------------------------------------------------------------- + + /** + * ALTER TABLE + * + * @param string $alter_type ALTER type + * @param string $table Table name + * @param mixed $field Column definition + * @return string|string[] + */ + protected function _alter_table($alter_type, $table, $field) + { + if (in_array($alter_type, array('ADD', 'DROP'), TRUE)) + { + return parent::_alter_table($alter_type, $table, $field); + } + + $sql = 'ALTER TABLE '.$this->db->escape_identifiers($table).' ALTER COLUMN '; + $sqls = array(); + for ($i = 0, $c = count($field); $i < $c; $i++) + { + $sqls[] = $sql.$this->_process_column($field[$i]); + } + + return $sqls; + } + + // -------------------------------------------------------------------- + + /** + * Field attribute TYPE + * + * Performs a data type mapping between different databases. + * + * @param array &$attributes + * @return void + */ + protected function _attr_type(&$attributes) + { + switch (strtoupper($attributes['TYPE'])) + { + case 'MEDIUMINT': + $attributes['TYPE'] = 'INTEGER'; + $attributes['UNSIGNED'] = FALSE; + return; + case 'INTEGER': + $attributes['TYPE'] = 'INT'; + return; + default: return; + } + } + + // -------------------------------------------------------------------- + + /** + * Field attribute AUTO_INCREMENT + * + * @param array &$attributes + * @param array &$field + * @return void + */ + protected function _attr_auto_increment(&$attributes, &$field) + { + if ( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE && stripos($field['type'], 'int') !== FALSE) + { + $field['auto_increment'] = ' IDENTITY(1,1)'; + } + } + +} + +/* End of file sqlsrv_forge.php */ +/* Location: ./system/database/drivers/sqlsrv/sqlsrv_forge.php */ \ No newline at end of file diff --git a/system/database/drivers/sqlsrv/sqlsrv_result.php b/system/database/drivers/sqlsrv/sqlsrv_result.php new file mode 100755 index 0000000..71c429e --- /dev/null +++ b/system/database/drivers/sqlsrv/sqlsrv_result.php @@ -0,0 +1,186 @@ +scrollable = $driver_object->scrollable; + } + + // -------------------------------------------------------------------- + + /** + * Number of rows in the result set + * + * @return int + */ + public function num_rows() + { + // sqlsrv_num_rows() doesn't work with the FORWARD and DYNAMIC cursors (FALSE is the same as FORWARD) + if ( ! in_array($this->scrollable, array(FALSE, SQLSRV_CURSOR_FORWARD, SQLSRV_CURSOR_DYNAMIC), TRUE)) + { + return parent::num_rows(); + } + + return is_int($this->num_rows) + ? $this->num_rows + : $this->num_rows = sqlsrv_num_rows($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Number of fields in the result set + * + * @return int + */ + public function num_fields() + { + return @sqlsrv_num_fields($this->result_id); + } + + // -------------------------------------------------------------------- + + /** + * Fetch Field Names + * + * Generates an array of column names + * + * @return array + */ + public function list_fields() + { + $field_names = array(); + foreach (sqlsrv_field_metadata($this->result_id) as $offset => $field) + { + $field_names[] = $field['Name']; + } + + return $field_names; + } + + // -------------------------------------------------------------------- + + /** + * Field data + * + * Generates an array of objects containing field meta-data + * + * @return array + */ + public function field_data() + { + $retval = array(); + foreach (sqlsrv_field_metadata($this->result_id) as $i => $field) + { + $retval[$i] = new stdClass(); + $retval[$i]->name = $field['Name']; + $retval[$i]->type = $field['Type']; + $retval[$i]->max_length = $field['Size']; + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Free the result + * + * @return void + */ + public function free_result() + { + if (is_resource($this->result_id)) + { + sqlsrv_free_stmt($this->result_id); + $this->result_id = FALSE; + } + } + + // -------------------------------------------------------------------- + + /** + * Result - associative array + * + * Returns the result set as an array + * + * @return array + */ + protected function _fetch_assoc() + { + return sqlsrv_fetch_array($this->result_id, SQLSRV_FETCH_ASSOC); + } + + // -------------------------------------------------------------------- + + /** + * Result - object + * + * Returns the result set as an object + * + * @param string $class_name + * @return object + */ + protected function _fetch_object($class_name = 'stdClass') + { + return sqlsrv_fetch_object($this->result_id, $class_name); + } + +} + +/* End of file sqlsrv_result.php */ +/* Location: ./system/database/drivers/sqlsrv/sqlsrv_result.php */ \ No newline at end of file diff --git a/system/database/drivers/sqlsrv/sqlsrv_utility.php b/system/database/drivers/sqlsrv/sqlsrv_utility.php new file mode 100755 index 0000000..b6a1fe4 --- /dev/null +++ b/system/database/drivers/sqlsrv/sqlsrv_utility.php @@ -0,0 +1,69 @@ +db->display_error('db_unsupported_feature'); + } + +} + +/* End of file sqlsrv_utility.php */ +/* Location: ./system/database/drivers/sqlsrv/sqlsrv_utility.php */ \ No newline at end of file diff --git a/system/database/index.html b/system/database/index.html new file mode 100755 index 0000000..c942a79 --- /dev/null +++ b/system/database/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

    Directory access is forbidden.

    + + + \ No newline at end of file diff --git a/system/fonts/index.html b/system/fonts/index.html new file mode 100755 index 0000000..c942a79 --- /dev/null +++ b/system/fonts/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

    Directory access is forbidden.

    + + + \ No newline at end of file diff --git a/system/fonts/texb.ttf b/system/fonts/texb.ttf new file mode 100755 index 0000000000000000000000000000000000000000..383c88b86b7c17e2e284732af48b2bfc359647ae GIT binary patch literal 143830 zcmcG%34ml(c{W_il{&<709mpO2M~UwQR4 z@7=v(myaoCd_MIlA7KsVlRh5jzKO4)RfWbY`wrhFjOp_+jKK07&#-9ijjuk9OX5eO ze>NVvX3m%KWq!-?e=`3kq$b|LTsPq(3kwT$FMb#w?FXMPgnqy~62q^6U+>GM*XGB@ z3wGjGydX-lqH6v?P&Z5~WIN$VG!{=JQ|XMG&E*TlQn}LBUhU}Y>h9^S_4N-7t{55~ zSvfj3KCx+&v)TP zzQf17eYakA`7M{6zRl;m$>+P~6u!FR_|dsTH{;F4mwE@BxccO^*In=PUFm)D`EI}C z#v{$Q%U`Zq_JL#QNWR~9+9&ureW!en`QGJwFQns1-^YAU`#$aayze`{v%Y`!y-0e< zc9vx&*3TMjiS1=qu#d5yW}jid!VzvWw>1;WBr|TNH}h>*cP-a(BW}X&cOP{><$lKf zTlZU8UzW}CSt+Y#^{kbRWmDNgwmrKtJCU8r&SW=c4`vT#Z^_<~eRcM}?4#NDWS`A` zKKu7MHP@EU7Cv0~MB!6~&lUc<@Ppz-#VcQ2_$}v+Y^K@XKSO(;YPR>=UVHxw?cK)u zSe{jy?Hy$AXWxbPeg^H;(OxT)$Yg$}z4yDHbf0m*=CzkWdquCkW;UEnqP-=ry_3!M zUYxx#dwcdSwD*DRJH7UPCnx19=d}0v;=$sv7hn3V52EDiY)_xy#= z?|pvv^Z)q#`19iP{PXPd%-MyrKR)}~vzMK{^z7cVd(L+Id}lk(R?oJbEuJmV@jV;C zuW*(<%bX==esd;$C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$5ulTi3cHetL(Z%|sTAGNsTAGN zseIg!Be{mII+fA_Ie9~mf`x`23?5^Ho0T4vN+}RYrINy?kv;MZA(=`k=t!j$u%%MH n`i '', '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 = "\""; + + 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/cookie_helper.php b/system/helpers/cookie_helper.php new file mode 100755 index 0000000..98670c1 --- /dev/null +++ b/system/helpers/cookie_helper.php @@ -0,0 +1,103 @@ +input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure); + } +} + +// -------------------------------------------------------------------- + +/** + * Fetch an item from the COOKIE array + * + * @access public + * @param string + * @param bool + * @return mixed + */ +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); + } +} + +// -------------------------------------------------------------------- + +/** + * Delete a COOKIE + * + * @param mixed + * @param string the cookie domain. Usually: .yourdomain.com + * @param string the cookie path + * @param string the cookie prefix + * @return void + */ +if ( ! function_exists('delete_cookie')) +{ + function delete_cookie($name = '', $domain = '', $path = '/', $prefix = '') + { + set_cookie($name, '', '', $domain, $path, $prefix); + } +} + + +/* End of file cookie_helper.php */ +/* Location: ./system/helpers/cookie_helper.php */ \ No newline at end of file diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php new file mode 100755 index 0000000..27aa482 --- /dev/null +++ b/system/helpers/date_helper.php @@ -0,0 +1,611 @@ +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 + { + return time(); + } + } +} + +// ------------------------------------------------------------------------ + +/** + * Convert MySQL Style Datecodes + * + * This function is identical to PHPs date() function, + * except that it allows date codes to be formatted using + * the MySQL style, where each code letter is preceded + * with a percent sign: %Y %m %d etc... + * + * The benefit of doing dates this way is that you don't + * have to worry about escaping your text letters that + * match the date codes. + * + * @access public + * @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); + } +} + +// ------------------------------------------------------------------------ + +/** + * Standard Date + * + * Returns a date formatted according to the submitted standard. + * + * @access public + * @param string the chosen format + * @param integer Unix timestamp + * @return string + */ +if ( ! function_exists('standard_date')) +{ + function standard_date($fmt = 'DATE_RFC822', $time = '') + { + $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%Q', + 'DATE_RFC822' => '%D, %d %M %y %H:%i:%s %O', + 'DATE_RFC850' => '%l, %d-%M-%y %H:%i:%s UTC', + 'DATE_RFC1036' => '%D, %d %M %y %H:%i:%s %O', + 'DATE_RFC1123' => '%D, %d %M %Y %H:%i:%s %O', + 'DATE_RSS' => '%D, %d %M %Y %H:%i:%s %O', + 'DATE_W3C' => '%Y-%m-%dT%H:%i:%s%Q' + ); + + if ( ! isset($formats[$fmt])) + { + return FALSE; + } + + return mdate($formats[$fmt], $time); + } +} + +// ------------------------------------------------------------------------ + +/** + * Timespan + * + * Returns a span of seconds in this format: + * 10 days 14 hours 36 minutes 47 seconds + * + * @access public + * @param integer a number of seconds + * @param integer Unix timestamp + * @return integer + */ +if ( ! function_exists('timespan')) +{ + function timespan($seconds = 1, $time = '') + { + $CI =& get_instance(); + $CI->lang->load('date'); + + if ( ! is_numeric($seconds)) + { + $seconds = 1; + } + + if ( ! is_numeric($time)) + { + $time = time(); + } + + if ($time <= $seconds) + { + $seconds = 1; + } + else + { + $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); + } +} + +// ------------------------------------------------------------------------ + +/** + * Number of days in a month + * + * Takes a month/year as input and returns the number of days + * for the given month/year. Takes leap years into consideration. + * + * @access public + * @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 = '') + { + if ($month < 1 OR $month > 12) + { + 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)) + { + return 29; + } + } + + $days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); + return $days_in_month[$month - 1]; + } +} + +// ------------------------------------------------------------------------ + +/** + * Converts a local Unix timestamp to GMT + * + * @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)); + } +} + +// ------------------------------------------------------------------------ + +/** + * Converts GMT time to a localized value + * + * Takes a Unix timestamp (in GMT) as input, and returns + * at the local value based on the timezone and DST setting + * submitted + * + * @access public + * @param integer Unix timestamp + * @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; + } +} + +// ------------------------------------------------------------------------ + +/** + * Converts a MySQL Timestamp to Unix + * + * @access public + * @param integer Unix timestamp + * @return integer + */ +if ( ! function_exists('mysql_to_unix')) +{ + function mysql_to_unix($time = '') + { + // 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), + substr($time, 10, 2), + substr($time, 12, 2), + substr($time, 4, 2), + substr($time, 6, 2), + substr($time, 0, 4) + ); + } +} + +// ------------------------------------------------------------------------ + +/** + * Unix to "Human" + * + * Formats Unix timestamp to the following prototype: 2006-08-21 11:35 PM + * + * @access public + * @param integer Unix timestamp + * @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); + } + else + { + $r .= date('H', $time).':'.date('i', $time); + } + + if ($seconds) + { + $r .= ':'.date('s', $time); + } + + if ($fmt == 'us') + { + $r .= ' '.date('A', $time); + } + + return $r; + } +} + +// ------------------------------------------------------------------------ + +/** + * Convert "human" date to GMT + * + * Reverses the above process + * + * @access public + * @param string format: us or euro + * @return integer + */ +if ( ! function_exists('human_to_unix')) +{ + function human_to_unix($datestr = '') + { + if ($datestr == '') + { + return FALSE; + } + + $datestr = trim($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 = 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']; + + if (isset($ex['2']) && preg_match('/[0-9]{1,2}/', $ex['2'])) + { + $sec = (strlen($ex['2']) == 1) ? '0'.$ex['2'] : $ex['2']; + } + else + { + // 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); + } +} + +// ------------------------------------------------------------------------ + +/** + * Timezone Menu + * + * Generates a drop-down menu of timezones. + * + * @access public + * @param string timezone + * @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 = '"; + + return $menu; + } +} + +// ------------------------------------------------------------------------ + +/** + * Timezones + * + * Returns an array of timezones. This is a helper function + * for various other ones in this library + * + * @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( + 'UM12' => -12, + 'UM11' => -11, + 'UM10' => -10, + 'UM95' => -9.5, + 'UM9' => -9, + 'UM8' => -8, + 'UM7' => -7, + 'UM6' => -6, + 'UM5' => -5, + 'UM45' => -4.5, + 'UM4' => -4, + 'UM35' => -3.5, + 'UM3' => -3, + 'UM2' => -2, + 'UM1' => -1, + 'UTC' => 0, + 'UP1' => +1, + 'UP2' => +2, + 'UP3' => +3, + 'UP35' => +3.5, + 'UP4' => +4, + 'UP45' => +4.5, + 'UP5' => +5, + 'UP55' => +5.5, + 'UP575' => +5.75, + 'UP6' => +6, + 'UP65' => +6.5, + 'UP7' => +7, + 'UP8' => +8, + 'UP875' => +8.75, + 'UP9' => +9, + 'UP95' => +9.5, + 'UP10' => +10, + 'UP105' => +10.5, + 'UP11' => +11, + 'UP115' => +11.5, + 'UP12' => +12, + 'UP1275' => +12.75, + 'UP13' => +13, + 'UP14' => +14 + ); + + if ($tz == '') + { + return $zones; + } + + if ($tz == 'GMT') + $tz = 'UTC'; + + return ( ! isset($zones[$tz])) ? 0 : $zones[$tz]; + } +} + + +/* End of file date_helper.php */ +/* Location: ./system/helpers/date_helper.php */ \ No newline at end of file diff --git a/system/helpers/directory_helper.php b/system/helpers/directory_helper.php new file mode 100755 index 0000000..0c0c39c --- /dev/null +++ b/system/helpers/directory_helper.php @@ -0,0 +1,80 @@ + 0) && @is_dir($source_dir.$file)) + { + $filedata[$file] = directory_map($source_dir.$file.DIRECTORY_SEPARATOR, $new_depth, $hidden); + } + else + { + $filedata[] = $file; + } + } + + closedir($fp); + return $filedata; + } + + return FALSE; + } +} + + +/* End of file directory_helper.php */ +/* Location: ./system/helpers/directory_helper.php */ \ No newline at end of file diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php new file mode 100755 index 0000000..34e2944 --- /dev/null +++ b/system/helpers/download_helper.php @@ -0,0 +1,107 @@ + 0) + { + $data =& fread($fp, filesize($file)); + } + + flock($fp, LOCK_UN); + fclose($fp); + + return $data; + } +} + +// ------------------------------------------------------------------------ + +/** + * Write File + * + * Writes data to the file specified in the path. + * Creates a new file if non-existent. + * + * @access public + * @param string path to file + * @param string file data + * @return bool + */ +if ( ! function_exists('write_file')) +{ + function write_file($path, $data, $mode = FOPEN_WRITE_CREATE_DESTRUCTIVE) + { + if ( ! $fp = @fopen($path, $mode)) + { + return FALSE; + } + + flock($fp, LOCK_EX); + fwrite($fp, $data); + flock($fp, LOCK_UN); + fclose($fp); + + return TRUE; + } +} + +// ------------------------------------------------------------------------ + +/** + * Delete Files + * + * Deletes all files contained in the supplied directory path. + * Files must be writable or owned by the system in order to be deleted. + * If the second parameter is set to TRUE, any directories contained + * within the supplied base directory will be nuked as well. + * + * @access public + * @param string path to file + * @param bool whether to delete any directories found in the path + * @return bool + */ +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 FALSE; + } + + while (FALSE !== ($filename = @readdir($current_dir))) + { + if ($filename != "." and $filename != "..") + { + if (is_dir($path.DIRECTORY_SEPARATOR.$filename)) + { + // Ignore empty folders + if (substr($filename, 0, 1) != '.') + { + delete_files($path.DIRECTORY_SEPARATOR.$filename, $del_dir, $level + 1); + } + } + else + { + unlink($path.DIRECTORY_SEPARATOR.$filename); + } + } + } + @closedir($current_dir); + + if ($del_dir == TRUE AND $level > 0) + { + return @rmdir($path); + } + + return TRUE; + } +} + +// ------------------------------------------------------------------------ + +/** + * Get Filenames + * + * Reads the specified directory and builds an array containing the filenames. + * Any sub-folders contained within the specified path are read as well. + * + * @access public + * @param string path to source + * @param bool whether to include the path as part of the filename + * @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 + if ($_recursion === FALSE) + { + $_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); + } + elseif (strncmp($file, '.', 1) !== 0) + { + $_filedata[] = ($include_path == TRUE) ? $source_dir.$file : $file; + } + } + return $_filedata; + } + else + { + return FALSE; + } + } +} + +// -------------------------------------------------------------------- + +/** + * Get Directory File Information + * + * 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 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, $top_level_only = TRUE, $_recursion = FALSE) + { + static $_filedata = array(); + $relative_path = $source_dir; + + if ($fp = @opendir($source_dir)) + { + // reset the array and make sure $source_dir has a trailing slash on the initial call + if ($_recursion === FALSE) + { + $_filedata = array(); + $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) AND strncmp($file, '.', 1) !== 0 AND $top_level_only === FALSE) + { + get_dir_file_info($source_dir.$file.DIRECTORY_SEPARATOR, $top_level_only, TRUE); + } + elseif (strncmp($file, '.', 1) !== 0) + { + $_filedata[$file] = get_file_info($source_dir.$file); + $_filedata[$file]['relative_path'] = $relative_path; + } + } + + return $_filedata; + } + else + { + return FALSE; + } + } +} + +// -------------------------------------------------------------------- + +/** +* Get File Info +* +* Given a file and path, returns the name, path, size, date modified +* Second parameter allows you to explicitly declare what information you want returned +* Options are: name, server_path, size, date, readable, writable, executable, fileperms +* Returns FALSE if the file cannot be found. +* +* @access public +* @param string path to file +* @param mixed array or comma separated string of information returned +* @return array +*/ +if ( ! function_exists('get_file_info')) +{ + function get_file_info($file, $returned_values = array('name', 'server_path', 'size', 'date')) + { + + if ( ! file_exists($file)) + { + return FALSE; + } + + if (is_string($returned_values)) + { + $returned_values = explode(',', $returned_values); + } + + foreach ($returned_values as $key) + { + switch ($key) + { + case 'name': + $fileinfo['name'] = substr(strrchr($file, DIRECTORY_SEPARATOR), 1); + break; + case 'server_path': + $fileinfo['server_path'] = $file; + break; + case 'size': + $fileinfo['size'] = filesize($file); + break; + case 'date': + $fileinfo['date'] = filemtime($file); + break; + case 'readable': + $fileinfo['readable'] = is_readable($file); + break; + case 'writable': + // There are known problems using is_weritable on IIS. It may not be reliable - consider fileperms() + $fileinfo['writable'] = is_writable($file); + break; + case 'executable': + $fileinfo['executable'] = is_executable($file); + break; + case 'fileperms': + $fileinfo['fileperms'] = fileperms($file); + break; + } + } + + return $fileinfo; + } +} + +// -------------------------------------------------------------------- + +/** + * Get Mime by Extension + * + * 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 + * It should NOT be trusted, and should certainly NOT be used for security + * + * @access public + * @param string path to file + * @return mixed + */ +if ( ! function_exists('get_mime_by_extension')) +{ + function get_mime_by_extension($file) + { + $extension = strtolower(substr(strrchr($file, '.'), 1)); + + global $mimes; + + if ( ! is_array($mimes)) + { + if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) + { + include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'); + } + elseif (is_file(APPPATH.'config/mimes.php')) + { + include(APPPATH.'config/mimes.php'); + } + + if ( ! is_array($mimes)) + { + return FALSE; + } + } + + if (array_key_exists($extension, $mimes)) + { + if (is_array($mimes[$extension])) + { + // Multiple mime types, just give the first one + return current($mimes[$extension]); + } + else + { + return $mimes[$extension]; + } + } + else + { + return FALSE; + } + } +} + +// -------------------------------------------------------------------- + +/** + * Symbolic Permissions + * + * Takes a numeric value representing a file's permissions and returns + * standard symbolic notation representing that value + * + * @access public + * @param int + * @return string + */ +if ( ! function_exists('symbolic_permissions')) +{ + function symbolic_permissions($perms) + { + if (($perms & 0xC000) == 0xC000) + { + $symbolic = 's'; // Socket + } + elseif (($perms & 0xA000) == 0xA000) + { + $symbolic = 'l'; // Symbolic Link + } + elseif (($perms & 0x8000) == 0x8000) + { + $symbolic = '-'; // Regular + } + elseif (($perms & 0x6000) == 0x6000) + { + $symbolic = 'b'; // Block special + } + elseif (($perms & 0x4000) == 0x4000) + { + $symbolic = 'd'; // Directory + } + elseif (($perms & 0x2000) == 0x2000) + { + $symbolic = 'c'; // Character special + } + elseif (($perms & 0x1000) == 0x1000) + { + $symbolic = 'p'; // FIFO pipe + } + else + { + $symbolic = 'u'; // Unknown + } + + // Owner + $symbolic .= (($perms & 0x0100) ? 'r' : '-'); + $symbolic .= (($perms & 0x0080) ? 'w' : '-'); + $symbolic .= (($perms & 0x0040) ? (($perms & 0x0800) ? 's' : 'x' ) : (($perms & 0x0800) ? 'S' : '-')); + + // Group + $symbolic .= (($perms & 0x0020) ? 'r' : '-'); + $symbolic .= (($perms & 0x0010) ? 'w' : '-'); + $symbolic .= (($perms & 0x0008) ? (($perms & 0x0400) ? 's' : 'x' ) : (($perms & 0x0400) ? 'S' : '-')); + + // World + $symbolic .= (($perms & 0x0004) ? 'r' : '-'); + $symbolic .= (($perms & 0x0002) ? 'w' : '-'); + $symbolic .= (($perms & 0x0001) ? (($perms & 0x0200) ? 't' : 'x' ) : (($perms & 0x0200) ? 'T' : '-')); + + return $symbolic; + } +} + +// -------------------------------------------------------------------- + +/** + * Octal Permissions + * + * Takes a numeric value representing a file's permissions and returns + * a three character string representing the file's octal permissions + * + * @access public + * @param int + * @return string + */ +if ( ! function_exists('octal_permissions')) +{ + function octal_permissions($perms) + { + return substr(sprintf('%o', $perms), -3); + } +} + + +/* End of file file_helper.php */ +/* Location: ./system/helpers/file_helper.php */ \ No newline at end of file diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php new file mode 100755 index 0000000..7e2c3a0 --- /dev/null +++ b/system/helpers/form_helper.php @@ -0,0 +1,1054 @@ +config->site_url($action); + } + + // If no action is provided then set to the current url + $action OR $action = $CI->config->site_url($CI->uri->uri_string()); + + $form = '
    config->item('csrf_protection') === TRUE AND ! (strpos($action, $CI->config->base_url()) === FALSE OR strpos($form, 'method="get"'))) + { + $hidden[$CI->security->get_csrf_token_name()] = $CI->security->get_csrf_hash(); + } + + if (is_array($hidden) AND count($hidden) > 0) + { + $form .= sprintf("
    %s
    ", form_hidden($hidden)); + } + + return $form; + } +} + +// ------------------------------------------------------------------------ + +/** + * Form Declaration - Multipart type + * + * Creates the opening portion of the form, but with "multipart/form-data". + * + * @access public + * @param string the URI segments of the form destination + * @param array a key/value pair of attributes + * @param array a key/value pair hidden data + * @return string + */ +if ( ! function_exists('form_open_multipart')) +{ + function form_open_multipart($action = '', $attributes = array(), $hidden = array()) + { + if (is_string($attributes)) + { + $attributes .= ' enctype="multipart/form-data"'; + } + else + { + $attributes['enctype'] = 'multipart/form-data'; + } + + return form_open($action, $attributes, $hidden); + } +} + +// ------------------------------------------------------------------------ + +/** + * Hidden Input Field + * + * Generates hidden fields. You can pass a simple key/value string or an associative + * array with multiple values. + * + * @access public + * @param mixed + * @param string + * @return string + */ +if ( ! function_exists('form_hidden')) +{ + function form_hidden($name, $value = '', $recursing = FALSE) + { + static $form; + + if ($recursing === FALSE) + { + $form = "\n"; + } + + if (is_array($name)) + { + foreach ($name as $key => $val) + { + form_hidden($key, $val, TRUE); + } + return $form; + } + + if ( ! is_array($value)) + { + $form .= ''."\n"; + } + else + { + foreach ($value as $k => $v) + { + $k = (is_int($k)) ? '' : $k; + form_hidden($name.'['.$k.']', $v, TRUE); + } + } + + return $form; + } +} + +// ------------------------------------------------------------------------ + +/** + * Text Input Field + * + * @access public + * @param mixed + * @param string + * @param string + * @return string + */ +if ( ! function_exists('form_input')) +{ + function form_input($data = '', $value = '', $extra = '') + { + $defaults = array('type' => 'text', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value); + + return ""; + } +} + +// ------------------------------------------------------------------------ + +/** + * Password Field + * + * Identical to the input function but adds the "password" type + * + * @access public + * @param mixed + * @param string + * @param string + * @return string + */ +if ( ! function_exists('form_password')) +{ + function form_password($data = '', $value = '', $extra = '') + { + if ( ! is_array($data)) + { + $data = array('name' => $data); + } + + $data['type'] = 'password'; + return form_input($data, $value, $extra); + } +} + +// ------------------------------------------------------------------------ + +/** + * Upload Field + * + * Identical to the input function but adds the "file" type + * + * @access public + * @param mixed + * @param string + * @param string + * @return string + */ +if ( ! function_exists('form_upload')) +{ + function form_upload($data = '', $value = '', $extra = '') + { + if ( ! is_array($data)) + { + $data = array('name' => $data); + } + + $data['type'] = 'file'; + return form_input($data, $value, $extra); + } +} + +// ------------------------------------------------------------------------ + +/** + * Textarea field + * + * @access public + * @param mixed + * @param string + * @param string + * @return string + */ +if ( ! function_exists('form_textarea')) +{ + function form_textarea($data = '', $value = '', $extra = '') + { + $defaults = array('name' => (( ! is_array($data)) ? $data : ''), 'cols' => '40', 'rows' => '10'); + + if ( ! is_array($data) OR ! isset($data['value'])) + { + $val = $value; + } + else + { + $val = $data['value']; + unset($data['value']); // textareas don't use the value attribute + } + + $name = (is_array($data)) ? $data['name'] : $data; + return ""; + } +} + +// ------------------------------------------------------------------------ + +/** + * Multi-select menu + * + * @access public + * @param string + * @param array + * @param mixed + * @param string + * @return type + */ +if ( ! function_exists('form_multiselect')) +{ + function form_multiselect($name = '', $options = array(), $selected = array(), $extra = '') + { + if ( ! strpos($extra, 'multiple')) + { + $extra .= ' multiple="multiple"'; + } + + return form_dropdown($name, $options, $selected, $extra); + } +} + +// -------------------------------------------------------------------- + +/** + * Drop-down Menu + * + * @access public + * @param string + * @param array + * @param string + * @param string + * @return string + */ +if ( ! function_exists('form_dropdown')) +{ + function form_dropdown($name = '', $options = array(), $selected = array(), $extra = '') + { + if ( ! is_array($selected)) + { + $selected = array($selected); + } + + // If no selected state was submitted we will attempt to set it automatically + if (count($selected) === 0) + { + // If the form name appears in the $_POST array we have a winner! + if (isset($_POST[$name])) + { + $selected = array($_POST[$name]); + } + } + + if ($extra != '') $extra = ' '.$extra; + + $multiple = (count($selected) > 1 && strpos($extra, 'multiple') === FALSE) ? ' multiple="multiple"' : ''; + + $form = ''; + + return $form; + } +} + +// ------------------------------------------------------------------------ + +/** + * Checkbox Field + * + * @access public + * @param mixed + * @param string + * @param bool + * @param string + * @return string + */ +if ( ! function_exists('form_checkbox')) +{ + function form_checkbox($data = '', $value = '', $checked = FALSE, $extra = '') + { + $defaults = array('type' => 'checkbox', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value); + + if (is_array($data) AND array_key_exists('checked', $data)) + { + $checked = $data['checked']; + + if ($checked == FALSE) + { + unset($data['checked']); + } + else + { + $data['checked'] = 'checked'; + } + } + + if ($checked == TRUE) + { + $defaults['checked'] = 'checked'; + } + else + { + unset($defaults['checked']); + } + + return ""; + } +} + +// ------------------------------------------------------------------------ + +/** + * Radio Button + * + * @access public + * @param mixed + * @param string + * @param bool + * @param string + * @return string + */ +if ( ! function_exists('form_radio')) +{ + function form_radio($data = '', $value = '', $checked = FALSE, $extra = '') + { + if ( ! is_array($data)) + { + $data = array('name' => $data); + } + + $data['type'] = 'radio'; + return form_checkbox($data, $value, $checked, $extra); + } +} + +// ------------------------------------------------------------------------ + +/** + * Submit Button + * + * @access public + * @param mixed + * @param string + * @param string + * @return string + */ +if ( ! function_exists('form_submit')) +{ + function form_submit($data = '', $value = '', $extra = '') + { + $defaults = array('type' => 'submit', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value); + + return ""; + } +} + +// ------------------------------------------------------------------------ + +/** + * Reset Button + * + * @access public + * @param mixed + * @param string + * @param string + * @return string + */ +if ( ! function_exists('form_reset')) +{ + function form_reset($data = '', $value = '', $extra = '') + { + $defaults = array('type' => 'reset', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value); + + return ""; + } +} + +// ------------------------------------------------------------------------ + +/** + * Form Button + * + * @access public + * @param mixed + * @param string + * @param string + * @return string + */ +if ( ! function_exists('form_button')) +{ + function form_button($data = '', $content = '', $extra = '') + { + $defaults = array('name' => (( ! is_array($data)) ? $data : ''), 'type' => 'button'); + + if ( is_array($data) AND isset($data['content'])) + { + $content = $data['content']; + unset($data['content']); // content is not an attribute + } + + return ""; + } +} + +// ------------------------------------------------------------------------ + +/** + * Form Label Tag + * + * @access public + * @param string The text to appear onscreen + * @param string The id the label applies to + * @param string Additional attributes + * @return string + */ +if ( ! function_exists('form_label')) +{ + function form_label($label_text = '', $id = '', $attributes = array()) + { + + $label = ' 0) + { + foreach ($attributes as $key => $val) + { + $label .= ' '.$key.'="'.$val.'"'; + } + } + + $label .= ">$label_text"; + + return $label; + } +} + +// ------------------------------------------------------------------------ +/** + * Fieldset Tag + * + * Used to produce
    text. To close fieldset + * use form_fieldset_close() + * + * @access public + * @param string The legend text + * @param string Additional attributes + * @return string + */ +if ( ! function_exists('form_fieldset')) +{ + function form_fieldset($legend_text = '', $attributes = array()) + { + $fieldset = "".$extra; + } +} + +// ------------------------------------------------------------------------ + +/** + * Form Close Tag + * + * @access public + * @param string + * @return string + */ +if ( ! function_exists('form_close')) +{ + function form_close($extra = '') + { + return "".$extra; + } +} + +// ------------------------------------------------------------------------ + +/** + * Form Prep + * + * Formats text so that it can be safely placed in a form field in the event it has HTML tags. + * + * @access public + * @param string + * @return string + */ +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)) + { + foreach ($str as $key => $val) + { + $str[$key] = form_prep($val); + } + + return $str; + } + + if ($str === '') + { + return ''; + } + + // we've already prepped a field with this name + // @todo need to figure out a way to namespace this so + // that we know the *exact* field and not just one with + // the same name + if (isset($prepped_fields[$field_name])) + { + return $str; + } + + $str = htmlspecialchars($str); + + // In case htmlspecialchars misses these. + $str = str_replace(array("'", '"'), array("'", """), $str); + + if ($field_name != '') + { + $prepped_fields[$field_name] = $field_name; + } + + return $str; + } +} + +// ------------------------------------------------------------------------ + +/** + * Form Value + * + * Grabs a value from the POST array for the specified field so you can + * re-populate an input field or textarea. If Form Validation + * is active it retrieves the info from the validation class + * + * @access public + * @param string + * @return mixed + */ +if ( ! function_exists('set_value')) +{ + function set_value($field = '', $default = '') + { + if (FALSE === ($OBJ =& _get_validation_object())) + { + if ( ! isset($_POST[$field])) + { + return $default; + } + + return form_prep($_POST[$field], $field); + } + + return form_prep($OBJ->set_value($field, $default), $field); + } +} + +// ------------------------------------------------------------------------ + +/** + * Set Select + * + * Let's you set the selected value of a
    '); + popupTypeClass = PROMPT_CLASS; + } + + // Paste as Text + else if (popupName === "pastetext") { + $popup.html('Paste your content here and click submit.

    '); + popupTypeClass = PROMPT_CLASS; + } + + // Add the popup type class name + if (!popupTypeClass && !popupContent) + popupTypeClass = LIST_CLASS; + $popup.addClass(popupTypeClass); + + // Add the unselectable attribute to all items + if (ie) { + $popup.attr(UNSELECTABLE, "on") + .find("div,font,p,h1,h2,h3,h4,h5,h6") + .attr(UNSELECTABLE, "on"); + } + + // Add the hover effect to all items + if ($popup.hasClass(LIST_CLASS) || popupHover === true) + $popup.children().hover(hoverEnter, hoverLeave); + + // Add the popup to the array and return it + popups[popupName] = $popup[0]; + return $popup[0]; + + } + + // disable - enables or disables the editor + function disable(editor, disabled) { + + // Update the textarea and save the state + if (disabled) { + editor.$area.attr(DISABLED, DISABLED); + editor.disabled = true; + } + else { + editor.$area.removeAttr(DISABLED); + delete editor.disabled; + } + + // Switch the iframe into design mode. + // ie6 does not support designMode. + // ie7 & ie8 do not properly support designMode="off". + try { + if (ie) editor.doc.body.contentEditable = !disabled; + else editor.doc.designMode = !disabled ? "on" : "off"; + } + // Firefox 1.5 throws an exception that can be ignored + // when toggling designMode from off to on. + catch (err) {} + + // Enable or disable the toolbar buttons + refreshButtons(editor); + + } + + // execCommand - executes a designMode command + function execCommand(editor, command, value, useCSS, button) { + + // Restore the current ie selection + restoreRange(editor); + + // Set the styling method + if (!ie) { + if (useCSS === undefined || useCSS === null) + useCSS = editor.options.useCSS; + editor.doc.execCommand("styleWithCSS", 0, useCSS.toString()); + } + + // Execute the command and check for error + var success = true, message; + if (ie && command.toLowerCase() === "inserthtml") + getRange(editor).pasteHTML(value); + else { + try { success = editor.doc.execCommand(command, 0, value || null); } + catch (err) { message = err.message; success = false; } + if (!success) { + if ("cutcopypaste".indexOf(command) > -1) + showMessage(editor, "For security reasons, your browser does not support the " + + command + " command. Try using the keyboard shortcut or context menu instead.", + button); + else + showMessage(editor, + (message ? message : "Error executing the " + command + " command."), + button); + } + } + + // Enable the buttons and update the textarea + refreshButtons(editor); + updateTextArea(editor, true); + return success; + + } + + // focus - sets focus to either the textarea or iframe + function focus(editor) { + setTimeout(function() { + if (sourceMode(editor)) editor.$area.focus(); + else editor.$frame[0].contentWindow.focus(); + refreshButtons(editor); + }, 0); + } + + // getRange - gets the current text range object + function getRange(editor) { + if (ie) return getSelection(editor).createRange(); + return getSelection(editor).getRangeAt(0); + } + + // getSelection - gets the current text range object + function getSelection(editor) { + if (ie) return editor.doc.selection; + return editor.$frame[0].contentWindow.getSelection(); + } + + // hex - returns the hex value for the passed in color string + function hex(s) { + + // hex("rgb(255, 0, 0)") returns #FF0000 + var m = /rgba?\((\d+), (\d+), (\d+)/.exec(s); + if (m) { + s = (m[1] << 16 | m[2] << 8 | m[3]).toString(16); + while (s.length < 6) + s = "0" + s; + return "#" + s; + } + + // hex("#F00") returns #FF0000 + var c = s.split(""); + if (s.length === 4) + return "#" + c[1] + c[1] + c[2] + c[2] + c[3] + c[3]; + + // hex("#FF0000") returns #FF0000 + return s; + + } + + // hidePopups - hides all popups + function hidePopups() { + $.each(popups, function(idx, popup) { + $(popup) + .hide() + .unbind(CLICK) + .removeData(BUTTON); + }); + } + + // imagesPath - returns the path to the images folder + function imagesPath() { + var href = $("link[href*=cleditor]").attr("href"); + return href.replace(/^(.*\/)[^\/]+$/, '$1') + "images/"; + } + + // imageUrl - Returns the css url string for a filemane + function imageUrl(filename) { + return "url(" + imagesPath() + filename + ")"; + } + + // refresh - creates the iframe and resizes the controls + function refresh(editor) { + + var $main = editor.$main, + options = editor.options; + + // Remove the old iframe + if (editor.$frame) + editor.$frame.remove(); + + // Create a new iframe + var $frame = editor.$frame = $('