codeigniter_vender 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/MIT-LICENSE +20 -0
- data/README +40 -0
- data/Rakefile +18 -0
- data/VERSION +1 -0
- data/codeigniter_vender.gemspec +389 -0
- data/generators/ci_app/USAGE +8 -0
- data/generators/ci_app/ci_app_generator.rb +12 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/index.php +118 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/license.txt +52 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/application/config/autoload.php +116 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/application/config/config.php +329 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/application/config/constants.php +41 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/application/config/database.php +55 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/application/config/doctypes.php +15 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/application/config/hooks.php +16 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/application/config/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/application/config/mimes.php +105 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/application/config/routes.php +48 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/application/config/smileys.php +66 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/application/config/user_agents.php +175 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/application/controllers/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/application/controllers/welcome.php +17 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/application/errors/error_404.php +34 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/application/errors/error_db.php +34 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/application/errors/error_general.php +34 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/application/errors/error_php.php +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/application/errors/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/application/helpers/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/application/hooks/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/application/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/application/language/english/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/application/libraries/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/application/models/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/application/views/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/application/views/welcome_message.php +62 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/cache/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/codeigniter/Base4.php +69 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/codeigniter/Base5.php +56 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/codeigniter/CodeIgniter.php +280 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/codeigniter/Common.php +421 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/codeigniter/Compat.php +93 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/codeigniter/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/DB.php +146 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/DB_active_rec.php +1820 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/DB_cache.php +195 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/DB_driver.php +1366 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/DB_forge.php +375 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/DB_result.php +342 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/DB_utility.php +389 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/mssql/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/mssql/mssql_driver.php +667 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/mssql/mssql_forge.php +248 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/mssql/mssql_result.php +169 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/mssql/mssql_utility.php +123 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/mysql/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/mysql/mysql_driver.php +670 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/mysql/mysql_forge.php +254 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/mysql/mysql_result.php +169 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/mysql/mysql_utility.php +245 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/mysqli/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/mysqli/mysqli_driver.php +671 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/mysqli/mysqli_forge.php +254 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/mysqli/mysqli_result.php +169 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/mysqli/mysqli_utility.php +123 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/oci8/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/oci8/oci8_driver.php +780 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/oci8/oci8_forge.php +248 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/oci8/oci8_result.php +249 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/oci8/oci8_utility.php +122 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/odbc/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/odbc/odbc_driver.php +639 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/odbc/odbc_forge.php +266 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/odbc/odbc_result.php +228 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/odbc/odbc_utility.php +148 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/postgre/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/postgre/postgre_driver.php +684 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/postgre/postgre_forge.php +248 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/postgre/postgre_result.php +169 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/postgre/postgre_utility.php +124 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/sqlite/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/sqlite/sqlite_driver.php +657 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/sqlite/sqlite_forge.php +265 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/sqlite/sqlite_result.php +179 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/drivers/sqlite/sqlite_utility.php +141 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/database/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/fonts/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/fonts/texb.ttf +0 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/helpers/array_helper.php +78 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/helpers/compatibility_helper.php +498 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/helpers/cookie_helper.php +144 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/helpers/date_helper.php +611 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/helpers/directory_helper.php +84 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/helpers/download_helper.php +100 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/helpers/email_helper.php +62 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/helpers/file_helper.php +464 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/helpers/form_helper.php +1025 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/helpers/html_helper.php +416 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/helpers/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/helpers/inflector_helper.php +171 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/helpers/language_helper.php +58 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/helpers/number_helper.php +75 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/helpers/path_helper.php +72 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/helpers/security_helper.php +126 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/helpers/smiley_helper.php +273 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/helpers/string_helper.php +273 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/helpers/text_helper.php +462 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/helpers/typography_helper.php +71 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/helpers/url_helper.php +593 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/helpers/xml_helper.php +62 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/language/english/calendar_lang.php +51 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/language/english/date_lang.php +60 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/language/english/db_lang.php +28 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/language/english/email_lang.php +24 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/language/english/form_validation_lang.php +24 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/language/english/ftp_lang.php +17 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/language/english/imglib_lang.php +24 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/language/english/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/language/english/number_lang.php +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/language/english/profiler_lang.php +19 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/language/english/scaffolding_lang.php +17 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/language/english/unit_test_lang.php +24 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/language/english/upload_lang.php +22 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/language/english/validation_lang.php +24 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/language/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Benchmark.php +113 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Calendar.php +477 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Cart.php +550 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Config.php +244 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Controller.php +127 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Email.php +2041 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Encrypt.php +484 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Exceptions.php +174 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Form_validation.php +1278 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Ftp.php +618 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Hooks.php +226 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Image_lib.php +1544 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Input.php +1067 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Language.php +123 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Loader.php +1085 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Log.php +117 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Model.php +83 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Output.php +409 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Pagination.php +244 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Parser.php +173 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Profiler.php +392 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Router.php +389 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Session.php +758 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Sha1.php +251 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Table.php +440 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Trackback.php +547 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Typography.php +406 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/URI.php +586 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Unit_test.php +347 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Upload.php +970 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/User_agent.php +502 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Validation.php +875 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Xmlrpc.php +1421 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Xmlrpcs.php +536 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/Zip.php +359 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/libraries/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/logs/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/plugins/captcha_pi.php +356 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/plugins/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/plugins/js_calendar_pi.php +629 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/scaffolding/Scaffolding.php +291 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/scaffolding/images/background.jpg +0 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/scaffolding/images/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/scaffolding/images/logo.jpg +0 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/scaffolding/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/scaffolding/views/add.php +32 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/scaffolding/views/delete.php +9 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/scaffolding/views/edit.php +33 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/scaffolding/views/footer.php +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/scaffolding/views/header.php +29 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/scaffolding/views/index.html +10 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/scaffolding/views/no_data.php +8 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/scaffolding/views/stylesheet.css +143 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/system/scaffolding/views/view.php +27 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/changelog.html +1080 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/database/active_record.html +757 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/database/caching.html +220 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/database/call_function.html +118 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/database/configuration.html +157 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/database/connecting.html +186 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/database/examples.html +217 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/database/fields.html +163 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/database/forge.html +234 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/database/helpers.html +151 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/database/index.html +99 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/database/queries.html +153 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/database/results.html +238 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/database/table_data.html +113 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/database/transactions.html +200 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/database/utilities.html +295 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/doc_style/index.html +86 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/doc_style/template.html +128 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/general/alternative_php.html +147 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/general/ancillary_classes.html +117 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/general/autoloader.html +101 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/general/caching.html +115 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/general/common_functions.html +119 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/general/controllers.html +385 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/general/core_classes.html +185 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/general/creating_libraries.html +298 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/general/credits.html +86 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/general/errors.html +138 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/general/helpers.html +185 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/general/hooks.html +167 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/general/libraries.html +94 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/general/managing_apps.html +133 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/general/models.html +251 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/general/plugins.html +127 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/general/profiling.html +104 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/general/quick_reference.html +77 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/general/requirements.html +82 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/general/reserved_names.html +156 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/general/routing.html +176 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/general/scaffolding.html +147 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/general/security.html +153 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/general/styleguide.html +687 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/general/urls.html +151 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/general/views.html +274 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/helpers/array_helper.html +119 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/helpers/compatibility_helper.html +118 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/helpers/cookie_helper.html +147 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/helpers/date_helper.html +408 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/helpers/directory_helper.html +143 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/helpers/download_helper.html +112 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/helpers/email_helper.html +102 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/helpers/file_helper.html +178 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/helpers/form_helper.html +484 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/helpers/html_helper.html +385 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/helpers/inflector_helper.html +151 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/helpers/language_helper.html +98 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/helpers/number_helper.html +107 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/helpers/path_helper.html +106 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/helpers/security_helper.html +125 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/helpers/smiley_helper.html +215 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/helpers/string_helper.html +176 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/helpers/text_helper.html +192 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/helpers/typography_helper.html +112 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/helpers/url_helper.html +289 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/helpers/xml_helper.html +105 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/images/appflowchart.gif +0 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/images/arrow.gif +0 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/images/ci_logo.jpg +0 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/images/ci_logo_flame.jpg +0 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/images/ci_quick_ref.png +0 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/images/codeigniter_1.7.1_helper_reference.pdf +0 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/images/codeigniter_1.7.1_helper_reference.png +0 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/images/codeigniter_1.7.1_library_reference.pdf +0 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/images/codeigniter_1.7.1_library_reference.png +0 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/images/file.gif +0 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/images/folder.gif +0 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/images/nav_bg_darker.jpg +0 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/images/nav_separator_darker.jpg +0 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/images/nav_toggle_darker.jpg +0 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/images/smile.gif +0 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/images/transparent.gif +0 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/index.html +99 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/installation/downloads.html +105 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/installation/index.html +97 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/installation/troubleshooting.html +90 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/installation/upgrade_120.html +92 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/installation/upgrade_130.html +203 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/installation/upgrade_131.html +102 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/installation/upgrade_132.html +100 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/installation/upgrade_133.html +112 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/installation/upgrade_140.html +145 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/installation/upgrade_141.html +148 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/installation/upgrade_150.html +178 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/installation/upgrade_152.html +111 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/installation/upgrade_153.html +100 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/installation/upgrade_154.html +116 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/installation/upgrade_160.html +125 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/installation/upgrade_161.html +98 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/installation/upgrade_162.html +106 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/installation/upgrade_163.html +99 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/installation/upgrade_170.html +121 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/installation/upgrade_171.html +98 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/installation/upgrade_172.html +105 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/installation/upgrade_b11.html +144 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/installation/upgrading.html +101 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/libraries/benchmark.html +198 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/libraries/calendar.html +249 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/libraries/cart.html +346 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/libraries/config.html +181 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/libraries/email.html +307 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/libraries/encryption.html +182 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/libraries/file_uploading.html +451 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/libraries/form_validation.html +1221 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/libraries/ftp.html +303 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/libraries/image_lib.html +666 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/libraries/input.html +231 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/libraries/language.html +137 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/libraries/loader.html +214 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/libraries/output.html +145 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/libraries/pagination.html +218 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/libraries/parser.html +208 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/libraries/sessions.html +311 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/libraries/table.html +292 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/libraries/trackback.html +246 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/libraries/typography.html +160 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/libraries/unit_testing.html +205 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/libraries/uri.html +252 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/libraries/user_agent.html +201 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/libraries/validation.html +740 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/libraries/xmlrpc.html +517 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/libraries/zip.html +278 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/license.html +107 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/nav/hacks.txt +9 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/nav/moo.fx.js +119 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/nav/moo.fx.pack.js +241 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/nav/nav.js +139 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/nav/prototype.lite.js +127 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/nav/user_guide_menu.js +4 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/overview/appflow.html +95 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/overview/at_a_glance.html +172 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/overview/cheatsheets.html +83 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/overview/features.html +120 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/overview/getting_started.html +92 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/overview/goals.html +98 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/overview/index.html +84 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/overview/mvc.html +100 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/toc.html +209 -0
- data/generators/ci_app/templates/CodeIgniter_1.7.2/user_guide/userguide.css +406 -0
- data/generators/ci_app/templates/README +1 -0
- data/generators/ci_controller/USAGE +2 -0
- data/generators/ci_controller/ci_controller_generator.rb +11 -0
- data/generators/ci_controller/templates/ci_controller.php.erb +15 -0
- data/generators/ci_controller/templates/ci_view.php.erb +8 -0
- data/generators/ci_layout/USAGE +2 -0
- data/generators/ci_layout/ci_layout_generator.rb +24 -0
- data/generators/ci_layout/templates/application_layout.php.erb +19 -0
- data/generators/ci_model/USAGE +2 -0
- data/generators/ci_model/ci_model_generator.rb +42 -0
- data/generators/ci_model/templates/ci_model.php.erb +15 -0
- data/generators/ci_model/templates/model.rb +5 -0
- data/generators/ci_model/templates/model_migration.rb.erb +16 -0
- data/init.rb +1 -0
- data/install.rb +1 -0
- data/lib/codeigniter_vender.rb +1 -0
- data/lib/tasks/app.rake +8 -0
- data/test/codeigniter_vender_test.rb +8 -0
- data/test/test_helper.rb +3 -0
- data/uninstall.rb +1 -0
- metadata +411 -0
@@ -0,0 +1,1278 @@
|
|
1
|
+
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
2
|
+
/**
|
3
|
+
* CodeIgniter
|
4
|
+
*
|
5
|
+
* An open source application development framework for PHP 4.3.2 or newer
|
6
|
+
*
|
7
|
+
* @package CodeIgniter
|
8
|
+
* @author ExpressionEngine Dev Team
|
9
|
+
* @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
|
10
|
+
* @license http://codeigniter.com/user_guide/license.html
|
11
|
+
* @link http://codeigniter.com
|
12
|
+
* @since Version 1.0
|
13
|
+
* @filesource
|
14
|
+
*/
|
15
|
+
|
16
|
+
// ------------------------------------------------------------------------
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Form Validation Class
|
20
|
+
*
|
21
|
+
* @package CodeIgniter
|
22
|
+
* @subpackage Libraries
|
23
|
+
* @category Validation
|
24
|
+
* @author ExpressionEngine Dev Team
|
25
|
+
* @link http://codeigniter.com/user_guide/libraries/form_validation.html
|
26
|
+
*/
|
27
|
+
class CI_Form_validation {
|
28
|
+
|
29
|
+
var $CI;
|
30
|
+
var $_field_data = array();
|
31
|
+
var $_config_rules = array();
|
32
|
+
var $_error_array = array();
|
33
|
+
var $_error_messages = array();
|
34
|
+
var $_error_prefix = '<p>';
|
35
|
+
var $_error_suffix = '</p>';
|
36
|
+
var $error_string = '';
|
37
|
+
var $_safe_form_data = FALSE;
|
38
|
+
|
39
|
+
|
40
|
+
/**
|
41
|
+
* Constructor
|
42
|
+
*
|
43
|
+
*/
|
44
|
+
function CI_Form_validation($rules = array())
|
45
|
+
{
|
46
|
+
$this->CI =& get_instance();
|
47
|
+
|
48
|
+
// Validation rules can be stored in a config file.
|
49
|
+
$this->_config_rules = $rules;
|
50
|
+
|
51
|
+
// Automatically load the form helper
|
52
|
+
$this->CI->load->helper('form');
|
53
|
+
|
54
|
+
// Set the character encoding in MB.
|
55
|
+
if (function_exists('mb_internal_encoding'))
|
56
|
+
{
|
57
|
+
mb_internal_encoding($this->CI->config->item('charset'));
|
58
|
+
}
|
59
|
+
|
60
|
+
log_message('debug', "Form Validation Class Initialized");
|
61
|
+
}
|
62
|
+
|
63
|
+
// --------------------------------------------------------------------
|
64
|
+
|
65
|
+
/**
|
66
|
+
* Set Rules
|
67
|
+
*
|
68
|
+
* This function takes an array of field names and validation
|
69
|
+
* rules as input, validates the info, and stores it
|
70
|
+
*
|
71
|
+
* @access public
|
72
|
+
* @param mixed
|
73
|
+
* @param string
|
74
|
+
* @return void
|
75
|
+
*/
|
76
|
+
function set_rules($field, $label = '', $rules = '')
|
77
|
+
{
|
78
|
+
// No reason to set rules if we have no POST data
|
79
|
+
if (count($_POST) == 0)
|
80
|
+
{
|
81
|
+
return;
|
82
|
+
}
|
83
|
+
|
84
|
+
// If an array was passed via the first parameter instead of indidual string
|
85
|
+
// values we cycle through it and recursively call this function.
|
86
|
+
if (is_array($field))
|
87
|
+
{
|
88
|
+
foreach ($field as $row)
|
89
|
+
{
|
90
|
+
// Houston, we have a problem...
|
91
|
+
if ( ! isset($row['field']) OR ! isset($row['rules']))
|
92
|
+
{
|
93
|
+
continue;
|
94
|
+
}
|
95
|
+
|
96
|
+
// If the field label wasn't passed we use the field name
|
97
|
+
$label = ( ! isset($row['label'])) ? $row['field'] : $row['label'];
|
98
|
+
|
99
|
+
// Here we go!
|
100
|
+
$this->set_rules($row['field'], $label, $row['rules']);
|
101
|
+
}
|
102
|
+
return;
|
103
|
+
}
|
104
|
+
|
105
|
+
// No fields? Nothing to do...
|
106
|
+
if ( ! is_string($field) OR ! is_string($rules) OR $field == '')
|
107
|
+
{
|
108
|
+
return;
|
109
|
+
}
|
110
|
+
|
111
|
+
// If the field label wasn't passed we use the field name
|
112
|
+
$label = ($label == '') ? $field : $label;
|
113
|
+
|
114
|
+
// Is the field name an array? We test for the existence of a bracket "[" in
|
115
|
+
// the field name to determine this. If it is an array, we break it apart
|
116
|
+
// into its components so that we can fetch the corresponding POST data later
|
117
|
+
if (strpos($field, '[') !== FALSE AND preg_match_all('/\[(.*?)\]/', $field, $matches))
|
118
|
+
{
|
119
|
+
// Note: Due to a bug in current() that affects some versions
|
120
|
+
// of PHP we can not pass function call directly into it
|
121
|
+
$x = explode('[', $field);
|
122
|
+
$indexes[] = current($x);
|
123
|
+
|
124
|
+
for ($i = 0; $i < count($matches['0']); $i++)
|
125
|
+
{
|
126
|
+
if ($matches['1'][$i] != '')
|
127
|
+
{
|
128
|
+
$indexes[] = $matches['1'][$i];
|
129
|
+
}
|
130
|
+
}
|
131
|
+
|
132
|
+
$is_array = TRUE;
|
133
|
+
}
|
134
|
+
else
|
135
|
+
{
|
136
|
+
$indexes = array();
|
137
|
+
$is_array = FALSE;
|
138
|
+
}
|
139
|
+
|
140
|
+
// Build our master array
|
141
|
+
$this->_field_data[$field] = array(
|
142
|
+
'field' => $field,
|
143
|
+
'label' => $label,
|
144
|
+
'rules' => $rules,
|
145
|
+
'is_array' => $is_array,
|
146
|
+
'keys' => $indexes,
|
147
|
+
'postdata' => NULL,
|
148
|
+
'error' => ''
|
149
|
+
);
|
150
|
+
}
|
151
|
+
|
152
|
+
// --------------------------------------------------------------------
|
153
|
+
|
154
|
+
/**
|
155
|
+
* Set Error Message
|
156
|
+
*
|
157
|
+
* Lets users set their own error messages on the fly. Note: The key
|
158
|
+
* name has to match the function name that it corresponds to.
|
159
|
+
*
|
160
|
+
* @access public
|
161
|
+
* @param string
|
162
|
+
* @param string
|
163
|
+
* @return string
|
164
|
+
*/
|
165
|
+
function set_message($lang, $val = '')
|
166
|
+
{
|
167
|
+
if ( ! is_array($lang))
|
168
|
+
{
|
169
|
+
$lang = array($lang => $val);
|
170
|
+
}
|
171
|
+
|
172
|
+
$this->_error_messages = array_merge($this->_error_messages, $lang);
|
173
|
+
}
|
174
|
+
|
175
|
+
// --------------------------------------------------------------------
|
176
|
+
|
177
|
+
/**
|
178
|
+
* Set The Error Delimiter
|
179
|
+
*
|
180
|
+
* Permits a prefix/suffix to be added to each error message
|
181
|
+
*
|
182
|
+
* @access public
|
183
|
+
* @param string
|
184
|
+
* @param string
|
185
|
+
* @return void
|
186
|
+
*/
|
187
|
+
function set_error_delimiters($prefix = '<p>', $suffix = '</p>')
|
188
|
+
{
|
189
|
+
$this->_error_prefix = $prefix;
|
190
|
+
$this->_error_suffix = $suffix;
|
191
|
+
}
|
192
|
+
|
193
|
+
// --------------------------------------------------------------------
|
194
|
+
|
195
|
+
/**
|
196
|
+
* Get Error Message
|
197
|
+
*
|
198
|
+
* Gets the error message associated with a particular field
|
199
|
+
*
|
200
|
+
* @access public
|
201
|
+
* @param string the field name
|
202
|
+
* @return void
|
203
|
+
*/
|
204
|
+
function error($field = '', $prefix = '', $suffix = '')
|
205
|
+
{
|
206
|
+
if ( ! isset($this->_field_data[$field]['error']) OR $this->_field_data[$field]['error'] == '')
|
207
|
+
{
|
208
|
+
return '';
|
209
|
+
}
|
210
|
+
|
211
|
+
if ($prefix == '')
|
212
|
+
{
|
213
|
+
$prefix = $this->_error_prefix;
|
214
|
+
}
|
215
|
+
|
216
|
+
if ($suffix == '')
|
217
|
+
{
|
218
|
+
$suffix = $this->_error_suffix;
|
219
|
+
}
|
220
|
+
|
221
|
+
return $prefix.$this->_field_data[$field]['error'].$suffix;
|
222
|
+
}
|
223
|
+
|
224
|
+
// --------------------------------------------------------------------
|
225
|
+
|
226
|
+
/**
|
227
|
+
* Error String
|
228
|
+
*
|
229
|
+
* Returns the error messages as a string, wrapped in the error delimiters
|
230
|
+
*
|
231
|
+
* @access public
|
232
|
+
* @param string
|
233
|
+
* @param string
|
234
|
+
* @return str
|
235
|
+
*/
|
236
|
+
function error_string($prefix = '', $suffix = '')
|
237
|
+
{
|
238
|
+
// No errrors, validation passes!
|
239
|
+
if (count($this->_error_array) === 0)
|
240
|
+
{
|
241
|
+
return '';
|
242
|
+
}
|
243
|
+
|
244
|
+
if ($prefix == '')
|
245
|
+
{
|
246
|
+
$prefix = $this->_error_prefix;
|
247
|
+
}
|
248
|
+
|
249
|
+
if ($suffix == '')
|
250
|
+
{
|
251
|
+
$suffix = $this->_error_suffix;
|
252
|
+
}
|
253
|
+
|
254
|
+
// Generate the error string
|
255
|
+
$str = '';
|
256
|
+
foreach ($this->_error_array as $val)
|
257
|
+
{
|
258
|
+
if ($val != '')
|
259
|
+
{
|
260
|
+
$str .= $prefix.$val.$suffix."\n";
|
261
|
+
}
|
262
|
+
}
|
263
|
+
|
264
|
+
return $str;
|
265
|
+
}
|
266
|
+
|
267
|
+
// --------------------------------------------------------------------
|
268
|
+
|
269
|
+
/**
|
270
|
+
* Run the Validator
|
271
|
+
*
|
272
|
+
* This function does all the work.
|
273
|
+
*
|
274
|
+
* @access public
|
275
|
+
* @return bool
|
276
|
+
*/
|
277
|
+
function run($group = '')
|
278
|
+
{
|
279
|
+
// Do we even have any data to process? Mm?
|
280
|
+
if (count($_POST) == 0)
|
281
|
+
{
|
282
|
+
return FALSE;
|
283
|
+
}
|
284
|
+
|
285
|
+
// Does the _field_data array containing the validation rules exist?
|
286
|
+
// If not, we look to see if they were assigned via a config file
|
287
|
+
if (count($this->_field_data) == 0)
|
288
|
+
{
|
289
|
+
// No validation rules? We're done...
|
290
|
+
if (count($this->_config_rules) == 0)
|
291
|
+
{
|
292
|
+
return FALSE;
|
293
|
+
}
|
294
|
+
|
295
|
+
// Is there a validation rule for the particular URI being accessed?
|
296
|
+
$uri = ($group == '') ? trim($this->CI->uri->ruri_string(), '/') : $group;
|
297
|
+
|
298
|
+
if ($uri != '' AND isset($this->_config_rules[$uri]))
|
299
|
+
{
|
300
|
+
$this->set_rules($this->_config_rules[$uri]);
|
301
|
+
}
|
302
|
+
else
|
303
|
+
{
|
304
|
+
$this->set_rules($this->_config_rules);
|
305
|
+
}
|
306
|
+
|
307
|
+
// We're we able to set the rules correctly?
|
308
|
+
if (count($this->_field_data) == 0)
|
309
|
+
{
|
310
|
+
log_message('debug', "Unable to find validation rules");
|
311
|
+
return FALSE;
|
312
|
+
}
|
313
|
+
}
|
314
|
+
|
315
|
+
// Load the language file containing error messages
|
316
|
+
$this->CI->lang->load('form_validation');
|
317
|
+
|
318
|
+
// Cycle through the rules for each field, match the
|
319
|
+
// corresponding $_POST item and test for errors
|
320
|
+
foreach ($this->_field_data as $field => $row)
|
321
|
+
{
|
322
|
+
// Fetch the data from the corresponding $_POST array and cache it in the _field_data array.
|
323
|
+
// Depending on whether the field name is an array or a string will determine where we get it from.
|
324
|
+
|
325
|
+
if ($row['is_array'] == TRUE)
|
326
|
+
{
|
327
|
+
$this->_field_data[$field]['postdata'] = $this->_reduce_array($_POST, $row['keys']);
|
328
|
+
}
|
329
|
+
else
|
330
|
+
{
|
331
|
+
if (isset($_POST[$field]) AND $_POST[$field] != "")
|
332
|
+
{
|
333
|
+
$this->_field_data[$field]['postdata'] = $_POST[$field];
|
334
|
+
}
|
335
|
+
}
|
336
|
+
|
337
|
+
$this->_execute($row, explode('|', $row['rules']), $this->_field_data[$field]['postdata']);
|
338
|
+
}
|
339
|
+
|
340
|
+
// Did we end up with any errors?
|
341
|
+
$total_errors = count($this->_error_array);
|
342
|
+
|
343
|
+
if ($total_errors > 0)
|
344
|
+
{
|
345
|
+
$this->_safe_form_data = TRUE;
|
346
|
+
}
|
347
|
+
|
348
|
+
// Now we need to re-set the POST data with the new, processed data
|
349
|
+
$this->_reset_post_array();
|
350
|
+
|
351
|
+
// No errors, validation passes!
|
352
|
+
if ($total_errors == 0)
|
353
|
+
{
|
354
|
+
return TRUE;
|
355
|
+
}
|
356
|
+
|
357
|
+
// Validation fails
|
358
|
+
return FALSE;
|
359
|
+
}
|
360
|
+
|
361
|
+
// --------------------------------------------------------------------
|
362
|
+
|
363
|
+
/**
|
364
|
+
* Traverse a multidimensional $_POST array index until the data is found
|
365
|
+
*
|
366
|
+
* @access private
|
367
|
+
* @param array
|
368
|
+
* @param array
|
369
|
+
* @param integer
|
370
|
+
* @return mixed
|
371
|
+
*/
|
372
|
+
function _reduce_array($array, $keys, $i = 0)
|
373
|
+
{
|
374
|
+
if (is_array($array))
|
375
|
+
{
|
376
|
+
if (isset($keys[$i]))
|
377
|
+
{
|
378
|
+
if (isset($array[$keys[$i]]))
|
379
|
+
{
|
380
|
+
$array = $this->_reduce_array($array[$keys[$i]], $keys, ($i+1));
|
381
|
+
}
|
382
|
+
else
|
383
|
+
{
|
384
|
+
return NULL;
|
385
|
+
}
|
386
|
+
}
|
387
|
+
else
|
388
|
+
{
|
389
|
+
return $array;
|
390
|
+
}
|
391
|
+
}
|
392
|
+
|
393
|
+
return $array;
|
394
|
+
}
|
395
|
+
|
396
|
+
// --------------------------------------------------------------------
|
397
|
+
|
398
|
+
/**
|
399
|
+
* Re-populate the _POST array with our finalized and processed data
|
400
|
+
*
|
401
|
+
* @access private
|
402
|
+
* @return null
|
403
|
+
*/
|
404
|
+
function _reset_post_array()
|
405
|
+
{
|
406
|
+
foreach ($this->_field_data as $field => $row)
|
407
|
+
{
|
408
|
+
if ( ! is_null($row['postdata']))
|
409
|
+
{
|
410
|
+
if ($row['is_array'] == FALSE)
|
411
|
+
{
|
412
|
+
if (isset($_POST[$row['field']]))
|
413
|
+
{
|
414
|
+
$_POST[$row['field']] = $this->prep_for_form($row['postdata']);
|
415
|
+
}
|
416
|
+
}
|
417
|
+
else
|
418
|
+
{
|
419
|
+
// start with a reference
|
420
|
+
$post_ref =& $_POST;
|
421
|
+
|
422
|
+
// before we assign values, make a reference to the right POST key
|
423
|
+
if (count($row['keys']) == 1)
|
424
|
+
{
|
425
|
+
$post_ref =& $post_ref[current($row['keys'])];
|
426
|
+
}
|
427
|
+
else
|
428
|
+
{
|
429
|
+
foreach ($row['keys'] as $val)
|
430
|
+
{
|
431
|
+
$post_ref =& $post_ref[$val];
|
432
|
+
}
|
433
|
+
}
|
434
|
+
|
435
|
+
if (is_array($row['postdata']))
|
436
|
+
{
|
437
|
+
$array = array();
|
438
|
+
foreach ($row['postdata'] as $k => $v)
|
439
|
+
{
|
440
|
+
$array[$k] = $this->prep_for_form($v);
|
441
|
+
}
|
442
|
+
|
443
|
+
$post_ref = $array;
|
444
|
+
}
|
445
|
+
else
|
446
|
+
{
|
447
|
+
$post_ref = $this->prep_for_form($row['postdata']);
|
448
|
+
}
|
449
|
+
}
|
450
|
+
}
|
451
|
+
}
|
452
|
+
}
|
453
|
+
|
454
|
+
// --------------------------------------------------------------------
|
455
|
+
|
456
|
+
/**
|
457
|
+
* Executes the Validation routines
|
458
|
+
*
|
459
|
+
* @access private
|
460
|
+
* @param array
|
461
|
+
* @param array
|
462
|
+
* @param mixed
|
463
|
+
* @param integer
|
464
|
+
* @return mixed
|
465
|
+
*/
|
466
|
+
function _execute($row, $rules, $postdata = NULL, $cycles = 0)
|
467
|
+
{
|
468
|
+
// If the $_POST data is an array we will run a recursive call
|
469
|
+
if (is_array($postdata))
|
470
|
+
{
|
471
|
+
foreach ($postdata as $key => $val)
|
472
|
+
{
|
473
|
+
$this->_execute($row, $rules, $val, $cycles);
|
474
|
+
$cycles++;
|
475
|
+
}
|
476
|
+
|
477
|
+
return;
|
478
|
+
}
|
479
|
+
|
480
|
+
// --------------------------------------------------------------------
|
481
|
+
|
482
|
+
// If the field is blank, but NOT required, no further tests are necessary
|
483
|
+
$callback = FALSE;
|
484
|
+
if ( ! in_array('required', $rules) AND is_null($postdata))
|
485
|
+
{
|
486
|
+
// Before we bail out, does the rule contain a callback?
|
487
|
+
if (preg_match("/(callback_\w+)/", implode(' ', $rules), $match))
|
488
|
+
{
|
489
|
+
$callback = TRUE;
|
490
|
+
$rules = (array('1' => $match[1]));
|
491
|
+
}
|
492
|
+
else
|
493
|
+
{
|
494
|
+
return;
|
495
|
+
}
|
496
|
+
}
|
497
|
+
|
498
|
+
// --------------------------------------------------------------------
|
499
|
+
|
500
|
+
// Isset Test. Typically this rule will only apply to checkboxes.
|
501
|
+
if (is_null($postdata) AND $callback == FALSE)
|
502
|
+
{
|
503
|
+
if (in_array('isset', $rules, TRUE) OR in_array('required', $rules))
|
504
|
+
{
|
505
|
+
// Set the message type
|
506
|
+
$type = (in_array('required', $rules)) ? 'required' : 'isset';
|
507
|
+
|
508
|
+
if ( ! isset($this->_error_messages[$type]))
|
509
|
+
{
|
510
|
+
if (FALSE === ($line = $this->CI->lang->line($type)))
|
511
|
+
{
|
512
|
+
$line = 'The field was not set';
|
513
|
+
}
|
514
|
+
}
|
515
|
+
else
|
516
|
+
{
|
517
|
+
$line = $this->_error_messages[$type];
|
518
|
+
}
|
519
|
+
|
520
|
+
// Build the error message
|
521
|
+
$message = sprintf($line, $this->_translate_fieldname($row['label']));
|
522
|
+
|
523
|
+
// Save the error message
|
524
|
+
$this->_field_data[$row['field']]['error'] = $message;
|
525
|
+
|
526
|
+
if ( ! isset($this->_error_array[$row['field']]))
|
527
|
+
{
|
528
|
+
$this->_error_array[$row['field']] = $message;
|
529
|
+
}
|
530
|
+
}
|
531
|
+
|
532
|
+
return;
|
533
|
+
}
|
534
|
+
|
535
|
+
// --------------------------------------------------------------------
|
536
|
+
|
537
|
+
// Cycle through each rule and run it
|
538
|
+
foreach ($rules As $rule)
|
539
|
+
{
|
540
|
+
$_in_array = FALSE;
|
541
|
+
|
542
|
+
// We set the $postdata variable with the current data in our master array so that
|
543
|
+
// each cycle of the loop is dealing with the processed data from the last cycle
|
544
|
+
if ($row['is_array'] == TRUE AND is_array($this->_field_data[$row['field']]['postdata']))
|
545
|
+
{
|
546
|
+
// We shouldn't need this safety, but just in case there isn't an array index
|
547
|
+
// associated with this cycle we'll bail out
|
548
|
+
if ( ! isset($this->_field_data[$row['field']]['postdata'][$cycles]))
|
549
|
+
{
|
550
|
+
continue;
|
551
|
+
}
|
552
|
+
|
553
|
+
$postdata = $this->_field_data[$row['field']]['postdata'][$cycles];
|
554
|
+
$_in_array = TRUE;
|
555
|
+
}
|
556
|
+
else
|
557
|
+
{
|
558
|
+
$postdata = $this->_field_data[$row['field']]['postdata'];
|
559
|
+
}
|
560
|
+
|
561
|
+
// --------------------------------------------------------------------
|
562
|
+
|
563
|
+
// Is the rule a callback?
|
564
|
+
$callback = FALSE;
|
565
|
+
if (substr($rule, 0, 9) == 'callback_')
|
566
|
+
{
|
567
|
+
$rule = substr($rule, 9);
|
568
|
+
$callback = TRUE;
|
569
|
+
}
|
570
|
+
|
571
|
+
// Strip the parameter (if exists) from the rule
|
572
|
+
// Rules can contain a parameter: max_length[5]
|
573
|
+
$param = FALSE;
|
574
|
+
if (preg_match("/(.*?)\[(.*?)\]/", $rule, $match))
|
575
|
+
{
|
576
|
+
$rule = $match[1];
|
577
|
+
$param = $match[2];
|
578
|
+
}
|
579
|
+
|
580
|
+
// Call the function that corresponds to the rule
|
581
|
+
if ($callback === TRUE)
|
582
|
+
{
|
583
|
+
if ( ! method_exists($this->CI, $rule))
|
584
|
+
{
|
585
|
+
continue;
|
586
|
+
}
|
587
|
+
|
588
|
+
// Run the function and grab the result
|
589
|
+
$result = $this->CI->$rule($postdata, $param);
|
590
|
+
|
591
|
+
// Re-assign the result to the master data array
|
592
|
+
if ($_in_array == TRUE)
|
593
|
+
{
|
594
|
+
$this->_field_data[$row['field']]['postdata'][$cycles] = (is_bool($result)) ? $postdata : $result;
|
595
|
+
}
|
596
|
+
else
|
597
|
+
{
|
598
|
+
$this->_field_data[$row['field']]['postdata'] = (is_bool($result)) ? $postdata : $result;
|
599
|
+
}
|
600
|
+
|
601
|
+
// If the field isn't required and we just processed a callback we'll move on...
|
602
|
+
if ( ! in_array('required', $rules, TRUE) AND $result !== FALSE)
|
603
|
+
{
|
604
|
+
continue;
|
605
|
+
}
|
606
|
+
}
|
607
|
+
else
|
608
|
+
{
|
609
|
+
if ( ! method_exists($this, $rule))
|
610
|
+
{
|
611
|
+
// If our own wrapper function doesn't exist we see if a native PHP function does.
|
612
|
+
// Users can use any native PHP function call that has one param.
|
613
|
+
if (function_exists($rule))
|
614
|
+
{
|
615
|
+
$result = $rule($postdata);
|
616
|
+
|
617
|
+
if ($_in_array == TRUE)
|
618
|
+
{
|
619
|
+
$this->_field_data[$row['field']]['postdata'][$cycles] = (is_bool($result)) ? $postdata : $result;
|
620
|
+
}
|
621
|
+
else
|
622
|
+
{
|
623
|
+
$this->_field_data[$row['field']]['postdata'] = (is_bool($result)) ? $postdata : $result;
|
624
|
+
}
|
625
|
+
}
|
626
|
+
|
627
|
+
continue;
|
628
|
+
}
|
629
|
+
|
630
|
+
$result = $this->$rule($postdata, $param);
|
631
|
+
|
632
|
+
if ($_in_array == TRUE)
|
633
|
+
{
|
634
|
+
$this->_field_data[$row['field']]['postdata'][$cycles] = (is_bool($result)) ? $postdata : $result;
|
635
|
+
}
|
636
|
+
else
|
637
|
+
{
|
638
|
+
$this->_field_data[$row['field']]['postdata'] = (is_bool($result)) ? $postdata : $result;
|
639
|
+
}
|
640
|
+
}
|
641
|
+
|
642
|
+
// Did the rule test negatively? If so, grab the error.
|
643
|
+
if ($result === FALSE)
|
644
|
+
{
|
645
|
+
if ( ! isset($this->_error_messages[$rule]))
|
646
|
+
{
|
647
|
+
if (FALSE === ($line = $this->CI->lang->line($rule)))
|
648
|
+
{
|
649
|
+
$line = 'Unable to access an error message corresponding to your field name.';
|
650
|
+
}
|
651
|
+
}
|
652
|
+
else
|
653
|
+
{
|
654
|
+
$line = $this->_error_messages[$rule];
|
655
|
+
}
|
656
|
+
|
657
|
+
// Is the parameter we are inserting into the error message the name
|
658
|
+
// of another field? If so we need to grab its "field label"
|
659
|
+
if (isset($this->_field_data[$param]) AND isset($this->_field_data[$param]['label']))
|
660
|
+
{
|
661
|
+
$param = $this->_field_data[$param]['label'];
|
662
|
+
}
|
663
|
+
|
664
|
+
// Build the error message
|
665
|
+
$message = sprintf($line, $this->_translate_fieldname($row['label']), $param);
|
666
|
+
|
667
|
+
// Save the error message
|
668
|
+
$this->_field_data[$row['field']]['error'] = $message;
|
669
|
+
|
670
|
+
if ( ! isset($this->_error_array[$row['field']]))
|
671
|
+
{
|
672
|
+
$this->_error_array[$row['field']] = $message;
|
673
|
+
}
|
674
|
+
|
675
|
+
return;
|
676
|
+
}
|
677
|
+
}
|
678
|
+
}
|
679
|
+
|
680
|
+
// --------------------------------------------------------------------
|
681
|
+
|
682
|
+
/**
|
683
|
+
* Translate a field name
|
684
|
+
*
|
685
|
+
* @access private
|
686
|
+
* @param string the field name
|
687
|
+
* @return string
|
688
|
+
*/
|
689
|
+
function _translate_fieldname($fieldname)
|
690
|
+
{
|
691
|
+
// Do we need to translate the field name?
|
692
|
+
// We look for the prefix lang: to determine this
|
693
|
+
if (substr($fieldname, 0, 5) == 'lang:')
|
694
|
+
{
|
695
|
+
// Grab the variable
|
696
|
+
$line = substr($fieldname, 5);
|
697
|
+
|
698
|
+
// Were we able to translate the field name? If not we use $line
|
699
|
+
if (FALSE === ($fieldname = $this->CI->lang->line($line)))
|
700
|
+
{
|
701
|
+
return $line;
|
702
|
+
}
|
703
|
+
}
|
704
|
+
|
705
|
+
return $fieldname;
|
706
|
+
}
|
707
|
+
|
708
|
+
// --------------------------------------------------------------------
|
709
|
+
|
710
|
+
/**
|
711
|
+
* Get the value from a form
|
712
|
+
*
|
713
|
+
* Permits you to repopulate a form field with the value it was submitted
|
714
|
+
* with, or, if that value doesn't exist, with the default
|
715
|
+
*
|
716
|
+
* @access public
|
717
|
+
* @param string the field name
|
718
|
+
* @param string
|
719
|
+
* @return void
|
720
|
+
*/
|
721
|
+
function set_value($field = '', $default = '')
|
722
|
+
{
|
723
|
+
if ( ! isset($this->_field_data[$field]))
|
724
|
+
{
|
725
|
+
return $default;
|
726
|
+
}
|
727
|
+
|
728
|
+
return $this->_field_data[$field]['postdata'];
|
729
|
+
}
|
730
|
+
|
731
|
+
// --------------------------------------------------------------------
|
732
|
+
|
733
|
+
/**
|
734
|
+
* Set Select
|
735
|
+
*
|
736
|
+
* Enables pull-down lists to be set to the value the user
|
737
|
+
* selected in the event of an error
|
738
|
+
*
|
739
|
+
* @access public
|
740
|
+
* @param string
|
741
|
+
* @param string
|
742
|
+
* @return string
|
743
|
+
*/
|
744
|
+
function set_select($field = '', $value = '', $default = FALSE)
|
745
|
+
{
|
746
|
+
if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata']))
|
747
|
+
{
|
748
|
+
if ($default === TRUE AND count($this->_field_data) === 0)
|
749
|
+
{
|
750
|
+
return ' selected="selected"';
|
751
|
+
}
|
752
|
+
return '';
|
753
|
+
}
|
754
|
+
|
755
|
+
$field = $this->_field_data[$field]['postdata'];
|
756
|
+
|
757
|
+
if (is_array($field))
|
758
|
+
{
|
759
|
+
if ( ! in_array($value, $field))
|
760
|
+
{
|
761
|
+
return '';
|
762
|
+
}
|
763
|
+
}
|
764
|
+
else
|
765
|
+
{
|
766
|
+
if (($field == '' OR $value == '') OR ($field != $value))
|
767
|
+
{
|
768
|
+
return '';
|
769
|
+
}
|
770
|
+
}
|
771
|
+
|
772
|
+
return ' selected="selected"';
|
773
|
+
}
|
774
|
+
|
775
|
+
// --------------------------------------------------------------------
|
776
|
+
|
777
|
+
/**
|
778
|
+
* Set Radio
|
779
|
+
*
|
780
|
+
* Enables radio buttons to be set to the value the user
|
781
|
+
* selected in the event of an error
|
782
|
+
*
|
783
|
+
* @access public
|
784
|
+
* @param string
|
785
|
+
* @param string
|
786
|
+
* @return string
|
787
|
+
*/
|
788
|
+
function set_radio($field = '', $value = '', $default = FALSE)
|
789
|
+
{
|
790
|
+
if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata']))
|
791
|
+
{
|
792
|
+
if ($default === TRUE AND count($this->_field_data) === 0)
|
793
|
+
{
|
794
|
+
return ' checked="checked"';
|
795
|
+
}
|
796
|
+
return '';
|
797
|
+
}
|
798
|
+
|
799
|
+
$field = $this->_field_data[$field]['postdata'];
|
800
|
+
|
801
|
+
if (is_array($field))
|
802
|
+
{
|
803
|
+
if ( ! in_array($value, $field))
|
804
|
+
{
|
805
|
+
return '';
|
806
|
+
}
|
807
|
+
}
|
808
|
+
else
|
809
|
+
{
|
810
|
+
if (($field == '' OR $value == '') OR ($field != $value))
|
811
|
+
{
|
812
|
+
return '';
|
813
|
+
}
|
814
|
+
}
|
815
|
+
|
816
|
+
return ' checked="checked"';
|
817
|
+
}
|
818
|
+
|
819
|
+
// --------------------------------------------------------------------
|
820
|
+
|
821
|
+
/**
|
822
|
+
* Set Checkbox
|
823
|
+
*
|
824
|
+
* Enables checkboxes to be set to the value the user
|
825
|
+
* selected in the event of an error
|
826
|
+
*
|
827
|
+
* @access public
|
828
|
+
* @param string
|
829
|
+
* @param string
|
830
|
+
* @return string
|
831
|
+
*/
|
832
|
+
function set_checkbox($field = '', $value = '', $default = FALSE)
|
833
|
+
{
|
834
|
+
if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata']))
|
835
|
+
{
|
836
|
+
if ($default === TRUE AND count($this->_field_data) === 0)
|
837
|
+
{
|
838
|
+
return ' checked="checked"';
|
839
|
+
}
|
840
|
+
return '';
|
841
|
+
}
|
842
|
+
|
843
|
+
$field = $this->_field_data[$field]['postdata'];
|
844
|
+
|
845
|
+
if (is_array($field))
|
846
|
+
{
|
847
|
+
if ( ! in_array($value, $field))
|
848
|
+
{
|
849
|
+
return '';
|
850
|
+
}
|
851
|
+
}
|
852
|
+
else
|
853
|
+
{
|
854
|
+
if (($field == '' OR $value == '') OR ($field != $value))
|
855
|
+
{
|
856
|
+
return '';
|
857
|
+
}
|
858
|
+
}
|
859
|
+
|
860
|
+
return ' checked="checked"';
|
861
|
+
}
|
862
|
+
|
863
|
+
// --------------------------------------------------------------------
|
864
|
+
|
865
|
+
/**
|
866
|
+
* Required
|
867
|
+
*
|
868
|
+
* @access public
|
869
|
+
* @param string
|
870
|
+
* @return bool
|
871
|
+
*/
|
872
|
+
function required($str)
|
873
|
+
{
|
874
|
+
if ( ! is_array($str))
|
875
|
+
{
|
876
|
+
return (trim($str) == '') ? FALSE : TRUE;
|
877
|
+
}
|
878
|
+
else
|
879
|
+
{
|
880
|
+
return ( ! empty($str));
|
881
|
+
}
|
882
|
+
}
|
883
|
+
|
884
|
+
// --------------------------------------------------------------------
|
885
|
+
|
886
|
+
/**
|
887
|
+
* Match one field to another
|
888
|
+
*
|
889
|
+
* @access public
|
890
|
+
* @param string
|
891
|
+
* @param field
|
892
|
+
* @return bool
|
893
|
+
*/
|
894
|
+
function matches($str, $field)
|
895
|
+
{
|
896
|
+
if ( ! isset($_POST[$field]))
|
897
|
+
{
|
898
|
+
return FALSE;
|
899
|
+
}
|
900
|
+
|
901
|
+
$field = $_POST[$field];
|
902
|
+
|
903
|
+
return ($str !== $field) ? FALSE : TRUE;
|
904
|
+
}
|
905
|
+
|
906
|
+
// --------------------------------------------------------------------
|
907
|
+
|
908
|
+
/**
|
909
|
+
* Minimum Length
|
910
|
+
*
|
911
|
+
* @access public
|
912
|
+
* @param string
|
913
|
+
* @param value
|
914
|
+
* @return bool
|
915
|
+
*/
|
916
|
+
function min_length($str, $val)
|
917
|
+
{
|
918
|
+
if (preg_match("/[^0-9]/", $val))
|
919
|
+
{
|
920
|
+
return FALSE;
|
921
|
+
}
|
922
|
+
|
923
|
+
if (function_exists('mb_strlen'))
|
924
|
+
{
|
925
|
+
return (mb_strlen($str) < $val) ? FALSE : TRUE;
|
926
|
+
}
|
927
|
+
|
928
|
+
return (strlen($str) < $val) ? FALSE : TRUE;
|
929
|
+
}
|
930
|
+
|
931
|
+
// --------------------------------------------------------------------
|
932
|
+
|
933
|
+
/**
|
934
|
+
* Max Length
|
935
|
+
*
|
936
|
+
* @access public
|
937
|
+
* @param string
|
938
|
+
* @param value
|
939
|
+
* @return bool
|
940
|
+
*/
|
941
|
+
function max_length($str, $val)
|
942
|
+
{
|
943
|
+
if (preg_match("/[^0-9]/", $val))
|
944
|
+
{
|
945
|
+
return FALSE;
|
946
|
+
}
|
947
|
+
|
948
|
+
if (function_exists('mb_strlen'))
|
949
|
+
{
|
950
|
+
return (mb_strlen($str) > $val) ? FALSE : TRUE;
|
951
|
+
}
|
952
|
+
|
953
|
+
return (strlen($str) > $val) ? FALSE : TRUE;
|
954
|
+
}
|
955
|
+
|
956
|
+
// --------------------------------------------------------------------
|
957
|
+
|
958
|
+
/**
|
959
|
+
* Exact Length
|
960
|
+
*
|
961
|
+
* @access public
|
962
|
+
* @param string
|
963
|
+
* @param value
|
964
|
+
* @return bool
|
965
|
+
*/
|
966
|
+
function exact_length($str, $val)
|
967
|
+
{
|
968
|
+
if (preg_match("/[^0-9]/", $val))
|
969
|
+
{
|
970
|
+
return FALSE;
|
971
|
+
}
|
972
|
+
|
973
|
+
if (function_exists('mb_strlen'))
|
974
|
+
{
|
975
|
+
return (mb_strlen($str) != $val) ? FALSE : TRUE;
|
976
|
+
}
|
977
|
+
|
978
|
+
return (strlen($str) != $val) ? FALSE : TRUE;
|
979
|
+
}
|
980
|
+
|
981
|
+
// --------------------------------------------------------------------
|
982
|
+
|
983
|
+
/**
|
984
|
+
* Valid Email
|
985
|
+
*
|
986
|
+
* @access public
|
987
|
+
* @param string
|
988
|
+
* @return bool
|
989
|
+
*/
|
990
|
+
function valid_email($str)
|
991
|
+
{
|
992
|
+
return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;
|
993
|
+
}
|
994
|
+
|
995
|
+
// --------------------------------------------------------------------
|
996
|
+
|
997
|
+
/**
|
998
|
+
* Valid Emails
|
999
|
+
*
|
1000
|
+
* @access public
|
1001
|
+
* @param string
|
1002
|
+
* @return bool
|
1003
|
+
*/
|
1004
|
+
function valid_emails($str)
|
1005
|
+
{
|
1006
|
+
if (strpos($str, ',') === FALSE)
|
1007
|
+
{
|
1008
|
+
return $this->valid_email(trim($str));
|
1009
|
+
}
|
1010
|
+
|
1011
|
+
foreach(explode(',', $str) as $email)
|
1012
|
+
{
|
1013
|
+
if (trim($email) != '' && $this->valid_email(trim($email)) === FALSE)
|
1014
|
+
{
|
1015
|
+
return FALSE;
|
1016
|
+
}
|
1017
|
+
}
|
1018
|
+
|
1019
|
+
return TRUE;
|
1020
|
+
}
|
1021
|
+
|
1022
|
+
// --------------------------------------------------------------------
|
1023
|
+
|
1024
|
+
/**
|
1025
|
+
* Validate IP Address
|
1026
|
+
*
|
1027
|
+
* @access public
|
1028
|
+
* @param string
|
1029
|
+
* @return string
|
1030
|
+
*/
|
1031
|
+
function valid_ip($ip)
|
1032
|
+
{
|
1033
|
+
return $this->CI->input->valid_ip($ip);
|
1034
|
+
}
|
1035
|
+
|
1036
|
+
// --------------------------------------------------------------------
|
1037
|
+
|
1038
|
+
/**
|
1039
|
+
* Alpha
|
1040
|
+
*
|
1041
|
+
* @access public
|
1042
|
+
* @param string
|
1043
|
+
* @return bool
|
1044
|
+
*/
|
1045
|
+
function alpha($str)
|
1046
|
+
{
|
1047
|
+
return ( ! preg_match("/^([a-z])+$/i", $str)) ? FALSE : TRUE;
|
1048
|
+
}
|
1049
|
+
|
1050
|
+
// --------------------------------------------------------------------
|
1051
|
+
|
1052
|
+
/**
|
1053
|
+
* Alpha-numeric
|
1054
|
+
*
|
1055
|
+
* @access public
|
1056
|
+
* @param string
|
1057
|
+
* @return bool
|
1058
|
+
*/
|
1059
|
+
function alpha_numeric($str)
|
1060
|
+
{
|
1061
|
+
return ( ! preg_match("/^([a-z0-9])+$/i", $str)) ? FALSE : TRUE;
|
1062
|
+
}
|
1063
|
+
|
1064
|
+
// --------------------------------------------------------------------
|
1065
|
+
|
1066
|
+
/**
|
1067
|
+
* Alpha-numeric with underscores and dashes
|
1068
|
+
*
|
1069
|
+
* @access public
|
1070
|
+
* @param string
|
1071
|
+
* @return bool
|
1072
|
+
*/
|
1073
|
+
function alpha_dash($str)
|
1074
|
+
{
|
1075
|
+
return ( ! preg_match("/^([-a-z0-9_-])+$/i", $str)) ? FALSE : TRUE;
|
1076
|
+
}
|
1077
|
+
|
1078
|
+
// --------------------------------------------------------------------
|
1079
|
+
|
1080
|
+
/**
|
1081
|
+
* Numeric
|
1082
|
+
*
|
1083
|
+
* @access public
|
1084
|
+
* @param string
|
1085
|
+
* @return bool
|
1086
|
+
*/
|
1087
|
+
function numeric($str)
|
1088
|
+
{
|
1089
|
+
return (bool)preg_match( '/^[\-+]?[0-9]*\.?[0-9]+$/', $str);
|
1090
|
+
|
1091
|
+
}
|
1092
|
+
|
1093
|
+
// --------------------------------------------------------------------
|
1094
|
+
|
1095
|
+
/**
|
1096
|
+
* Is Numeric
|
1097
|
+
*
|
1098
|
+
* @access public
|
1099
|
+
* @param string
|
1100
|
+
* @return bool
|
1101
|
+
*/
|
1102
|
+
function is_numeric($str)
|
1103
|
+
{
|
1104
|
+
return ( ! is_numeric($str)) ? FALSE : TRUE;
|
1105
|
+
}
|
1106
|
+
|
1107
|
+
// --------------------------------------------------------------------
|
1108
|
+
|
1109
|
+
/**
|
1110
|
+
* Integer
|
1111
|
+
*
|
1112
|
+
* @access public
|
1113
|
+
* @param string
|
1114
|
+
* @return bool
|
1115
|
+
*/
|
1116
|
+
function integer($str)
|
1117
|
+
{
|
1118
|
+
return (bool)preg_match( '/^[\-+]?[0-9]+$/', $str);
|
1119
|
+
}
|
1120
|
+
|
1121
|
+
// --------------------------------------------------------------------
|
1122
|
+
|
1123
|
+
/**
|
1124
|
+
* Is a Natural number (0,1,2,3, etc.)
|
1125
|
+
*
|
1126
|
+
* @access public
|
1127
|
+
* @param string
|
1128
|
+
* @return bool
|
1129
|
+
*/
|
1130
|
+
function is_natural($str)
|
1131
|
+
{
|
1132
|
+
return (bool)preg_match( '/^[0-9]+$/', $str);
|
1133
|
+
}
|
1134
|
+
|
1135
|
+
// --------------------------------------------------------------------
|
1136
|
+
|
1137
|
+
/**
|
1138
|
+
* Is a Natural number, but not a zero (1,2,3, etc.)
|
1139
|
+
*
|
1140
|
+
* @access public
|
1141
|
+
* @param string
|
1142
|
+
* @return bool
|
1143
|
+
*/
|
1144
|
+
function is_natural_no_zero($str)
|
1145
|
+
{
|
1146
|
+
if ( ! preg_match( '/^[0-9]+$/', $str))
|
1147
|
+
{
|
1148
|
+
return FALSE;
|
1149
|
+
}
|
1150
|
+
|
1151
|
+
if ($str == 0)
|
1152
|
+
{
|
1153
|
+
return FALSE;
|
1154
|
+
}
|
1155
|
+
|
1156
|
+
return TRUE;
|
1157
|
+
}
|
1158
|
+
|
1159
|
+
// --------------------------------------------------------------------
|
1160
|
+
|
1161
|
+
/**
|
1162
|
+
* Valid Base64
|
1163
|
+
*
|
1164
|
+
* Tests a string for characters outside of the Base64 alphabet
|
1165
|
+
* as defined by RFC 2045 http://www.faqs.org/rfcs/rfc2045
|
1166
|
+
*
|
1167
|
+
* @access public
|
1168
|
+
* @param string
|
1169
|
+
* @return bool
|
1170
|
+
*/
|
1171
|
+
function valid_base64($str)
|
1172
|
+
{
|
1173
|
+
return (bool) ! preg_match('/[^a-zA-Z0-9\/\+=]/', $str);
|
1174
|
+
}
|
1175
|
+
|
1176
|
+
// --------------------------------------------------------------------
|
1177
|
+
|
1178
|
+
/**
|
1179
|
+
* Prep data for form
|
1180
|
+
*
|
1181
|
+
* This function allows HTML to be safely shown in a form.
|
1182
|
+
* Special characters are converted.
|
1183
|
+
*
|
1184
|
+
* @access public
|
1185
|
+
* @param string
|
1186
|
+
* @return string
|
1187
|
+
*/
|
1188
|
+
function prep_for_form($data = '')
|
1189
|
+
{
|
1190
|
+
if (is_array($data))
|
1191
|
+
{
|
1192
|
+
foreach ($data as $key => $val)
|
1193
|
+
{
|
1194
|
+
$data[$key] = $this->prep_for_form($val);
|
1195
|
+
}
|
1196
|
+
|
1197
|
+
return $data;
|
1198
|
+
}
|
1199
|
+
|
1200
|
+
if ($this->_safe_form_data == FALSE OR $data === '')
|
1201
|
+
{
|
1202
|
+
return $data;
|
1203
|
+
}
|
1204
|
+
|
1205
|
+
return str_replace(array("'", '"', '<', '>'), array("'", """, '<', '>'), stripslashes($data));
|
1206
|
+
}
|
1207
|
+
|
1208
|
+
// --------------------------------------------------------------------
|
1209
|
+
|
1210
|
+
/**
|
1211
|
+
* Prep URL
|
1212
|
+
*
|
1213
|
+
* @access public
|
1214
|
+
* @param string
|
1215
|
+
* @return string
|
1216
|
+
*/
|
1217
|
+
function prep_url($str = '')
|
1218
|
+
{
|
1219
|
+
if ($str == 'http://' OR $str == '')
|
1220
|
+
{
|
1221
|
+
return '';
|
1222
|
+
}
|
1223
|
+
|
1224
|
+
if (substr($str, 0, 7) != 'http://' && substr($str, 0, 8) != 'https://')
|
1225
|
+
{
|
1226
|
+
$str = 'http://'.$str;
|
1227
|
+
}
|
1228
|
+
|
1229
|
+
return $str;
|
1230
|
+
}
|
1231
|
+
|
1232
|
+
// --------------------------------------------------------------------
|
1233
|
+
|
1234
|
+
/**
|
1235
|
+
* Strip Image Tags
|
1236
|
+
*
|
1237
|
+
* @access public
|
1238
|
+
* @param string
|
1239
|
+
* @return string
|
1240
|
+
*/
|
1241
|
+
function strip_image_tags($str)
|
1242
|
+
{
|
1243
|
+
return $this->CI->input->strip_image_tags($str);
|
1244
|
+
}
|
1245
|
+
|
1246
|
+
// --------------------------------------------------------------------
|
1247
|
+
|
1248
|
+
/**
|
1249
|
+
* XSS Clean
|
1250
|
+
*
|
1251
|
+
* @access public
|
1252
|
+
* @param string
|
1253
|
+
* @return string
|
1254
|
+
*/
|
1255
|
+
function xss_clean($str)
|
1256
|
+
{
|
1257
|
+
return $this->CI->input->xss_clean($str);
|
1258
|
+
}
|
1259
|
+
|
1260
|
+
// --------------------------------------------------------------------
|
1261
|
+
|
1262
|
+
/**
|
1263
|
+
* Convert PHP tags to entities
|
1264
|
+
*
|
1265
|
+
* @access public
|
1266
|
+
* @param string
|
1267
|
+
* @return string
|
1268
|
+
*/
|
1269
|
+
function encode_php_tags($str)
|
1270
|
+
{
|
1271
|
+
return str_replace(array('<?php', '<?PHP', '<?', '?>'), array('<?php', '<?PHP', '<?', '?>'), $str);
|
1272
|
+
}
|
1273
|
+
|
1274
|
+
}
|
1275
|
+
// END Form Validation Class
|
1276
|
+
|
1277
|
+
/* End of file Form_validation.php */
|
1278
|
+
/* Location: ./system/libraries/Form_validation.php */
|